JDK-6782260 : Memory leak in CodeBuffer::create_patch_overflow
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs14
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-12-08
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u18Fixed 7Fixed hs15Fixed
Description
libumem reports a number of memory leaks in functions using GrowableArray<int>*CodeBuffer::create_patch_overflow

It appears that there are potential problems: _overflow_arena is never deleted and objects created in the arena is neither.

GrowableArray<int>* CodeBuffer::create_patch_overflow() {
  if (_overflow_arena == NULL) {
    _overflow_arena = new Arena();
  }
  return new (_overflow_arena) GrowableArray<int>(_overflow_arena, 8, 0, 0);
}

Examples:
umem_alloc_24 leak: 7 buffers, 24 bytes each, 168 bytes total
            ADDR          BUFADDR        TIMESTAMP           THREAD
                            CACHE          LASTLOG         CONTENTS
         81fde18          81f9cb8     a921a03bd071                7
                          806a710                0                0
                 libumem.so.1`umem_cache_alloc_debug+0x16c
                 libumem.so.1`umem_cache_alloc+0x15c
                 libumem.so.1`umem_alloc+0x3f
                 libumem.so.1`malloc+0x23
                 libjvm.so`void*os::malloc+0x2e
                 libjvm.so`void*CHeapObj::operator new+0x11
                 libjvm.so`GrowableArray<int>*CodeBuffer::create_patch_overflow+0x2c
                 libjvm.so`void Label::add_patch_at+0x32
                 libjvm.so`void Assembler::jmp+0x79
                 libjvm.so`void LIR_Assembler::emit_opBranch+0x15c
                 libjvm.so`void LIR_OpBranch::emit_code+0x21
                 libjvm.so`void LIR_Assembler::emit_lir_list+0x74
                 libjvm.so`void LIR_Assembler::emit_block+0x5c
                 libjvm.so`void LIR_Assembler::emit_code+0x43
                 libjvm.so`int Compilation::emit_code_body+0xad

umem_alloc_1152 leak: 1 buffer, 1152 bytes
            ADDR          BUFADDR        TIMESTAMP           THREAD
                            CACHE          LASTLOG         CONTENTS
         808c5f0          808ecc0     a9219b97c647                2
                          8075a90                0                0
                 libumem.so.1`umem_cache_alloc_debug+0x16c
                 libumem.so.1`umem_cache_alloc+0x15c
                 libumem.so.1`umem_alloc+0x3f
                 libumem.so.1`malloc+0x23
                 libjvm.so`void*os::malloc+0x2e
                 libjvm.so`void*Chunk::operator new+0x62
                 libjvm.so`Arena::Arena #Nvariant 1+0x13
                 libjvm.so`GrowableArray<int>*CodeBuffer::create_patch_overflow+0x3e
                 libjvm.so`void Label::add_patch_at+0x32
                 libjvm.so`void Assembler::jcc+0xff
                 libjvm.so`void InterpreterMacroAssembler::lock_object+0x673
                 libjvm.so`void InterpreterGenerator::lock_method+0x541
                 libjvm.so`unsigned char*InterpreterGenerator::generate_normal_entry+0x7b6
                 libjvm.so`unsigned char*AbstractInterpreterGenerator::generate_method_entry+0xcc
                 libjvm.so`void TemplateInterpreterGenerator::generate_all+0x1fe7

Comments
EVALUATION The overflow_arena wasn't being deleted which lead to a small leak during code generation. The fix is simply to delete it properly.
05-02-2009

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/5bfdb08ea692
04-02-2009

EVALUATION Having investigated this for Java RTS the CodeBlob destructor should delete _overflow_arena.
22-01-2009