Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object not garbage collected, but contains no gcroots

Tags:

People also ask

How garbage collector removes unused references?

As long as an object is being referenced, the JVM considers it alive. Once an object is no longer referenced and therefore is not reachable by the application code, the garbage collector removes it and reclaims the unused memory.

What is memory garbage collection?

Garbage collection (GC) is a memory recovery feature built into programming languages such as C# and Java. A GC-enabled programming language includes one or more garbage collectors (GC engines) that automatically free up memory space that has been allocated to objects no longer needed by the program.

What is GC root chain?

A local variable in a method that is currently running is considered to be a GC root. The objects referenced by these variables can always be accessed immediately by the method they are declared in, and so they must be kept around. The lifetime of these roots can depend on the way the program was built.


Running into a prickly problem with our web app here. (Asp.net 2.0 Win server 2008)

Our memory usage for the website, grows and grows even though I would expect it to remain at a fairly static level. (We have a small amount of data that gets stored in state).

Wanting to find out what the problem is, I've run a System.GC.Collect(); a few times, taken a memory dump and then loaded this memory dump into WinDbg.

When I do a DumpHeap -Stat I get an inordinately large number on particular type hanging around in memory.

0000064280580b40 713471 79908752 PaymentOption

so, doing a DumpHeap -MT for this type, I get a stack of object references. Picking a random number of these, I do a !gcroot and the command comes back reporting that no references are held to it.

To me, this is exactly when the GC should collect these items, but for some reason they have been left outstanding.

Can anybody offer an explanation as to what might be happening?