[RFR] 8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before

Andrey Zakharov andrey.x.zakharov at oracle.com
Thu Mar 12 16:46:35 UTC 2015


Fixed
webrev: http://cr.openjdk.java.net/~azakharov/8061715/webrev.07/

hs-gc is same:
http://cr.openjdk.java.net/~azakharov/8061715/webrev.06/hs-gc/

Testing on the run: STH queue - 2015-03-12-160604.gtee.auxdata

Thanks.

12.03.2015 16:16, Andrey Zakharov пишет:
> The following code is not correct with regards to the safepoint 
> protocol. You should not perform the ToNativeFromVM transition until 
> you have received the data from the VM. After the transition a GC 
> pause may occur while you are executing in 
> get_auxillary_data_memory_usage and you can get strange results.
>>
>>  328 WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))
>>  329   ResourceMark rm(THREAD);
>>  330   ThreadToNativeFromVM ttn(thread);
>>  331   G1CollectedHeap* g1h = G1CollectedHeap::heap();
>>  332   MemoryUsage mu = g1h->get_auxiliary_data_memory_usage();
>>  333
>>  334   jclass jclass_memory_usage = 
>> env->FindClass("java/lang/management/MemoryUsage");
>>  335   CHECK_JNI_EXCEPTION_(env, NULL);
>>  336   if (jclass_memory_usage == NULL) {
>>
>> I just found out that there is an existing function which creates a 
>> java.lang.management.MemoryUsage from a C++ MemoryUsage object,
>> MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS)
>>
>> Using this you can get rid of the state transition altogether and do 
>> something like:
>>
>> WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))
>>   G1CollectedHeap* g1h = G1CollectedHeap::heap();
>>   MemoryUsage mu = g1h->get_auxiliary_data_memory_usage();
>>   Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
>>   return JNIHandles::make_local(env, h());
>> WB_END
>>
>> This code is almost the same as jmm_GetMemoryPoolUsage in 
>> management.cpp so if it doesn't compile see if I've missed something.
>> I'm pretty sure you don't need a ResourceMark for this function since 
>> it does not allocate any memory in the resource area.
>>
>> /Mikael
>
> Hi, Mikael. Thanks for the tip. It makes things better here. But I'm 
> in doubt about needless of ResourceMark. It exists in mentioned 
> *jmm_GetMemoryPoolUsage:
>
> *JVM_ENTRY(jobject, jmm_GetMemoryPoolUsage(JNIEnv* env, jobject obj))
> *  ResourceMark rm(THREAD);*
>
>   MemoryPool* pool = get_memory_pool_from_jobject(obj, CHECK_NULL);
>   if (pool != NULL) {
>     MemoryUsage usage = pool->get_memory_usage();
>     Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
>     return JNIHandles::make_local(env, h());
>   } else {
>     return NULL;
>   }
> JVM_END*
>
> *

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20150312/aee075f0/attachment.htm>


More information about the hotspot-gc-dev mailing list