https://blogs.msdn.microsoft.com/flo...x-and-the-clr/
The garbage collector in Dynamics Ax is very simple: it collects all unreferenced object every
3 seconds (ok, this is a little bit simplified, but it’s pretty much what the GC does).
Consequently you know when the object is collected: about every 3
seconds and if this doesn’t happen you can use the Form SysHeapCheck
to create a dump of the current heap, so you know how many references
are currently held to that object.
Another point that differentiates X++ with C# is the existing of a destructor.
In X++ this destructor is called "finalize()". As described on Msdn:
X++ objects are destructed automatically when there are no more references to them.
You can destruct them explicitly in the following ways:
- Use the finalize method.
- Set the object handle to null.
In X++ it's the finalize method that contains all code that is used to clean up
the instance (releases all objects that are held by this instance, ...).
In C# this is done by the Dispose() method, but I'll describe this later.
An important point is mentioned in the Msdn documentation
(
http://msdn.microsoft.com/en-us/libr...74(AX.10).aspx
https://web.archive.org/web/20130517...8AX.10%29.aspx
https://docs.microsoft.com/en-us/dyn...ectedfrom=MSDN
):
Use finalize carefully. It will destruct an object even if there are references to it.