United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6782260 Memory leak in CodeBuffer::create_patch_overflow
JDK-6782260 : Memory leak in CodeBuffer::create_patch_overflow

Details
Type:
Bug
Submit Date:
2008-12-08
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
hs14
Fixed Versions:
hs15 (b02)

Related Reports
Backport:
Backport:

Sub Tasks

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

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/5bfdb08ea692
                                     
2009-02-04
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.
                                     
2009-02-05
EVALUATION

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



Hardware and Software, Engineered to Work Together