JVM Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.10

Memory Management General Rules

This section describes some general rules used by JVM to manage memory.

Generally, a JVM should be using these rules to manage memory:

  • When a JVM is invoked to run an application, it will ask the operating system for enough memory to run the JVM itself and some free memory for the application to create new objects.
  • When a new object is created, the JVM will allocate memory for that object out of the free memory area.
  • When the free memory area is getting too small, the JVM will ask the operating system for more.
  • When a object is no longer used by the application, it will be destroyed. Its memory will be freed up and merged back to the free memory area.
  • When the free memory area is used up, and there is no more additional memory available from the operating system, the JVM will stop the application and issue the "Out of memory error".

Last update: 2002.

Table of Contents

 About This Book

 Download and Install Java SE 1.6 Update 2

 java.lang.Runtime Class - The JVM Instance

 java.lang.System Class - The Operating System

 ClassLoader Class - Class Loaders

 Class Class - Class Reflections

 Sun's JVM - Java HotSpot VM

 JRockit JVM 7.0 by BEA Systems

 JRockit JVM 8.0 by BEA Systems

Memory Management Rules and Tests

Memory Management General Rules

 Java Exception: java.lang.OutOfMemoryError

 Garbage Collection Process

 Garbage Collection Tests

 Stack Overflow Tests

 Thread Testing Program and Result

 StringBuffer Testing Program and Result

 CDS (Class Data Sharing)

 Micro Benchmark Runner and JVM Options

 Micro Benchmark Tests on "int" Operations

 Micro Benchmark Tests on "long" Operations

 Micro Benchmark Tests in JIT Compilation Mode

 Micro Benchmark Tests on "float" and "double" Operations

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2010
Memory Management General Rules