Skip to main content

Support & downloads  >  

How to identify the Java stack of a thread making an allocation request larger than a certain size

 Technote (troubleshooting)
 
Problem(Abstract)
When you debug Java™ heap fragmentation problems, it can be helpful to find the stack traces of the thread that makes large allocation requests.
 
Resolving the problem
On IBM® 1.3.1 Sovereign SDK Service Release 10 and later (build date of June 5, 2006 and later) and IBM 1.4.2 Sovereign SDK Service Release 4 and later, the environment variable ALLOCATION_THRESHOLD enables a user to identify the Java stack of a thread making an allocation request of larger than the value of this environment variable.


The output is:
    Allocation request for <allocation request> bytes <java stack>

If there is no Java stack, <java stack> becomes No Java Stack.

If 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 testcase:

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=5000000

You 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)

You can set the ALLOCATION_THRESHOLD environment variable on IBM WebSphere® Application Server V5.1.1 and V6.0 with 1.4.2 Service Release 4 and later SDKs.

There are instances when this option will not print the Java stack. It will not print Java stack when JVM considers printing of the Java stack as an unsafe operation and so the Java stack will not be printed for some threads. It is considered to be an limitation of this environment variable.

To learn about setting the ALLOCATION_THRESHOLD environment variable for Application Server versions 5.1.1 and 6.0 click the link from the following list:

WebSphere Application Server V6.0
WebSphere Application Server V5.1.1


WebSphere Application Server V6.0
To set the following environment entries from the Administrative Console in WebSphere Application Server versions 6.0 and 6.0.1, follow these steps:
  1. Open the Administrative Console.
  2. Select Servers > Application Servers > server_name > Java and Process Management > Process Definition > Environment Entries > New.
  3. If you are using Application Server 6.0.2 or greater, navigate in the Administrative Console to: Servers >Application servers > server_name > (Expand Java and Process Management) > Process Definition > Custom Properties > New
  4. Add the following Name/Value pairs:
    Name: ALLOCATION_THRESHOLD
    Value: value
  5. Make sure that you save your changes to the master configuration and restart the Application Server.


WebSphere Application Server V5.1.1
To set the following Environment Entries from the Administrative Console in WebSphere Application Server 5.1.1, follow these steps:
  1. Open the Administrative Console.
  2. Select Servers > Application Servers > server_name > Process Definition > Environment Entries > New.
  3. Add the following Name/Value pairs:
    Name: ALLOCATION_THRESHOLD
    Value: value
  4. Make sure that you save your changes to the master configuration and restart the Application Server.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application ServersRuntimes for Java TechnologyJava SDK
 
 

Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.
Rate this page
Please take a moment to complete this form to help us better serve you.
This material provides me with the information I need.




This material is clear and easy to understand.




Did the information help you to achieve your goal?
What updates, improvements, or related information would you like to see in this document?
Your response will be used to improve our document content. Requests for assistance, if applicable, should be submitted through your normal support channel as we cannot respond from this site.
Input the verification number to submit feedback:
Document information
 Product categories:
 Software
 Application Servers
 Distributed Application & Web Servers
 WebSphere Application Server
 Java SDK
 Operating system(s):
  AIX, Linux, Windows
 Software version:
  5.1.1, 6.0
 Reference #:
  1236523
 IBM Group:
 Software Group
 Modified date:
 2008-05-22

Translate My Page
 
 

Rate this page

Help us improve this page. Your response will be used to improve our document content. Requests for assistance, if applicable, should be submitted through your normal support channel as we cannot respond from this site.