LanguageLink, Lifetimes, and Garbage Collection

Remote LanguageLink implementation have, by design, no visibility into Glamorous Toolkit or Lepiter. As such, they cannot know about the lifetimes of values or when to free them.

To mitigate this, LanguageLink remote objects should be tagged with an ID and entered into a LanguageLinkExecutionHandler LanguageLinkHandler subclass: #LanguageLinkExecutionHandler instanceVariableNames: 'commandQueue weakRegistry objectRegistry promiseRegistry mapperFactory' classVariableNames: '' package: 'PharoLink-Execution' using LanguageLinkExecutionHandler>>#registerObject: registerObject: aProxyObject objectRegistry registerObject: aProxyObject. weakRegistry registerObject: aProxyObject finalizer: (LanguageLinkRegistryFinalizer variable: aProxyObject proxyObjectId executionHandler: self) . This will register a finalizer that will call LanguageLinkExecutionHandler>>#removeId: removeId: aRemoteProxyId "Tell the remote server to remove the object from its registry" ^ self subclassResponsibility when the object is finalized, giving the remote implementation a chance to remove the object from its own registry and destroy it or free it for garbage collection.

Note that, to avoid infinite GC loops, the object returned from this remote message should not also be electable for garbage collection itself.