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

Native memory tracking shows malloc memory leak where there is none

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 9
    • hs24, hs25, 7u40
    • hotspot
    • None

      Let's start with the reproducer (HelloSpin.java attached):

      java -XX:NativeMemoryTracking=detail HelloSpin
      <wait 10-15 seconds>
      jcmd VM.native_memory baseline
      jcmd HelloSpin GC.heap_dump heap.hprof
      jcmd VM.native_memory detail.diff

      The detail.diff will among other things output an entry for this:

      [0x00007f8f6dfc29dd] HeapDumper::dump(char const*)+0x3d
                                  (malloc=8192KB +8192KB, #1 +1)

      The entry reflects the buffer allocated in heapDumper.cpp:DumpWriter::DumpWriter(const char* path):

      _buffer = (char*)os::malloc(_size, mtInternal);

      where size is io_buffer_size = 8MB.


      However, the _buffer is *not* leaked - it is free:d up immediately when the heap dumper has done its job, so the information displayed is incorrect.

      If I trigger a GC using:

      jcmd HelloSpin GC.run

      The entry goes away, which I assume means that the information is just not updated in a timely fashion.

      This is on Linux/x64. I can reproduce the same problem on both 7u40 and 8.

      ILW=MMM=P3

            Unassigned Unassigned
            mikael Mikael Vidstedt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: