Well, you said "today you can do" as a general advice so I assumed you try to 
show us "how simple it is to do it by hand", not "how easy it is to make sth 
only for internal usage".

About this object being a ref one --- no, please read my comment again. Long 
story short: ref object can be deepCopied, your example cannot.

Besides: no, that's not the same. Why? Because GC finalizes a _pointer_. So it 
will finalize it when it comes to the conclusion it should free the memory for 
a _pointer_. It cares not about how huge memory block on shared heap it 
corresponds to nor think whenever shared heap should be cleaned at all. So you 
could have 90% of the shared heap filled with unused arrays and GC saying "Why 
free anythin? I've still got plenty of space on my thread's heap!" because 
pointers themselves are very small. That's the same I've told you about CUDA 
memory. Simply put: you don't have a GC-ed shared heap. You have an _illusion_ 
of GC-ed shared heap.

Reply via email to