FG:

But I also had to write s.length = 0 instead of either s = [] or s = "".dup.

Also try:
s = null;


I wonder why GC didn't reclaim the regions previously used by the array before it an empty one was assigned to s.

Some explanations are in the article I've linked previously. Most of the other part of the answer comes from the fact that currently the D GC is not a precise GC. So randomly inbound pointers keep large memory chunks alive.


Now, this delete looks like Python's kind of GC cheating. :)
Personally, I don't have anything against it, but is it a valid practice?

delete is deprecated in D. There is destroy(), and a replacement for delete in the memory/GC module.

Bye,
bearophile

Reply via email to