multythreading app memory consumption

Andrew MacIntyre andymac at
Tue Oct 24 11:29:24 CEST 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  (pref) | Snail: PO Box 370
        andymac at             (alt) |        Belconnen ACT 2616
Web:               |        Australia

More information about the Python-list mailing list