Re: help with huge memory consumption??
- From: phil-news-nospam@xxxxxxxx
- Date: 4 Mar 2007 20:09:58 GMT
On Sun, 4 Mar 2007 17:58:54 +0000 (UTC) Michel Talon <talon@xxxxxxxxxxxxxxxx> wrote:
| Robert Redelmeier <redelm@xxxxxxxxxxxxxxx> wrote:
|> Rainer Weikusat <rainer.weikusat@xxxxxxxxx> wrote in part:
|> > By definition, threads run in the same address space and each
|> > thread as access to the memory all other threads have access
|> > to, too (assuming it has a pointer pointing into first).
|>
|> If all the memory is marked as shared (with the exception of
|> the stacks) this puts a lot of memory pressure on the heap.
|> A special thread-safe heap-only malloc() may be needed.
|
| But precisely, modern mallocs are programmed to be thread friendly, for
| example by having several arenas for allocating memory, so that several
| threads can allocate concurrently without locking. I think this is the
| case for Linux, Solaris and FreeBSD.
One problem with threads is they are more likely to fragment the memory.
One reason is the concurrency where multiple threads are entangling in
time and interleaving their allocations (if in the same arena). If some
threads go away but others stay, then you have a jumbled collection of
allocated and free spaces in the heap. Compare that to a simple process
that extinguishes the whole virtual memory when it is done. And programs
designed with threads tend to be those that are long lived (a major desk
application) as opposed to really short ones (simple web CGI).
For that and other reasons, I avoid using threads as much as possible.
If it can be done reasonably well without threads, that's how I do it.
--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2007-03-04-1404@xxxxxxxx |
|------------------------------------/-------------------------------------|
.
- Follow-Ups:
- Re: help with huge memory consumption??
- From: David Schwartz
- Re: help with huge memory consumption??
- References:
- help with huge memory consumption??
- From: Dan Miller
- Re: help with huge memory consumption??
- From: Robert Redelmeier
- Re: help with huge memory consumption??
- From: Rainer Weikusat
- Re: help with huge memory consumption??
- From: Robert Redelmeier
- Re: help with huge memory consumption??
- From: Rainer Weikusat
- Re: help with huge memory consumption??
- From: Robert Redelmeier
- Re: help with huge memory consumption??
- From: Rainer Weikusat
- Re: help with huge memory consumption??
- From: Robert Redelmeier
- Re: help with huge memory consumption??
- From: Rainer Weikusat
- Re: help with huge memory consumption??
- From: Robert Redelmeier
- Re: help with huge memory consumption??
- From: Michel Talon
- help with huge memory consumption??
- Prev by Date: Re: HZ in 2.4
- Next by Date: Re: help with huge memory consumption??
- Previous by thread: Re: help with huge memory consumption??
- Next by thread: Re: help with huge memory consumption??
- Index(es):
Relevant Pages
|