Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Memory pinning
Last updated at 9:20 am UTC on 31 August 2017
Question:
What is memory pinning and when would I want to use it?

Answer:

Pinning is the ability to tell the garbage collector not to move a specific object. The GC moves objects when it scavenges surviving objects in new space (garbageCollectMost) and when it compacts old space as part of a "full GC" (garbageCollect). If an object is pinned the GC arranges that the object is in old space, using a become if required, and sets the pinned flag bit in the object's header. The compactor then moves only unpinned objects, leaving pinned objects where they are.

Pinning is useful for passing objects to external code, for example to use as a buffer for copying data between Smalltalk and external code. Since pinned objects don't move the external code can simply hold onto the address of the start of the object's body and write into the object, instead of having to track the object via a handle that points to a possibly moving object.


Source: Eliot Miranda, Fri, Aug 25, 2017 at 4:21 PM
To: The general-purpose Squeak developers list


Continue reading with Is it necessary to unpin objects?