Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Garbage collection problem

Garbage collection problem

Scheduled Pinned Locked Moved C#
helpdatabaseoracleperformancetutorial
12 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T t4ure4n

    I have written an application which interacts with the oracle database. There are 2-3 update queries in my program. There is only 1 select statement which executes at the start of the program. The problem with my program is I call the Update queries from a recursive method. I have noticed that the memory consumed by my program keeps increasing and occasionally decreases. But If i minimize the application. The memory used drops down from 44k to a 7-8k and if i maximize it it starts increasing again. I believe that it is a Garbage collection problem. Can any one help me how to force garbage collection to happen each time method returns cheers....

    o O º(`'·.,(`'·., ☆,.·''),.·'')º O o° »·'"`»* *☆ t4ure4n ☆* *«·'"`« °o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

    D Offline
    D Offline
    Dustin Metzgar
    wrote on last edited by
    #2

    You can force garbage collection by calling GC.Collect(), but if the most your application is taking in memory is 44k, I'm not seeing the problem.

    T 1 Reply Last reply
    0
    • D Dustin Metzgar

      You can force garbage collection by calling GC.Collect(), but if the most your application is taking in memory is 44k, I'm not seeing the problem.

      T Offline
      T Offline
      t4ure4n
      wrote on last edited by
      #3

      My apoligies it was 44 M rather than K's this is just the memory it takes if I chop the process into doing 10% of the actual work i want to do. If I perform the operation of on the actual data then for a start it takes 250 M +

      o O º(`'·.,(`'·., ☆,.·''),.·'')º O o° »·'"`»* *☆ t4ure4n ☆* *«·'"`« °o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

      1 Reply Last reply
      0
      • T t4ure4n

        I have written an application which interacts with the oracle database. There are 2-3 update queries in my program. There is only 1 select statement which executes at the start of the program. The problem with my program is I call the Update queries from a recursive method. I have noticed that the memory consumed by my program keeps increasing and occasionally decreases. But If i minimize the application. The memory used drops down from 44k to a 7-8k and if i maximize it it starts increasing again. I believe that it is a Garbage collection problem. Can any one help me how to force garbage collection to happen each time method returns cheers....

        o O º(`'·.,(`'·., ☆,.·''),.·'')º O o° »·'"`»* *☆ t4ure4n ☆* *«·'"`« °o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

        D Offline
        D Offline
        Dan Neely
        wrote on last edited by
        #4

        This isn't a GC issue. The task manager shows much much memory windows has given your program, not how much your program has allocated. Giving an app more memory is an expensive operation so windows gives it in large chunks, and it isn't returned to the OS when you release only a few bytes worth. An app will only give up the excess under limited circumstances. As you've seen minimization is one of them. A second is when it decides it has alot (megabytes) of excess memory that it probably won't need anytime soon. A third is when windows itself realizes it's running low on memory and sends requests to all the running processes to return any that they can.

        -- Rules of thumb should not be taken for the whole hand.

        1 Reply Last reply
        0
        • T t4ure4n

          I have written an application which interacts with the oracle database. There are 2-3 update queries in my program. There is only 1 select statement which executes at the start of the program. The problem with my program is I call the Update queries from a recursive method. I have noticed that the memory consumed by my program keeps increasing and occasionally decreases. But If i minimize the application. The memory used drops down from 44k to a 7-8k and if i maximize it it starts increasing again. I believe that it is a Garbage collection problem. Can any one help me how to force garbage collection to happen each time method returns cheers....

          o O º(`'·.,(`'·., ☆,.·''),.·'')º O o° »·'"`»* *☆ t4ure4n ☆* *«·'"`« °o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #5

          t4urean wrote:

          But If i minimize the application. The memory used drops down from 44k to a 7-8k and if i maximize it it starts increasing again. I believe that it is a Garbage collection problem.

          No it is not. What you are seeing is not the memory your application is using but the memory it has "reserved" for use. That will generally rise as the application is used. When it is minimised the reservation is removed and you see a value closer to the actual amount used. There is nothing wrong with this and your application is most likely functioning properly. If you want to see the actual amount of memory used by your application then you should look at the performance counters for the process. You can access these through Administrative Tools --> Performance.


          Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

          S 1 Reply Last reply
          0
          • C Colin Angus Mackay

            t4urean wrote:

            But If i minimize the application. The memory used drops down from 44k to a 7-8k and if i maximize it it starts increasing again. I believe that it is a Garbage collection problem.

            No it is not. What you are seeing is not the memory your application is using but the memory it has "reserved" for use. That will generally rise as the application is used. When it is minimised the reservation is removed and you see a value closer to the actual amount used. There is nothing wrong with this and your application is most likely functioning properly. If you want to see the actual amount of memory used by your application then you should look at the performance counters for the process. You can access these through Administrative Tools --> Performance.


            Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

            S Offline
            S Offline
            S Senthil Kumar
            wrote on last edited by
            #6

            Do you think an article about how to and how not to measure managed memory (and why) would be useful? I've seen this question asked so many times.

            Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

            C G 2 Replies Last reply
            0
            • S S Senthil Kumar

              Do you think an article about how to and how not to measure managed memory (and why) would be useful? I've seen this question asked so many times.

              Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #7

              S. Senthil Kumar wrote:

              Do you think an article about how to and how not to measure managed memory (and why) would be useful?

              Yes.


              Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

              1 Reply Last reply
              0
              • T t4ure4n

                I have written an application which interacts with the oracle database. There are 2-3 update queries in my program. There is only 1 select statement which executes at the start of the program. The problem with my program is I call the Update queries from a recursive method. I have noticed that the memory consumed by my program keeps increasing and occasionally decreases. But If i minimize the application. The memory used drops down from 44k to a 7-8k and if i maximize it it starts increasing again. I believe that it is a Garbage collection problem. Can any one help me how to force garbage collection to happen each time method returns cheers....

                o O º(`'·.,(`'·., ☆,.·''),.·'')º O o° »·'"`»* *☆ t4ure4n ☆* *«·'"`« °o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

                J Offline
                J Offline
                Judah Gabriel Himango
                wrote on last edited by
                #8

                Don't look at the Memory tab in Task Manager. Instead, look at the Virtual Memory tab, which will give you a better idea of your apps actual working set.

                Tech, life, family, faith: Give me a visit. I'm currently blogging about: Check out this cutie The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

                1 Reply Last reply
                0
                • T t4ure4n

                  I have written an application which interacts with the oracle database. There are 2-3 update queries in my program. There is only 1 select statement which executes at the start of the program. The problem with my program is I call the Update queries from a recursive method. I have noticed that the memory consumed by my program keeps increasing and occasionally decreases. But If i minimize the application. The memory used drops down from 44k to a 7-8k and if i maximize it it starts increasing again. I believe that it is a Garbage collection problem. Can any one help me how to force garbage collection to happen each time method returns cheers....

                  o O º(`'·.,(`'·., ☆,.·''),.·'')º O o° »·'"`»* *☆ t4ure4n ☆* *«·'"`« °o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #9

                  As a footnote to what the others have posted, they've all said that Task Manager show you how much memory your application has been allocated. You might be wondering why that number stays so high if you free up the memory in your app. Well, your application doesn't get it's memory from Windows. It gets memory from the .NET Common Lanugage Runtime, or if your familiar with Java, that refers to a virtual machine. The virtual machine (.NET CLR) aquires blocks of memory from Windows and it's put into a pool called the Managed Heap, actually a couple of different pools, but for simplicity... Your application allocates objects by requesting blocks of memory from the Managed Heap. When these objects aren't needed any more, the memory is freed back to the Managed Heap, not Windows. If the CLR detects that it's not going to need as much memory as it has reserved, it shrinks the Managed Heap and returns that memory back to Windows. I hope that makes it a little easier to understand.

                  Dave Kreskowiak Microsoft MVP - Visual Basic

                  T 1 Reply Last reply
                  0
                  • S S Senthil Kumar

                    Do you think an article about how to and how not to measure managed memory (and why) would be useful? I've seen this question asked so many times.

                    Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

                    G Offline
                    G Offline
                    Guffa
                    wrote on last edited by
                    #10

                    S. Senthil Kumar wrote:

                    o you think an article about how to and how not to measure managed memory (and why) would be useful?

                    Tnere isn't one already?

                    --- Year happy = new Year(2007);

                    S 1 Reply Last reply
                    0
                    • G Guffa

                      S. Senthil Kumar wrote:

                      o you think an article about how to and how not to measure managed memory (and why) would be useful?

                      Tnere isn't one already?

                      --- Year happy = new Year(2007);

                      S Offline
                      S Offline
                      S Senthil Kumar
                      wrote on last edited by
                      #11

                      You're right, I googled for it and found http://msdn.microsoft.com/msdnmag/issues/06/11/CLRInsideOut/default.aspx[^] to be a very thorough article on measuring managed memory.

                      Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro

                      1 Reply Last reply
                      0
                      • D Dave Kreskowiak

                        As a footnote to what the others have posted, they've all said that Task Manager show you how much memory your application has been allocated. You might be wondering why that number stays so high if you free up the memory in your app. Well, your application doesn't get it's memory from Windows. It gets memory from the .NET Common Lanugage Runtime, or if your familiar with Java, that refers to a virtual machine. The virtual machine (.NET CLR) aquires blocks of memory from Windows and it's put into a pool called the Managed Heap, actually a couple of different pools, but for simplicity... Your application allocates objects by requesting blocks of memory from the Managed Heap. When these objects aren't needed any more, the memory is freed back to the Managed Heap, not Windows. If the CLR detects that it's not going to need as much memory as it has reserved, it shrinks the Managed Heap and returns that memory back to Windows. I hope that makes it a little easier to understand.

                        Dave Kreskowiak Microsoft MVP - Visual Basic

                        T Offline
                        T Offline
                        t4ure4n
                        wrote on last edited by
                        #12

                        Thank you very much guys for your replies :cool::cool::cool::cool::cool:

                        o O º(`'·.,(`'·., ☆,.·''),.·'')º O o° »·'"`»* *☆ t4ure4n ☆* *«·'"`« °o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups