6.6. Managing Object Allocation

The Java virtual machine reclaims unused objects with garbage collection, which is not deterministic and cannot be forced to happen in the Java virtual machine.[1] An object is unused if it is not referenced by anyone. Thus, care must be taken to ensure that references to unused objects are removed so that the garbage collector can recover the memory occupied by these objects.

[1] The gc method on the java.lang.System class can be invoked to run the garbage collector, which makes a best effort to reclaim the memory occupied by unused objects. Its effect is specific to the Java virtual machine implementation.

Because a bundle can be stopped and uninstalled, it is especially important not to leave behind any objects ...

Get Programming Open Service Gateways with Java Embedded Server™ Technology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.