Java is Garbage Collected

You do not need to explicitly allocate or deallocate memory in Java. Memory is allocated as needed, both on the stack and the heap, and reclaimed by the garbage collector when it is no longer needed. There's no malloc(), free(), or destructor methods.

There are constructors and these do allocate memory on the heap, but this is transparent to the programmer.

Most Java virtual machines use an inefficient, mark and sweep garbage collector.


Previous | Next | Top
Last Modified September 18, 1998
Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu