* 2.4.x, mlockall() and pthreads: exceptionally huge memory demands
@ 2001-09-10 13:12 Suessmilch Bernd
0 siblings, 0 replies; 2+ messages in thread
From: Suessmilch Bernd @ 2001-09-10 13:12 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org'
Hallo kernel-list,
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)?
Please reply with CC to my personal e-mail address
(Bernd.Suessmilch@swarovski.com) since I did not subscribe to this list.
Kind regards,
Bernd
begin 600 mlockall_musg.c
M+RHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ
M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BH**B!M;&]C:V%L;%]M=7-G
M+F,@+2!D96UO;G-T<F%T97,@;&%R9V4@;65M;W)Y('5S86=E('=H96X@=7-I
M;F<@("`@("`@("`@("H**B`@("`@("`@("`@("`@("`@("!M;&]C:V%L;"@I
M('=I=&@@<'1H<F5A9',@("`@("`@("`@("`@("`@("`@("`@("`@("`@("H*
M*B`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("H**B!C;VUP:6QE<B!O<'1I
M;VYS.B!C8R`M;R!M;&]C:V%L;%]M=7-G(&UL;V-K86QL7VUU<V<N8R`M;'!T
M:')E860@("`@("`@("H**B!U<V%G93H@+B]M;&]C:V%L;%]M=7-G("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("H*
M*B!C;V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!S=')U8W0@<V-H961?<&%R86T@;7ES8VAE9#L@+RH@4V-H
M961U;&EN9R!087)A;65T97(@*B\*"B`@+RH*("`J*B!0<FEO<FET865T('-E
M='IE;@H@("HO"B`@;7ES8VAE9"YS8VAE9%]P<FEO<FET>2`]('-C:&5D7V=E
M=%]P<FEO<FET>5]M87@H4T-(141?1DE&3RD@+2!,3U=?4%))3U))5%D["B`@
M:68H*'-T871E(#T@<V-H961?<V5T<V-H961U;&5R*"`P+"!30TA%1%]&249/
M+"`F;7ES8VAE9"`I(#T]("TQ("DI('L*("`@(&1S=U]P97)R;W(H(G-C:&5D
M7W-E='-C:&5D=6QE<BAA7W1H<F5A9"DB+"!S=&%T92D["B`@("!E>&ET*#$I
M.PH@('T*"B`@<VQE97`H4TQ%15!4*3L*"B`@<'1H<F5A9%]E>&ET*$Y53$PI
$.PI]"@==
`
end
^ permalink raw reply [flat|nested] 2+ messages in thread
* re: 2.4.x, mlockall() and pthreads: exceptionally huge memory demands
@ 2001-09-10 16:59 Dan Kegel
0 siblings, 0 replies; 2+ messages in thread
From: Dan Kegel @ 2001-09-10 16:59 UTC (permalink / raw)
To: Bernd.Suessmilch, linux-kernel@vger.kernel.org
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."
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-09-10 16:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-10 16:59 2.4.x, mlockall() and pthreads: exceptionally huge memory demands Dan Kegel
-- strict thread matches above, loose matches on Subject: below --
2001-09-10 13:12 Suessmilch Bernd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox