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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access