3 ms·
I program in Scala and I wish we'd be able to delete objects manually, and then have the GC clean up the stuff we forget. That'd be awesome; enabling the perfec
by tormeh 12y ago
I program in Scala and I wish we'd be able to delete objects manually, and then have the GC clean up the stuff we forget. That'd be awesome; enabling the perfect fusion of managed and unmanaged memory. In the meantime starting out with huge heaps and setting references to null after use seems like the best we JVM folks can do.
Edited to specify I'm using Scala.
- WalterBright 12y agocore.memory.GC.free(void* p) should do that for you.
- tormeh 12y agoThat's great! Unfortunately I program in Scala, so D-specific advice doesn't really help me. Edited top post.
- bjourne 12y agoWhat happens if another object holds a reference to p? Bad things?
- tormeh 12y agoYeah. Some sort of nullpointerexceptions, I would imagine.
- WalterBright 12y agoYes, bad things, i.e. memory corruption. Manual memory management means it's up to the programmer to get it right.
- the_af 12y agoAre you setting references to null in Scala? :(
- tormeh 12y agoNo, not really. But it's a last resort if you need to make things collectable a bit sooner.