General Problems for GC'ed Applications?

Walter Bright newshound at digitalmars.com
Fri Jul 28 22:34:53 PDT 2006


Karen Lanrap wrote:
> Walter Bright wrote:
> 
>> 5) When you use -lg, what the code appears to do is allocate new
>> memory blocks. But since the old blocks are *still actively
>> pointed to*, they won't be released by the GC.
> 
> They are not *actively pointed to* from any location and the GC is 
> releasing them. Otherwise the program would acquire more and more 
> memory as one can see with the "-l" option which enables only the 
> leak but not the GC.
> 
> There are strong connected components(scc) of about 1MB size.
> The only pointer to them is assigned to with a new scc, thereby 
> insulating this scc to garbage,

"insulating this scc to garbage" ??

> ready to be collected in case they 
> are not deleted manually.
> 
> If they are not deleted manualy and the GC is enabled and collects 
> them, then the OS does not swap out the other data anymore. Why?

The statistics you mentioned do not contain any swapping information. 
Perhaps I'm not understanding what you mean by swapping.

> That is exactly the scheme that was said not to happen.

I'm having a very hard time understanding you.

> In case of "<exeName> <mem> 100" there are only 100MB of data touched 
> but the OS holds all <mem> data. That is why I believe the GC touches 
> all of the <mem> data in search for blocks to collect.

The GC scans the static data, the registers, and the stack for pointers. 
Any pointers in that to GC allocated data is called the 'root set'. Any 
GC allocated data that is pointed to by the 'root set' is also scanned 
for pointers to GC allocated data, recursively, until there are no more 
memory blocks to scan. Any GC allocated data that is not so pointed to 
is *not* scanned, and is added to the available pool of memory. (They 
are *not* returned to the operating system, thus the 'high water mark' I 
mentioned previously.)

It does not scan all the memory.

This is not a matter of belief, you can check the code yourself (it 
comes with Phobos), and you can turn on various logging features of it. 
I suggest doing that, I think you'll find it very interesting.


> If I am wrong, why is the OS disabled to swap out all untouched data, 
> as soon as the GC is enabled?  

I think you have a very different idea of what the word "swapping" means 
in regards to virtual memory and GC than I do. For one thing, nothing at 
all in your program disables OS swapping. I don't think it is even 
possible to disable it - it's a very low level service.

You're obviously very interested in GC - why not pick up the book on it 
referenced in www.digitalmars.com/bibilography.html? It's a very good read.



More information about the Digitalmars-d mailing list