3 ms·
There is nothing inherently wrong with garbage collection, but it does take your control away. You have to allow for a certain level of "magic" to have elements
by BFatts 10y ago
There is nothing inherently wrong with garbage collection, but it does take your control away. You have to allow for a certain level of "magic" to have elements be freed. This doesn't always work so memory leaks are a bit harder to track down.
In a system where you control the allocations and deallocations, you have finer control but it's easier to forget to deallocate memory no longer in use. This is easier to track down, but a headache none the less.
- kbsletten 10y agoAlso, if we're talking about passing pointers to objects to C code, GC frequently moves objects in memory which will invalidate the pointer. It's not possible to reliably predict when this will happen, so you need extra language support for pinning to do any of the things in this tutorial without accessing invalid memory.