On Saturday, 14 February 2026 at 18:42:21 UTC, H. S. Teoh wrote:
Basically, when something is allocated on the GC, the GC takes full responsibility for managing its lifetime. User code should not try to intervene. If your object needs to be managed manually, don't allocate it from the GC, use C's malloc() or your own memory allocation scheme. Because of this, class dtors really should not be necessary if you only allocate objects from the GC. They are only necessary when you need to manage resources that are not allocated by the GC, such as OS file handles, memory allocated by C's malloc(), or other such things. The dtor should only take care of cleaning up these external resources, and should not try to do anything related to GC-allocated objects.


T

How does one go about determining if these are GC-allocated objects, or if these are external to the GC?

Reply via email to