Heap fragmentation due to large objects | Tune heap to accomodate large objects
Identify Java stack that creates large objects
An environment variable ALLOCATION_THRESHOLD enables a user to identify the Java stack of a thread making an allocation request of larger than value of ALLOCATION_THRESHOLDThis is a very heavy trace. Avoid using it on a production environment.
The output is:
Allocation request for <allocation request> bytes <java stack>If there is no Java stack, <java stack> becomes...
Allocation request for <allocation request> bytes No Java StackIf you set this option to a value nnn (bytes), whenever an allocation request is made for an object size >= nnn (bytes), the Java stack trace corresponding to the thread requesting the allocation is printed into the standard error log.
Consider the following test case:
import java.io.*; public class largeobj { static int limit = 20; static int size1 = 1000000; static int size2 =2*size1; public static void main(String []args) throws IOException { for (int index0=0; true; index0++) { if (0 == index0 % 100) System.out.println(index0); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(String.class); oos.close(); Object array1 = null; for(int i1=0; i1<limit; i1++) { System.out.println("" + i1); array1 = new Object[size1] ; for (int i2=0; i2<limit; i2++) { array1 = new Object[size2]; } } array1=null; } } }If you set the option arbitrarily as:
export ALLOCATION_THRESHOLD=5000000You will get messages in the following format during any allocation request larger than or equal to the threshold value:
Allocation request for 8000016 bytes at largeobj.main(largeobj.java:18)To set ALLOCATION_THRESHOLD, navigate in the administrative console to...
Application servers | server_name | Java and Process Management | Process Definition | Custom PropertiesAdd the following name/value pairs:
Namexxxx ALLOCATION_THRESHOLD Valuexxxx value Save your changes to the master configuration and restart the application server.