The JVM's heap (memory area) stores all objects created by an executing Java
program. Objects are created by Java's "new" operator, and memory for new objects is allocated on the heap at run time. Garbage collection is the process of automatically freeing objects that are no longer referenced by the program. This frees the programmer from having to keep track of when to free allocated memory, thereby preventing many potential bugs and headaches.
You can even control the heap size, by issuing command :-
java -Xms32m -Xmx128m MyClassName
This option specifies that 32 MB of memory should be allocated initially for the program to run in, and that up to 128 MB may be allocated if necessary.
Hope it helps !
[ March 29, 2006: Message edited by: Mishra Anshu ]