Counting allocations and object sizes
Peter Libic
libic at dsrg.mff.cuni.cz
Mon Mar 8 07:38:53 PST 2010
Hi,
I'd like to count allocations and object sizes in the VM. And I want it with
lowest possible overhead and perturbation - what leads me to instrumentation
of the VM. After studying sources I thought all allocation should be
intercepted by at least some of the functions mentioned at the bottom of this
mail.
unfortunately, these functions are not sufficient - as tested by following
example - I run the following code with lines tagged with V1 and V2 commented
out, and in both cases Iv got exactly the same counts. That means, the
allocations of TstCls objects are somewhere else and I don't know where :).
I'm running the class like this:
java -XX:+UseParallelGC -verbose:gc -Xint DifferentAllocs
Could someone please write me where should I look for a code that allocates
the objects?
Thanks a lot!
Peter Libic
PS: I'm not quite sure if this is the correct list to ask at, I'm sorry if
this is the case.
============================================
public class DifferentAllocs {
public static void main(String[] args) {
Object[] arr = new Object[1024];
System.out.println("Starting test - ALLOCATE");
test(arr);
System.out.println("Finished test - ALLOCATE");
System.out.println(arr[(new Random()).nextInt(1004)]);
}
public static boolean test(Object[] arr) {
TstCls s, t, u; int i = 0;
s=new TstCls(); t=new TstCls();u=t; /*u=new TstCls();*/
arr[0] = s; arr[1] = t; arr[2] = u;
for (i = 3; i < 1003; i++) {
/*V1*/ arr[i] = new TstCls();
/*V2*/ //arr[i] = u;
}
return s.equals(t) || t.equals(u);
}
}
class TstCls {
public int val1;
public long val2;
public long getV() {return val1+val2;}
@Override public String toString() {return "123425345";}
}
============================================
Intercepted functions:
hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp:
CollectedHeap::post_allocation_setup_common
CollectedHeap::post_allocation_setup_no_klass_install
CollectedHeap::post_allocation_install_obj_klass
CollectedHeap::post_allocation_setup_obj
CollectedHeap::post_allocation_setup_array
CollectedHeap::common_mem_allocate_noinit
CollectedHeap::common_mem_allocate_init
CollectedHeap::common_permanent_mem_allocate_noinit
CollectedHeap::common_permanent_mem_allocate_init
CollectedHeap::allocate_from_tlab
CollectedHeap::init_obj
CollectedHeap::obj_allocate
CollectedHeap::array_allocate
CollectedHeap::large_typearray_allocate
CollectedHeap::permanent_obj_allocate
CollectedHeap::permanent_obj_allocate_no_klass_install
CollectedHeap::permanent_array_allocate
hotspot/src/share/vm/gc_interface/collectedHeap.cpp:
CollectedHeap::allocate_from_tlab_slow
hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp:
ParallelScavengeHeap::mem_allocate
ParallelScavengeHeap::failed_mem_allocate
ParallelScavengeHeap::permanent_mem_allocate
ParallelScavengeHeap::failed_permanent_mem_allocate
ParallelScavengeHeap::allocate_new_tlab
More information about the hotspot-gc-use
mailing list