allocationStart1 = AsyncProfiler.getInstance().getAndZeroTotalAllocationsPerThread()
ArrayList aa = new ArrayList();
for (int i = 0; i < 14000; i++) {
aa.add(RandomStringUtils.randomAlphanumeric(100));
}
allocationsEnd1 = AsyncProfiler.getInstance().getAndZeroTotalAllocationsPerThread();
getAndZeroTotalAllocationsPerThread is my adding to AsyncProfiler JNI, approximately returning the memory calculated by
static __thread u64 _total_counter_per_thread;
..
void Profiler::recordSample(void* ucontext, u64 counter, jint event_type, jmethodID event) {
_total_counter_per_thread += counter;
}
This code replaces original Profiler::recordSample method.
Now, since we are talking about TLAB and not just an event that fires on every memory allocation, this memory is not straightforward.
If I make "aa" to be "static" than it's much more predictable since it actually grows and takes more and more TLABs.jmm_GetThreadAllocatedMemory at http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/file/a2c8195708cc/src/share/vm/services/management.cpp#l2209