NETLink`
NETLink`

KeepNETObject

KeepNETObject[object]

causes the specified object(s) not to be released when the current NETBlock ends.

KeepNETObject[object,Manual]

causes the specified object to escape from all enclosing NETBlock expressions, meaning that the object will only be released if you manually call ReleaseNETObject.

Details and Options

  • To use KeepNETObject, you first need to load .NET/Link using Needs["NETLink`"].
  • KeepNETObject allows an object to "escape" from the current NETBlock.
  • It only has an effect if the object was in fact slated to be released by that block.
  • The object is promoted to the "release" list of the next-enclosing NETBlock, if there is one. The object will be released when that block ends (unless KeepNETObject is called again in the outer block).