4 ms·
> Also, you could write a destructor that scrambles the memory location before the object is collected. This assumes you can write destructor at all and that
by duped 4y ago
> Also, you could write a destructor that scrambles the memory location before the object is collected.
This assumes you can write destructor at all and that it's run deterministically.
> though you can probably force that to happen in most GCed languages
I'd actually be surprised if any GC'd language allows this. You normally need to resort to different kinds of tricks for RAII-like behavior.
- im3w1l 4y agoJava has try-with-resources for this. Python has with. Unlike say C++ you do have to indent your code once for every such resource though which can be cumbersome.
- aflag 4y agoPython has `gc.collect` which should work for user created types. Besides, it does have a reference counting GC. So, as long as you don't create cycles, you should be able to force the collection of objects similarly to C++'s shared_ptr.