next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Macaulay2Doc > The Macaulay2 language > system facilities > registerFinalizer

registerFinalizer -- register a string that will be displayed when an object is garbage collected



i1 : R = QQ[a..d];
i2 : makeGB = (n) -> (g := gb((ideal vars R)^4); registerFinalizer(g, "gb("|n|")"););
i3 : for i from 1 to 10 do (makeGB i);
i4 : collectGarbage()


This function should mainly be used for debugging. Having a large number of finalizers might degrade the performance of the program. Moreover, registering two or more objects that are members of a circular chain of pointers for finalization will result in a memory leak, with none of the objects in the chain being freed, even if nothing else points to any of them.

See also

For the programmer

The object registerFinalizer is a compiled function.