Re: help with huge memory consumption??
- From: "David Schwartz" <davids@xxxxxxxxxxxxx>
- Date: 6 Mar 2007 01:53:02 -0800
On Mar 4, 12:09 pm, phil-news-nos...@xxxxxxxx wrote:
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).
I don't buy this for three reasons:
1) The fragmentation is largely a result of the workload, now how you
handle it. For example, consider an instant messaging server. You
allocate memory for things like clients, messages, file transfers, and
the like when they happen in the outside world. You free them when
they're finished. This will fragment the same whether it's handled by
one thread or one hundred.
2) You claim the increased concurrency causes this fragmentation. If
so, this is not a cost of threads but a cost of increased concurrency.
Nothing about choosing to use threads requires you to increase
concurrency, and you would only do so if the benefits outweighed the
costs. There are many benefits to using threads other than making it
easier to increase concurrency should it be beneficial to do so, for
example, your whole server won't stall should your program experience
some unexpected blocking on file access or a page fault. (In
comparison to a poll-loop server. See point three if you're comparing
it to lots of little processes.)
3) It is very rare that one has a choice to write a long-lived
application or a short-lived one. For applications that are naturally
short-lived, it doesn't matter. For applications that are naturally
long-lived, you don't have a choice. I agree that if you can solve a
problem with short-lived (or intermediate-lived) processes, that is
often preferable to long-lived ones.
DS
.
- Follow-Ups:
- Re: help with huge memory consumption??
- From: phil-news-nospam
- 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
- Re: help with huge memory consumption??
- From: phil-news-nospam
- help with huge memory consumption??
- Prev by Date: Re: help with huge memory consumption??
- Next by Date: Re: Small Fork Problem
- Previous by thread: Re: help with huge memory consumption??
- Next by thread: Re: help with huge memory consumption??
- Index(es):
Relevant Pages
|