Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7152954

G1: Native memory leak during full GCs

    Details

    • Subcomponent:
      gc
    • Resolved In Build:
      b19
    • CPU:
      generic, x86
    • OS:
      generic, linux_redhat_5.0

      Backports

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  brutisso Bengt Rutisson (Inactive)
                  Reporter:
                  brutisso Bengt Rutisson (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: