Details
Description
A DESCRIPTION OF THE PROBLEM :
$ cat /etc/redhat-release
CentOS release 6.5 (Final)
$ ./java -XX:+PrintVMOptions -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+PrintFlagsFinal -version | grep 'PretenureSizeThreshold'
uintx PretenureSizeThreshold = 0 {product}
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
{code}
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
/**
* Created by jigar.joshi on 7/7/14.
*/
public class JVMMemoryInspection {
public static void main(String[] args) throws Exception{
byte[] array = new byte[300*1024*1024];
for(MemoryPoolMXBean memoryPoolMXBean: ManagementFactory.getMemoryPoolMXBeans()){
System.out.println(memoryPoolMXBean.getName());
System.out.println(memoryPoolMXBean.getUsage().getUsed());
}
}
}
{code}
Output:
{code}
$ ./java -Xmx1500m -Xms1500m -Xmn500m -XX:PretenureSizeThreshold=100000000 -XX:+PrintGCDetails JVMMemoryInspection
Code Cache
1101568
Metaspace
2536904
Compressed Class Space
276720
PS Eden Space
338165984
PS Survivor Space
0
PS Old Gen
0
{code}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Since the threshold is set, expected result was allocation in old generation
ACTUAL -
byte[] is allocated in young generation
URL OF FAULTY DOCUMENTATION :
http://www.oracle.com/technetwork/systems/index-156457.html
$ cat /etc/redhat-release
CentOS release 6.5 (Final)
$ ./java -XX:+PrintVMOptions -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+PrintFlagsFinal -version | grep 'PretenureSizeThreshold'
uintx PretenureSizeThreshold = 0 {product}
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
{code}
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
/**
* Created by jigar.joshi on 7/7/14.
*/
public class JVMMemoryInspection {
public static void main(String[] args) throws Exception{
byte[] array = new byte[300*1024*1024];
for(MemoryPoolMXBean memoryPoolMXBean: ManagementFactory.getMemoryPoolMXBeans()){
System.out.println(memoryPoolMXBean.getName());
System.out.println(memoryPoolMXBean.getUsage().getUsed());
}
}
}
{code}
Output:
{code}
$ ./java -Xmx1500m -Xms1500m -Xmn500m -XX:PretenureSizeThreshold=100000000 -XX:+PrintGCDetails JVMMemoryInspection
Code Cache
1101568
Metaspace
2536904
Compressed Class Space
276720
PS Eden Space
338165984
PS Survivor Space
0
PS Old Gen
0
{code}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Since the threshold is set, expected result was allocation in old generation
ACTUAL -
byte[] is allocated in young generation
URL OF FAULTY DOCUMENTATION :
http://www.oracle.com/technetwork/systems/index-156457.html