Is Phobos's Garbage Collector utterly broken? (Phobos vs Tango)

Vladimir Panteleev thecybershadow at gmail.com
Tue Jul 31 23:08:16 PDT 2007


Attached is a simple program which creates 326*100000 objects, and periodically prints out progress. I initially wrote it to try to find a memory leak in Tango's GC (which was actually fixed at some point).

The results of this program are quite interesting.
The Tango version runs in 65-75 seconds on my machine, and never seems to take more than 3MB of RAM.
The Phobos version, however, runs much more poorly - it starts to consume hundreds of MB of RAM immediately, and the fastest run from my tests was 265 seconds. It also behaves quite randomly (memory usage patterns differ each run).
Here's a description of one of the not-so-great runs: it starts off with almost instantly allocating 80 MB of memory, and after a while allocates about 30 more. It runs fine for a while, doing a 1000 in 2-3 seconds - until around 60000 it spontaneously starts eating a lot of memory. It goes on like this until it eats ~340 MB of RAM in all, where it plateaus. At that point, the program slows down to a crawl, doing a 1000 in a few minutes. I've attached a screenshot of the RAM history of this run - I had to stop the program to keep the run's history within view (don't think much would have changed had I left it running, and it could have taken half an hour or more).

What could be the problem of this seemingly random behavior? Is the GC not releasing the memory to the OS on purpose, by estimating that the OS doesn't need it? Or is it a GC bug - if it is, are the warnings Valgrind outputs about Phobos's GC referencing and using undefined memory somehow related to this?

-- 
Best regards,
  Vladimir                          mailto:thecybershadow at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcTest.d
Type: text/x-dsrc
Size: 676 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20070801/deabafd0/attachment.d>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phobos-ram-usage.png
Type: image/png
Size: 32247 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20070801/deabafd0/attachment.png>


More information about the Digitalmars-d mailing list