General Problems for GC'ed Applications?

Walter Bright newshound at digitalmars.com
Sat Jul 29 01:07:35 PDT 2006


Karen Lanrap wrote:
> Walter Bright wrote:
> 
>> 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.
> 
> I believed that the GC is working somehow that way.

GC's do not "work somehow". They work exactly the way they are 
programmed to.

> Therefore I 
> raised the question as a "general problem". I repeat your words:
>> until there are no more memory blocks to scan.

The only memory blocks scanned are those that have pointers to them. 
Nothing else.

> 
> And this scanning seems to prevent the OS to "page out" the data hold 
> in the first <mem> - <vital> locations in my code---I finally 
> understand that he who told me, that there is no difference bewteen 
> "swapping" and "paging", was wrong.
> 
>> why not pick up the book
> 
> No, thanks. I am not interested in theoretical foundations.

It's not very fruitful for me to try helping you understand GC if you 
aren't interested in doing a little homework. The GC book is a lot more 
than theoretical mumbo-jumbo. It is well worth the effort to pick up and 
look at. I guarantee you'll be able to write much more effective 
programs that use GC if you understand it.

At at a minimum, at least you and I will be using the same language. 
We'll have the same understanding of what "virtual" vs "physical" memory 
is, what "swapping" is, and that "vital" has no meaning for this topic.


> I observed a nasty behaviour of the code I wrote for the contest 
> mentioned in <e9p2qg$18j8$1 at digitaldaemon.com>: heavily paging.
> 
> After detecting and eliminating the memory leak, which lowered the 
> "high water mark" from 2.2GB to 1.8GB (my machine holds 2GB of main 
> memory), that paging was gone.
> 
> I was puzzled why this could happen although a GC is used.

I can't help you when you say you're not interested in learning about GC.



More information about the Digitalmars-d mailing list