Reputation: 1101
Does JLS/JVMS mandate garbage collection? Presumably any sane implementation would have garbage collection, but can insane ones nonetheless qualify as spec-conforming JVMs?
Upvotes: 1
Views: 100
Reputation: 37645
The exact quote from the JLS is:
The Java programming language is a relatively high-level language, in that details of the machine representation are not available through the language. It includes automatic storage management, typically using a garbage collector, to avoid the safety problems of explicit deallocation
Upvotes: 2
Reputation: 159086
Garbage collection is required by the spec.
Quoting the JVM Specification, "Heap":
The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads. The heap is the run-time data area from which memory for all class instances and arrays is allocated.
The heap is created on virtual machine start-up. Heap storage for objects is reclaimed by an automatic storage management system (known as a garbage collector); objects are never explicitly deallocated. The Java Virtual Machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementor's system requirements. The heap may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger heap becomes unnecessary. The memory for the heap does not need to be contiguous.
Upvotes: 1