in reply to Re: TCP Socket, Forking, Memory exhaustion
in thread TCP Socket, Forking, Memory exhaustion

it's called copy on write. all the pages used by process are marked this way, whenever one of the process forked try to write to that page a trap is raised and the OS copy the page.


  • Comment on Re^2: TCP Socket, Forking, Memory exhaustion

Replies are listed 'Best First'.
Re^3: TCP Socket, Forking, Memory exhaustion
by BrowserUk (Patriarch) on Nov 07, 2007 at 17:07 UTC

    Yes I know. (On Unix that is. They are just "shared memory segments" on Win32 for example).

    But it's not as beneficial as people think for perl processes, because "compiled" Perl code and Perl program data, are both RW memory to the perl executable. And even read references to perl variables can caused write accesses (and therefore COW) to the memory that holds them.

    But the main point of my post is that ps/top will often, if not always, count the shared, readonly memory (the perl executable's code and RO data) against each process that shares it, which may be giving the OP a false impression of how much memory is consumed by his existing forking solution.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.