United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7152954 G1: Native memory leak during full GCs
JDK-7152954 : G1: Native memory leak during full GCs

Details
Type:
Bug
Submit Date:
2012-03-12
Status:
Resolved
Updated Date:
2012-11-07
Project Name:
JDK
Resolved Date:
2012-03-28
Component:
hotspot
OS:
generic,linux_redhat_5.0
Sub-Component:
gc
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
hs23,7
Fixed Versions:
hs23 (b19)

Related Reports
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
There is a memory leak in the full GC code for G1. This can be seen by running this simple reproducer:

public class SysGC {
	public static void main(String[] args) {
		while (true) {
			System.gc();
		}
	}
}

I run it with this command line:

java -XX:+UseG1GC -Xms16m -Xmx16m -XX:+PrintGC SysGC

Watching the memory footprint for the java process shows that it is constantly using more memory.

The leak comes from SurvRateGroup::stop_adding_regions() which is called from SurvRateGroup::reset(), which in turn is called from G1CollectorPolicy::record_full_collection_end().

The problem with SurvRateGroup::stop_adding_regions() is that it does:

_surv_rate_pred[i] = new TruncatedSeq(10);

in a loop every time it is called. But there is no corresponding call to delete.

Adding a loop to call delete on the previously allocated TruncatedSeq objects is not enough to solve the problem since TruncatedSeq is itself allocating an array without freeing it. Adding a destructor to TruncatedSeq that frees the allocated array solves the issue.

With these two fixes the memory leak seems to go away. Will need to look closer at this to figure out if it is the correct solution. But the current fix confirms that this is indeed the source of the memory leak.

                                    

Comments
EVALUATION

See description.
                                     
2012-03-12
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-gc/hotspot/rev/2c0751569716
                                     
2012-03-14
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/2c0751569716
                                     
2012-03-17
EVALUATION

http://hg.openjdk.java.net/hsx/hsx23/hotspot/rev/b7175879a006
                                     
2012-03-20



Hardware and Software, Engineered to Work Together