5

There was a comment in the question calling-system-gc-explicitly stating that "You can not "force" a generic JVM to do garbage collection because a garbage collector is not actually required by the JVM spec.". My question is if there's such a JVM (and how and where does it get used, if so).

Community
  • 1
  • 1
maaartinus
  • 44,714
  • 32
  • 161
  • 320

2 Answers2

9

For instance, JavaCard's JVM lacked garbage collection until v3.

9000
  • 39,899
  • 9
  • 66
  • 104
  • +1 Excellent reference. isGarbageCollectionSupported() and requestGarbageCollection() were actually introduced in JCVM 2.2. – xelco52 Jan 24 '11 at 20:04
3

Garbage collection (if you ignore weak and soft references) is roughly a simulation of having infinite memory, at least for objects that are unreachable. If an object gets garbage collected in the woods and no code can reach it, did it make a sound?

In practice, JVMs without collectors would be few and far between because in practice memory is limited. About the only places I can think of where a JVM without a GC would be useful would be a research/learning JVM, or a JVM used only for very short-lived processes (where you know you'll destroy the entire JVM before it consumes too much memory).

Laurence Gonsalves
  • 137,896
  • 35
  • 246
  • 299