Chapter 16. Reusing Immortal Memory

Prevent immortal memory leaks with this rule:

Do not allocate an immortal object from code that is executed more than once in the life of the application.

And the corollary:

Try to create all immortal objects in static initializers.

These restrictions rule out actual dynamic creation of immortal objects, but they do not prevent dynamic use of immortal objects. This is the motivation for reuse of immortal objects.

Get Real-Time Java™ Platform Programming 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.