Writing trace data to memory buffers

Using memory buffers for holding trace data is an efficient method of running trace. The reason is that no file I/O is performed until a problem is detected or until the buffer content is intentionally stored in a file.

Buffers are allocated on a per-thread principle. This principle removes contention between threads, and prevents trace data for an individual thread from being mixed in with trace data from other threads. For example, if one particular thread is not being dispatched, its trace information is still available when the buffers are dumped or snapped. Use the -Xtrace:buffers=<size> option to control the size of the buffer allocated to each thread.

Note: On some systems, power management affects the timers that trace uses, and might result in misleading information. For reliable timing information, disable power management.
To examine the trace data captured in these memory buffers, you must snap or dump the data, then format the buffers.
Snapping buffers
Under default conditions, a running JVM collects a small amount of trace data in special wraparound buffers. This data is sent to a snap trace file under certain conditions:
  • An uncaught OutOfMemoryError occurs.
  • An operating system signal or exception occurs.
  • The com.ibm.jvm.Trace.snap() Java™ API is called.
  • The JVMRI TraceSnap function is called.

The resulting snap trace file is placed into the current working directory, with a name in the format Snapnnnn.yyyymmdd.hhmmssth.process.trc, where nnnn is a sequence number reset to 0001 at JVM startup, yyyymmdd is the current date, hhmmssth is the current time, and process is the process identifier. This file is in a binary format, and requires the use of the supplied trace formatter so that you can read it.

You can use the -Xdump:snap option to vary the events that cause a snap trace file to be produced.

Extracting buffers from system dump
You can extract the buffers from a system dump core file by using the Dump Viewer.


© Copyright IBM Corporation 2005, 2010. All Rights Reserved.
© Copyright Sun Microsystems, Inc. 1997, 2007, 901 San Antonio Rd., Palo Alto, CA 94303 USA. All rights reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
This information center is powered by Eclipse technology. (http://www.eclipse.org/)