Fully featured low overhead profiler for Java EE and Java SE platforms.
Ultimate profiling and monitoring solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

A question about GC Roots

Moderators: Vladimir Kondratyev, Anton Katilin

A question about GC Roots

Postby roger » Tue Jul 14, 2009 10:17 am

Hi,

In my case, I found a lot of objects in my application with a gc root like "System.Object[1020] [GC Handle]". I guess it means the objects is managed by the gc threads from now on, am I right?
My application's memory's keeping grow slowly, in one day, it growed from 200m to 700 m, and the most hot class is String. There're many object with a gc handle root in my application, does it mean there's something wrong with my application? I used PerfMon to monitor my gen x heap size conunter, and gen 1 size changed often. Is that mean the gc threads had to collect gen 1 every 2 seconds? Is that a bad practice?
Thank you very much.

Besg Regards!
roger
 
Posts: 2
Joined: Tue Jul 14, 2009 10:00 am

Re: A question about GC Roots

Postby Vladimir Kondratyev » Tue Jul 14, 2009 12:05 pm

If you see that the number of GC handles is constantly growing in your application, then it's a signal that there is a resource leak in your code. GC handles are used to create handles to managed instances. They act as roots for the garbage collector and can be used to prevent an instance from being collected, to pin a managed instance in memory, or to create a weak reference to an instance. The .NET Framework provides access to GC handles through the System.WeakReference class and the System.InteropServices.GCHandle structure. The runtime also uses GC handles internally to keep track of certain instances, such as managed COM interfaces and static field data.
Vladimir Kondratyev
 
Posts: 1444
Joined: Tue Aug 10, 2004 7:52 pm
Location: Düsseldorf, Germany

Re: A question about GC Roots

Postby roger » Wed Jul 15, 2009 2:27 am

Thank you for the reply.
I compared two snapshots, one used 400m process memory, other used 800m. In the comparison, when I view the statistics in class tree, I found the size of <Objecs by classes> only grow 13%, and the objects grow 9%. Does the 13% of size mean that almost all of grown memory usage is allocated by the unmanaged code? Thank you very much!

Best Regards!
roger
 
Posts: 2
Joined: Tue Jul 14, 2009 10:00 am

Re: A question about GC Roots

Postby Vladimir Kondratyev » Thu Jul 16, 2009 1:55 pm

Yes, memory leak in native code might be a reason. I'd recommend you to read article http://www.yourkit.com/docs/net40/help/memory_leaks.jsp which describes how to find memory leaks.
Vladimir Kondratyev
 
Posts: 1444
Joined: Tue Aug 10, 2004 7:52 pm
Location: Düsseldorf, Germany


Return to .NET Profiler

Who is online

Users browsing this forum: No registered users and 2 guests