-1

Our app is now not performing well. When we look at perfmonance, we found that the Garbage collection time is 95% of the execution time. But at the same time, our over all memory usage is quite low - we have lots of free memory as indicated by the TaskManager. Why is that? I thought Garbage collector only got busy when memory pressure is high.

Ferdinand.kraft
  • 12,579
  • 10
  • 47
  • 69
user2434400
  • 619
  • 2
  • 7
  • 13

4 Answers4

1

From wiki: Garbage collection

The Garbage Collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program.

If you are allocating memory and failing to deallocate it, the garbage collector comes into picture. Review your code and see to it that the memory you allocate are deallocated as and when they go out of scope.

Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
nj-ath
  • 3,028
  • 2
  • 25
  • 41
  • That's what I am thinking too. It's just not easy to confirm it and locate the spot. Is there a way to enlarge the heap size so I can see that the GC comes around less frequently? - I know this is not a solution, just want to confirm this is the issue. – user2434400 Jul 19 '13 at 18:45
  • You can take a look at this? http://stackoverflow.com/questions/1565388/increase-heap-size-in-java – nj-ath Jul 19 '13 at 18:51
  • Sorry but I think that link is about Java. Mine is a .net app. – user2434400 Jul 19 '13 at 19:10
  • Which is your flavour?(I mean language) – nj-ath Jul 19 '13 at 19:11
  • 1
    @TheJoker In a system like, java, Pythono garbage collector regularly deallocates memory. We can call garbage (explicitly) to perform memory clean up operation( as I know we can do in Java). So your line *`If we are failing to deallocate it`* is crucial point. – Grijesh Chauhan Jul 19 '13 at 19:35
  • Add definition from [Garbage collection](http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) – Grijesh Chauhan Jul 19 '13 at 19:38
  • Yeah, it's one aspect of Garbage collection that is independent of the language or platform – nj-ath Jul 19 '13 at 19:40
  • @GrijeshChauhan Got it! – nj-ath Jul 19 '13 at 19:55
  • I am sorry but you guys have lost me. I think what I am looking for now is a way to enlarge the heap size of a .Net application. Anybody knows how to do that? – user2434400 Jul 19 '13 at 20:12
  • @user2434400 http://stackoverflow.com/questions/301393/can-i-and-do-i-ever-want-to-set-the-maximum-heap-size-in-net?lq=1 – nj-ath Jul 19 '13 at 20:18
  • You should really never explicitly deallocate memory in a garbage collected environment. And even if you do so , the garbage collection rules explicitly prevent you from triggering deallocation or collection. You can only suggest, based on your knowledge of you application's memory dynamics, when would be a good time to collect. – Andyz Smith Jul 19 '13 at 20:41
0

Task manager memory readings can be totally unrelated to the actual memory allocated to a particular virtual machine.

Andyz Smith
  • 698
  • 5
  • 20
0

Probably you are allocating a lot and a lot of objects can be freed. Use Allocation Tracker to track memory allocations and try to allocate as less as possible. You can even allocate everything on the start of the app and later don't allocate anything. This way you don't "seduce" GC to be invoked.

Adam Stelmaszczyk
  • 19,665
  • 4
  • 70
  • 110
0

Dont view task manager.try using any .net related memroy viewer,by that you find find out when and where does garabage collector gets into action.I think it might be because you could have a memory leak,try using some tools to get a better idea,about if there is a leak in you app.

Gowrav
  • 289
  • 1
  • 4
  • 20