From: Dan Kegel <dank@kegel.com>
To: Bernd.Suessmilch@SWAROVSKI.COM,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: re: 2.4.x, mlockall() and pthreads: exceptionally huge memory demands
Date: Mon, 10 Sep 2001 09:59:36 -0700 [thread overview]
Message-ID: <3B9CF178.333B11BE@kegel.com> (raw)
Bernd.Suessmilch@SWAROVSKI.COM wrote:
> I have written an application that uses mlockall() in conjunction
> with posix-threads. I realized that under Kernel 2.4.x (tested
> on 2.4.5-pre1 and 2.4.10-pre6, pentium III, no swap) each thread
> consumes an exceptionally huge amount of memory (about 2MB).
> When I omit the mlockall()-call each thread consumes only about
> 24KB.
> Running the same application under kernel 2.2.x each thread
> consumes about 12KB of memory (with memory locked).
> The attached program illustrates this behavior.
>
> May this be a bug in the mlockall() implementation of 2.4.x and is
> this behavior already known (I found no hint in the archive)?
First - this is a glibc issue, not a kernel issue, I bet.
Second - the new behavior seems allowed by the standard, if not desirable.
Portably speaking, the default stack size for a thread may be quite large.
If you want to consume less memory, either configure the threads to use a
smaller stack with pthread_attr_setstacksize() (I haven't tried this),
or use fewer threads (my favorite approach).
Third - the old behavior is hinted by
http://pauillac.inria.fr/~xleroy/linuxthreads/faq.html
(see below) so perhaps there's a problem with newer glibc's?
- Dan
"E.5: Does LinuxThreads implement pthread_attr_setstacksize() and pthread_attr_setstackaddr()?
These optional functions are provided in recent versions
of LinuxThreads (0.8 and up). Earlier releases did not provide
these optional components of the POSIX standard.
Even if pthread_attr_setstacksize() and pthread_attr_setstackaddr()
are now provided, we still recommend that you do not use them
unless you really have strong reasons for doing so. The default
stack allocation strategy for LinuxThreads is nearly optimal:
stacks start small (4k) and automatically grow on demand to a
fairly large limit (2M).
Moreover, there is no portable way to estimate the stack requirements
of a thread, so setting the stack size yourself makes your program
less reliable and non-portable."
next reply other threads:[~2001-09-10 16:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-10 16:59 Dan Kegel [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-09-10 13:12 2.4.x, mlockall() and pthreads: exceptionally huge memory demands Suessmilch Bernd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B9CF178.333B11BE@kegel.com \
--to=dank@kegel.com \
--cc=Bernd.Suessmilch@SWAROVSKI.COM \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox