MY application profiling showing a big Garbage Collection overhead. The profiler does'nt have a drill down into the Garbage Collection. What should I do to reduce this overhead?
I have many short-living arraylists and some long-lived that only die when the application shuts down.
An application that spends 1% of its execution time on garbage collection will loose more than 20% throughput on a 32-processor system. If we increase the GC time to 2%, the overall throughput will drop by another 20%. Such is the impact of suspending 32 executing threads simultaneously!
Simply put, the JVM takes care of freeing up memory when objects are no longer being used. This process is called Garbage Collection (GC). The GC Overhead Limit Exceeded error is one from the java. lang. OutOfMemoryError family, and it's an indication of a resource (memory) exhaustion.
Well basically you should reduce the work for the garbage collector. There a certain 'patterns' which produce a lot of work.
So in your case I guess that you either you've a 'midlife'-crisis with the short lived lists. Or you simple allocate list like mad.
In the first case: Try to make the life-span of the lists shorter. I can't tell you how the solution looks like for your application.
In the second case: Try to avoid allocation so many lists. Maybe you can use proper value-types? Or fixed sized arrays? Or change the structure of the code in such a way that less lists are needed?
Anyway, I would recommend to profile you applicaition and look how much you memory you allocate and how much can be collected in the first generation.
If you have too much garbage collection overhead, reduce your garbage. Try reusing lists ( preallocate and use them, clear them when done).
If you are using ArrayList with value types, try switching to use List<T>
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With