Question about D, garbage collection and fork()

Jerry Quinn jlquinn at optonline.net
Thu Mar 10 11:44:40 PST 2011


Steven Schveighoffer Wrote:
 
> Do you know what causes the OS to regard that memory as read-only?  Since  
> fork() is a C system call, and D gets its heap memory the same as any  
> other unix process (brk()), I can't see why it wouldn't work.  As long as  
> you do the same thing you do in C, I think it will work.

It's not that the OS considers the memory actually read-only.  It uses copy-on-write so the pages will be shared between the processes until one or the other attempts to write to the page.

So if the garbage collector moves things around, it will cause the pages to be copied and unshared.  So my question is really probably whether the garbage collector will tend to dirty shared pages or not.

Jerry





More information about the Digitalmars-d mailing list