UnmanageObject
UnmanageObject[man]
takes ownership of memory wrapped in a "Managed" object, suitable for use in compiled code.
Details

- UnmanageObject is only available in compiled code.
- UnmanageObject has the type signature {"Managed"::[t]}t.
- UnmanageObject[man] mutably invalidates the "Managed" object man. Reusing man after it has been invalidated is a runtime error.
- UnmanageObject can be used when passing an object to external code that will hold a long-term reference to it.
Examples
open allclose allBasic Examples (2)
Compile a function that creates a managed object:
Compile a function that unmanages the object:
Unmanage it, returning the original wrapped value:
Subsequent calls to UnmanageObject fail, as the managed object is invalidated when it is unmanaged:


Managed objects are invalidated by UnmanageObject and are not freed when they go out of scope. Compile functions for creating an unmanaged object:
Scope (1)
Properties & Relations (1)
Managed objects are automatically unwrapped by functions declared with LibraryFunctionDeclaration, so no calls to UnmanageObject are needed:
The managed C array is borrowed and automatically unwrapped before it is passed to the library function:
Text
Wolfram Research (2022), UnmanageObject, Wolfram Language function, https://reference.wolfram.com/language/ref/UnmanageObject.html.
CMS
Wolfram Language. 2022. "UnmanageObject." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/UnmanageObject.html.
APA
Wolfram Language. (2022). UnmanageObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnmanageObject.html