Request for review: 8020530 Non heap memory size calculated incorrectly

Staffan Larsen staffan.larsen at oracle.com
Tue Aug 20 05:38:50 PDT 2013


On 20 aug 2013, at 14:14, David Holmes <David.Holmes at oracle.com> wrote:

> On 20/08/2013 9:44 PM, Vladimir Kempik wrote:
>> Hi all,
>> 
>> Could I have a couple of reviews for this change?
>> 
>> http://cr.openjdk.java.net/~vkempik/8020530/webrev.00/
>> 
>> Running WebLogic server with 1.8.0 encounters this error:
>> 
>> Caused by: java.lang.IllegalArgumentException: committed = 86482944
>> should be < max = 50331648
>> 
>>         at java.lang.management.MemoryUsage.<init>(MemoryUsage.java:162)
>> 
>>         at sun.management.MemoryImpl.getMemoryUsage0(Native Method)
>> 
>>         at
>> sun.management.MemoryImpl.getNonHeapMemoryUsage(MemoryImpl.java:75)
>> 
>>        ... 37 more
>> 
>> There is a bug in jmm_GetMemoryUsage here -- if a memory region does not
>> define a maximum size, then the total_max is not updated:
>>       if (u.max_size() == (size_t)-1) {
>>         has_undefined_max_size = true;
>>       }
>>       if (!has_undefined_max_size) {
>>         total_max += u.max_size();
>>       }
>> 
>> It started with JDK version 1.8.0-ea-b97.
>> 
>> In src/share/vm/services/management.cpp: jmm_GetMemoryUsage() there is
>> next comment
>> 
>> // if any one of the memory pool has undefined init_size or max_size,
>> // set it to -1
>> 
>> But code doing this is missing, so I've added the code to do exactly
>> what comment says.
> 
> That doesn't make a lot of sense to me. Why would a pool have undefined values?

The Metaspace pool has no max value (unless you specify -XX:MaxMetaspaceSize=), thus undefined.

> If a subset of pools have undefined values why report completely fallacious values of -1?

The javadoc for MemoryUsage says getMax() returns -1 if the maximum memory size is undefined.

> It also isn't clear how this relates to the "committed" value in the failure. What gets reported now?

I guess there can still be a committed value even if we don't have a max value for how much we might commit in the future: used <= committed <= max.

/Staffan

> 
> Thanks,
> David
> 
>> Thanks,
>> Vladimir
>> 



More information about the hotspot-runtime-dev mailing list