Re: help with huge memory consumption??



Robert Redelmeier <redelm@xxxxxxxxxxxxxxx> writes:
Rainer Weikusat <rainer.weikusat@xxxxxxxxx> wrote in part:
The original article talked about stacks allocated for thread
within a process and I did, too. So, how can stack pages allocated
for threads withing a single process be shared with whom?

They can RO -- so long as no one writes to them.

The stack is the area of memory that is constantly written to, because
it contains storage for local variables of subroutines and is used to
temporarily save register values and subroutine return addresses.

[...]

AFAIK, a thread has the spawner's stack until one of them writes
to it, then the page gets copied (CoW). You can make private
stacks, but it's more work: they have to be specially allocated
and mapped with all the usual overflow worries.

Each newly created (NPTL) thread has an 8M area (by default) mapped as its
private stack with an adjacent 4K guard page. That's what the original
poster kind of complained about and by actually looking at a
multi-threaded Linux process, you could very easily have determined
that by yourself (eg by using pmap -d).

Your idea about 'copy on write' stacks is grotesque: The stack
contains the call chain of the thread that uses it for running, ie
activation records of currently active subroutines, and the newly
created thread does not share any of this state with its creator (and
could not meaningfully share it anyhow).
.



Relevant Pages

  • Re: Help me with redback and unibasic
    ... That problem is as old as subroutines. ... You need to keep track of the stack ... XLr8 the tool for RedBack ... need to abort from one of those subroutines and get back to ASP. ...
    (comp.databases.pick)
  • Re: No machine stack and C
    ... sensitive computing souls...whence the stack, ... Taylorism created the infamous "lines of code ... inimical to "Taylorists" because a tree structure of subroutines ...
    (comp.lang.c)
  • Re: Paper on PL/I
    ... a hardware stack for subroutine calling and returning. ... Turing and his team developed software (subroutines) for a variety of tasks ... stack machines of the Burroughs line and of the English Electric KDF9, ... recognizing his occupation, complaints about languages (Algol, FORTRAN, ...
    (comp.lang.pl1)
  • Re: Classes, Properties, and structures
    ... > also the ability to add function, subroutines, events and such that apply ... A ValueType which contains only ValueType's for fields will be created ... entirely on the stack and won't generate any garbage. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: help with huge memory consumption??
    ... for threads withing a single process be shared with whom? ... The memory isn't shared in any back-and-forth sense ... a thread has the spawner's stack until one of them writes ...
    (comp.os.linux.development.system)