garbage collection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ömer KUL

    #1

    garbage collection

    hi,
    i have a garbage collection problem. i have an application writen by
    vb.net, i am opening a form and in this form there is a big query. when i
    open the form, it takes 80 mb memory because of the data table. when i closed
    the form it is already taking 80 mb memory. where is garbage collection? i am
    waiting 30 minutes but memory usage is not decreasing. what must i do?
    thanks,
    Ömer KUL
  • Sean Hederman

    #2
    Re: garbage collection

    Have a look at


    "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
    news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=blue]
    > hi,
    > i have a garbage collection problem. i have an application writen by
    > vb.net, i am opening a form and in this form there is a big query. when i
    > open the form, it takes 80 mb memory because of the data table. when i
    > closed
    > the form it is already taking 80 mb memory. where is garbage collection? i
    > am
    > waiting 30 minutes but memory usage is not decreasing. what must i do?
    > thanks,
    > Ömer KUL[/color]


    Comment

    • Ömer KUL

      #3
      Re: garbage collection

      hi Hederman,
      i have read the article. thank you very much for your help. the article is
      very helpful but it is not answering my question. i am opening a form and
      memory usage is increasing(80 mb), after that i am closing it but memory
      usage is not decreasing. whenever i open the form memory usage is increasing
      80 mb and going on so... that is the problem...
      thanks
      Ömer KUL

      "Sean Hederman":
      [color=blue]
      > Have a look at
      > http://getdotnetco.web101.discountas...%20Mystery.htm
      >
      > "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
      > news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=green]
      > > hi,
      > > i have a garbage collection problem. i have an application writen by
      > > vb.net, i am opening a form and in this form there is a big query. when i
      > > open the form, it takes 80 mb memory because of the data table. when i
      > > closed
      > > the form it is already taking 80 mb memory. where is garbage collection? i
      > > am
      > > waiting 30 minutes but memory usage is not decreasing. what must i do?
      > > thanks,
      > > Ömer KUL[/color]
      >
      >
      >[/color]

      Comment

      • Sean Hederman

        #4
        Re: garbage collection

        If you're not holding any references to your datasets then the CLR will free
        the memory when it needs to, not on some schedule. So the point would be to
        ensure that the references to your datasets are being cleared.

        "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
        news:05032427-6FE4-41AA-A2FC-0F70DDC8B2F6@mi crosoft.com...[color=blue]
        > hi Hederman,
        > i have read the article. thank you very much for your help. the article is
        > very helpful but it is not answering my question. i am opening a form and
        > memory usage is increasing(80 mb), after that i am closing it but memory
        > usage is not decreasing. whenever i open the form memory usage is
        > increasing
        > 80 mb and going on so... that is the problem...
        > thanks
        > Ömer KUL
        >
        > "Sean Hederman":
        >[color=green]
        >> Have a look at
        >> http://getdotnetco.web101.discountas...%20Mystery.htm
        >>
        >> "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
        >> news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=darkred]
        >> > hi,
        >> > i have a garbage collection problem. i have an application writen by
        >> > vb.net, i am opening a form and in this form there is a big query. when
        >> > i
        >> > open the form, it takes 80 mb memory because of the data table. when i
        >> > closed
        >> > the form it is already taking 80 mb memory. where is garbage
        >> > collection? i
        >> > am
        >> > waiting 30 minutes but memory usage is not decreasing. what must i do?
        >> > thanks,
        >> > Ömer KUL[/color]
        >>
        >>
        >>[/color][/color]


        Comment

        • Rob Windsor [MVP]

          #5
          Re: garbage collection

          Task Manager doesn't always show memory usage correctly. To see this follow
          these steps:

          - Create a new Windows Forms application
          - Run it
          - Check memory usage in Task Manager
          - My computer shows 15,554 K
          - Minimize the app
          - Check memory usage in Task Manager
          - My computer shows 864 K
          - Restore the app
          - Check memory usage in Task Manager
          - My computer shows 1,784 K

          Try minimizing the app after you close the form and see if the memory usage
          changes.

          --
          Rob Windsor [MVP-VB]
          G6 Consulting
          Toronto, Canada


          "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
          news:05032427-6FE4-41AA-A2FC-0F70DDC8B2F6@mi crosoft.com...[color=blue]
          > hi Hederman,
          > i have read the article. thank you very much for your help. the article is
          > very helpful but it is not answering my question. i am opening a form and
          > memory usage is increasing(80 mb), after that i am closing it but memory
          > usage is not decreasing. whenever i open the form memory usage is
          > increasing
          > 80 mb and going on so... that is the problem...
          > thanks
          > Ömer KUL
          >
          > "Sean Hederman":
          >[color=green]
          >> Have a look at
          >> http://getdotnetco.web101.discountas...%20Mystery.htm
          >>
          >> "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
          >> news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=darkred]
          >> > hi,
          >> > i have a garbage collection problem. i have an application writen by
          >> > vb.net, i am opening a form and in this form there is a big query. when
          >> > i
          >> > open the form, it takes 80 mb memory because of the data table. when i
          >> > closed
          >> > the form it is already taking 80 mb memory. where is garbage
          >> > collection? i
          >> > am
          >> > waiting 30 minutes but memory usage is not decreasing. what must i do?
          >> > thanks,
          >> > Ömer KUL[/color]
          >>
          >>
          >>[/color][/color]


          Comment

          • Willy Denoyette [MVP]

            #6
            Re: garbage collection


            "Rob Windsor [MVP]" <rob.windsor.no .spam@gmail.com > wrote in message
            news:OKr182IWFH A.2684@TK2MSFTN GP09.phx.gbl...[color=blue]
            > Task Manager doesn't always show memory usage correctly. To see this
            > follow these steps:
            >
            > - Create a new Windows Forms application
            > - Run it
            > - Check memory usage in Task Manager
            > - My computer shows 15,554 K
            > - Minimize the app
            > - Check memory usage in Task Manager
            > - My computer shows 864 K
            > - Restore the app
            > - Check memory usage in Task Manager
            > - My computer shows 1,784 K
            >
            > Try minimizing the app after you close the form and see if the memory
            > usage changes.[/color]


            And what makes you think this isn't correct here?
            The OS automatically reduces the workingset of a windows application
            (any)when minimizing, this has been done since NT4 was introduced years ago.
            Taskman takes it's values from the preformance counters, do you mean that
            these aren't correct?

            Willy.


            Comment

            • Willy Denoyette [MVP]

              #7
              Re: garbage collection


              "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
              news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=blue]
              > hi,
              > i have a garbage collection problem. i have an application writen by
              > vb.net, i am opening a form and in this form there is a big query. when i
              > open the form, it takes 80 mb memory because of the data table. when i
              > closed
              > the form it is already taking 80 mb memory. where is garbage collection? i
              > am
              > waiting 30 minutes but memory usage is not decreasing. what must i do?
              > thanks,
              > Ömer KUL[/color]

              When there is no garbage, there is nothing to collect, that's how the GC
              works, so in your case there is no garbage because you are still holding
              references to your Data Tables. Please post your code if you want to get any
              more help.

              Willy.


              Comment

              • Ömer KUL

                #8
                Re: garbage collection

                Hi Willy,
                i am closing the form that increases the memory usage. are not the all
                variables and controls on the form disposed? after now, does not the GC
                collect them?
                i can not send you all code, because it is an ERP packet and it is 50 mb
                when zipped. i can send you code samples if you want.
                thanks
                Ömer KUL

                "Willy Denoyette [MVP]":
                [color=blue]
                >
                > "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
                > news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=green]
                > > hi,
                > > i have a garbage collection problem. i have an application writen by
                > > vb.net, i am opening a form and in this form there is a big query. when i
                > > open the form, it takes 80 mb memory because of the data table. when i
                > > closed
                > > the form it is already taking 80 mb memory. where is garbage collection? i
                > > am
                > > waiting 30 minutes but memory usage is not decreasing. what must i do?
                > > thanks,
                > > Ömer KUL[/color]
                >
                > When there is no garbage, there is nothing to collect, that's how the GC
                > works, so in your case there is no garbage because you are still holding
                > references to your Data Tables. Please post your code if you want to get any
                > more help.
                >
                > Willy.
                >
                >
                >[/color]

                Comment

                • Jon Shemitz

                  #9
                  Re: garbage collection

                  Ömer KUL wrote:
                  [color=blue]
                  > i have a garbage collection problem. i have an application writen by
                  > vb.net, i am opening a form and in this form there is a big query. when i
                  > open the form, it takes 80 mb memory because of the data table. when i closed
                  > the form it is already taking 80 mb memory. where is garbage collection? i am
                  > waiting 30 minutes but memory usage is not decreasing. what must i do?[/color]

                  Merely waiting won't do anything - garbage collection is triggered by
                  allocations, not a timer.

                  --

                  Midnight Beach is Jon Shemitz, a freelance programmer and author. Jon offers software consulting and contract services, and recently finished his 2nd book - .NET 2.0 for Delphi Programmers.

                  Comment

                  • Sean Hederman

                    #10
                    Re: garbage collection

                    "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
                    news:AD4FD022-4283-4D01-85A9-B376FCF0BD1C@mi crosoft.com...[color=blue]
                    > Hi Willy,
                    > i am closing the form that increases the memory usage. are not the all
                    > variables and controls on the form disposed? after now, does not the GC
                    > collect them?[/color]

                    No, only those variables that are only referenced on the form will be
                    available for GC, and just because they're available doesn't mean they will
                    be GC'd.
                    [color=blue]
                    > i can not send you all code, because it is an ERP packet and it is 50 mb
                    > when zipped. i can send you code samples if you want.
                    > thanks
                    > Ömer KUL
                    >
                    > "Willy Denoyette [MVP]":
                    >[color=green]
                    >>
                    >> "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
                    >> news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=darkred]
                    >> > hi,
                    >> > i have a garbage collection problem. i have an application writen by
                    >> > vb.net, i am opening a form and in this form there is a big query. when
                    >> > i
                    >> > open the form, it takes 80 mb memory because of the data table. when i
                    >> > closed
                    >> > the form it is already taking 80 mb memory. where is garbage
                    >> > collection? i
                    >> > am
                    >> > waiting 30 minutes but memory usage is not decreasing. what must i do?
                    >> > thanks,
                    >> > Ã-mer KUL[/color]
                    >>
                    >> When there is no garbage, there is nothing to collect, that's how the GC
                    >> works, so in your case there is no garbage because you are still holding
                    >> references to your Data Tables. Please post your code if you want to get
                    >> any
                    >> more help.
                    >>
                    >> Willy.
                    >>
                    >>
                    >>[/color][/color]


                    Comment

                    • Sean Hederman

                      #11
                      Re: garbage collection

                      "Sean Hederman" <email.jpg@codi ngsanity.blogsp ot.com> wrote in message
                      news:d66otk$l3b $1@ctb-nnrp2.saix.net. ..[color=blue]
                      > No, only those variables that are only referenced on the form will be
                      > available for GC, and just because they're available doesn't mean they
                      > will be GC'd.[/color]

                      right away


                      Comment

                      • Nick Malik [Microsoft]

                        #12
                        Re: garbage collection

                        Hi Omer,
                        [color=blue]
                        > i can not send you all code, because it is an ERP packet and it is 50 mb
                        > when zipped. i can send you code samples if you want.
                        > thanks[/color]


                        Typically we ask that you post only the code snippets that you believe are
                        causing your problem or which form a basis for you to believe that the code
                        "should" work. In this case, it would be helpful if you would post the
                        calls that fetch the data, and enough information for us to know where the
                        references are stored for the data (on the stack or on the heap). Also, it
                        would be helpful if you would post the code that occurs when you opened and
                        closed the form.

                        Notes:

                        80Mb is a very large amount of data. Is there any way you can reduce the
                        amount of data that has to be returned by being more explicit in your
                        queries? There is no reasonable way for me to believe that you are actually
                        presenting 80Mb worth of data to the user... so clearly you are returning
                        some data that you don't need.


                        --
                        --- Nick Malik [Microsoft]
                        MCSD, CFPS, Certified Scrummaster
                        http://blogs.msdn.com/nickmalik

                        Disclaimer: Opinions expressed in this forum are my own, and not
                        representative of my employer.
                        I do not answer questions on behalf of my employer. I'm just a
                        programmer helping programmers.
                        --
                        "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
                        news:AD4FD022-4283-4D01-85A9-B376FCF0BD1C@mi crosoft.com...[color=blue]
                        > Hi Willy,
                        > i am closing the form that increases the memory usage. are not the all
                        > variables and controls on the form disposed? after now, does not the GC
                        > collect them?
                        > i can not send you all code, because it is an ERP packet and it is 50 mb
                        > when zipped. i can send you code samples if you want.
                        > thanks
                        > Ömer KUL
                        >
                        > "Willy Denoyette [MVP]":
                        >[color=green]
                        >>
                        >> "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
                        >> news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=darkred]
                        >> > hi,
                        >> > i have a garbage collection problem. i have an application writen by
                        >> > vb.net, i am opening a form and in this form there is a big query. when
                        >> > i
                        >> > open the form, it takes 80 mb memory because of the data table. when i
                        >> > closed
                        >> > the form it is already taking 80 mb memory. where is garbage
                        >> > collection? i
                        >> > am
                        >> > waiting 30 minutes but memory usage is not decreasing. what must i do?
                        >> > thanks,
                        >> > Ã-mer KUL[/color]
                        >>
                        >> When there is no garbage, there is nothing to collect, that's how the GC
                        >> works, so in your case there is no garbage because you are still holding
                        >> references to your Data Tables. Please post your code if you want to get
                        >> any
                        >> more help.
                        >>
                        >> Willy.
                        >>
                        >>
                        >>[/color][/color]


                        Comment

                        • Cor Ligthert

                          #13
                          Re: garbage collection

                          Omar,

                          I found the replys from Willy and Sean very clear. Now that there is a new
                          message added, I will try to explain their messages something more.

                          When you have done in by instance (I see not the code you use therefore in
                          VBNet)

                          In form1
                          Private myDatatable as Datatable
                          dim frm as new Form2
                          frm.datatablefr m2 = myDatatable
                          frm Show

                          And you have in your Form2
                          datatablefrm2 = new datatable.

                          Than the memory used by that datatable will released by the GC as soon as
                          there are no references any more in that datatable and set to nothing in
                          form1 (or that both forms are closed)

                          It is a strange way of coding by the way, however this can give the effect
                          you are talking about.

                          I hope this gives an idea

                          Cor


                          Comment

                          • Ömer KUL

                            #14
                            Re: garbage collection

                            hi Willy,
                            i am using a variable that declared as datatable. i get data from query and
                            set the datatable. after i used the datatable i dispose it but the memory
                            usage is not decreasing. the datatable gets about 80 mb memory...
                            if you give me your e-mail i can send your code part.
                            thanks for your helps.
                            Ömer KUL

                            "Willy Denoyette [MVP]":
                            [color=blue]
                            >
                            > "Ömer KUL" <merKUL@discuss ions.microsoft. com> wrote in message
                            > news:ADC67C47-6680-4E3E-8C50-B30A9DBF03B4@mi crosoft.com...[color=green]
                            > > hi,
                            > > i have a garbage collection problem. i have an application writen by
                            > > vb.net, i am opening a form and in this form there is a big query. when i
                            > > open the form, it takes 80 mb memory because of the data table. when i
                            > > closed
                            > > the form it is already taking 80 mb memory. where is garbage collection? i
                            > > am
                            > > waiting 30 minutes but memory usage is not decreasing. what must i do?
                            > > thanks,
                            > > Ömer KUL[/color]
                            >
                            > When there is no garbage, there is nothing to collect, that's how the GC
                            > works, so in your case there is no garbage because you are still holding
                            > references to your Data Tables. Please post your code if you want to get any
                            > more help.
                            >
                            > Willy.
                            >
                            >
                            >[/color]

                            Comment

                            • Cor Ligthert

                              #15
                              Re: garbage collection

                              Omer,

                              Disposing a datatable does almost nothing, however using clear can help you
                              with the datatable and with the dataset.

                              http://msdn.microsoft.com/library/de...cleartopic.asp

                              When that does not help, you can as quick fix as well try the
                              dataset.Tables[x].Remove;
                              in the closing method of that form.

                              I hope this helps,

                              Cor




                              Comment

                              Working...