Tuesday, August 10, 2010

Java memory usage

Tips and tricks I learned on JVM

  • Stack
Java puts the local variables on the stack.
Each thread maintains a stack of its own, so there is no concurrent access problem.

  • Heap
Java puts the objects and member variables on heap.
Threads share a single heap space, concurrent access occurs.

Eclipse memory analyzer tool (MAT) is a good memory profiling tool, it's an open source project. And here is a good tutorial on it.