Java Reference
In-Depth Information
cent Linux kernels, the PSS is a refinement of the RSS that removes the data shared by other
programs.
On Windows systems, the equivalent idea is called the working set of an application, which
is what is reported by the task manager.
Minimizing Footprint
To minimize the footprint used by the JVM, limit the amount of memory used by the follow-
ing:
Heap
The heap is the biggest chunk of memory, though surprisingly it may take up only 50% to
60% of the total footprint. Using a smaller maximum heap (or setting the GC tuning
parameters such that the heap never fully expands) limits the program's footprint.
Thread stacks
Thread stacks are quite large, particularly for a 64-bit JVM. See Chapter 9 for ways to
limit the amount of memory consumed by thread stacks.
Code cache
The code cache uses native memory to hold compiled code. As discussed in Chapter 4 ,
this can be tuned (though performance will suffer if all the code cannot be compiled due
to space limitations).
Direct byte buffers
These are discussed in the next section.
Native NIO Buffers
Developers can allocate native memory via JNI calls, but NIO byte buffers will also allocate
native memory if they are created via the allocateDirect() method. Native byte buffers
are quite important from a performance perspective, since they allow native code and Java
code to share data without copying it. The most common example here is buffers that are
used for filesystem and socket operations. Writing data to a native NIO buffer and then send-
ing that data to the channel (e.g., the file or socket) requires no copying of data between the
JVM and the C library used to transmit the data. If a heap byte buffer is used instead, con-
tents of the buffer must be copied by the JVM.
Search WWH ::




Custom Search