multythreading app memory consumption

Andrew MacIntyre andymac at bullseye.apana.org.au
Tue Oct 24 05:29:24 EDT 2006


Bryan Olson wrote:

> In Python 2.5, each thread will be allocated
> 
>      thread.stack_size()
> 
> bytes of stack address space. Note that address space is
> not physical memory, nor even virtual memory. On modern
> operating systems, the memory gets allocated as needed,
> and 150 threads is not be a problem.

Just a note that [thread|threading].stack_size() returns 0 to indicate
the platform default, and that value will always be returned unless an
explicit value has previously been set.

The Posix thread platforms (those that support programmatic setting of
this parameter) have the best support for sanity checking the requested
size - the value gets checked when actually set, rather than when the
thread creation is attempted.

The platform default thread stack sizes I can recall are:
Windows:  1MB (though this may be affected by linker options)
Linux:    1MB or 8MB depending on threading library and/or distro
FreeBSD:  64kB

-- 
-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia



More information about the Python-list mailing list