Topic
1 reply Latest Post - ‏2009-01-22T19:37:51Z by SystemAdmin
SystemAdmin
SystemAdmin
235 Posts
ACCEPTED ANSWER

Pinned topic instrumenting new

‏2009-01-22T12:24:29Z |
Hi,

we're seeing this issue with a java server that spuriously will allocate very large chunks of memory, only to release it again. This causes the entire server to hang.
We have no idea which piece of code is responsible for the memory allocation. We do not now if is a single allocation ( ie. a large byte array ) or a number of smaller allocations in a row ( in a loop ).

My idea now it to attempt to instrument the code responsible for allocating memory, but I'm a bit blank as where to start.
Is is possible to instrument a piece of code that is called when the new operator is used ? Ie. it seems that I should be able to instrument the default constructor for Object, but how about arrays of primitives ( ie. new byte[] ) ?

And, what would be the best way to cheaply get an estimate of what is allocated ? We're hoping to run this on a busy live system, so I expect that doing too much on every object allocation is a no-no.

I succesfully managed to write a native agent that triggers on JVMTI_EVENT_VM_OBJECT_ALLOC events. This seems fairly straightforward, but unfortunately, these allocations are those specifically NOT done by the new operator.
Is there any way to do this natively, or do I need to do bytecode instrumentations ( docs state that BCI is the way to go )

Thanks for any hints or pointers
/Peter
Updated on 2009-01-22T19:37:51Z at 2009-01-22T19:37:51Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    235 Posts
    ACCEPTED ANSWER

    Re: instrumenting new

    ‏2009-01-22T19:37:51Z  in response to SystemAdmin
    You could use a memory profiler which should so you memory allocations.