slow runtime

Jonathan M Davis jmdavisprog at gmail.com
Fri Sep 10 17:15:16 PDT 2010


On Friday 10 September 2010 09:44:10 bearophile wrote:
> Andrej Mitrovic:
> > So does that mean the GC doesn't make any pauses, unless it requires more
> > memory from the OS?
> 
> When you ask memory to the GC, it may perform collections, so it performs
> some computations, even if no new memory gets asked to the OS.
> 
> Bye,
> bearophile

Yeah. That's actually generally where GCs end up causing performance problems. 
It's not the fact that they have to grab more memory from the OS or give it back 
but rather the fact that it takes the time to figure out what it can put back in 
its own memory pool. Even worse, in most GCs, it's completely underministic when 
that could happen, so it could end up slowing down your program at critical 
moments. For most apps, that doesn't really matter, and I suspect that D's is 
currently somewhat more deterministic than most since it only runs the GC code 
when new is called as opposed to having its own separate thread, but it's a 
common criticism of GCs. The other would have to do with their memory 
consumption which stems from the fact that they maintain a memory pool and are 
essentially guaranteed to be holding more memory that you would if you freed 
memory immediately when you were done with it. Now, that doesn't necessarily 
mean that they're less efficient - that depends on the GC and can be hotly debated 
- but it does mean that your program will require more memory using a GC than 
not.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list