Using Shared Scoped Memory

Scopes can be shared among threads either by inheritance or by the same scopes being entered in multiple threads. This engages the reference-counting aspect of scoped memory.

Objects in a scoped memory are not freed until after the reference count goes to zero.

Objects in scoped memory are not eligible to be freed until the reference count on the scope goes to zero. This sounds simple, but threads are inherently asynchronous. The usage pattern of shared scopes can easily become complicated, and unless you check the reference of memory areas by using the getReferenceCount method on ScopedMemory, the clue that the reference count did not go to zero when you expected is that allocations from the memory area will start ...

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.