Re: Unconventional memory leak problem
Re: Unconventional memory leak problem
- Subject: Re: Unconventional memory leak problem
- From: John Stiles <email@hidden>
- Date: Wed, 6 Sep 2006 10:40:25 -0700
On Sep 6, 2006, at 7:40 AM, Erik Buck wrote:
The only important difference between processes and threads are
that processes have memory protection and threads don’t.
Err, it's not as simple as you claim IMO.
- Threads are trivial to communicate with and block on (semaphore,
mutex, etc). Sending messages to running processes requires Mach
ports and is much more heavyweight.
- Threads can trivially share resources (like a block of memory) with
zero overhead, or at most a mutex. Sharing a block of memory between
two processes requires lots of setup and is expensive (kernel trips,
VM system involvement).
- Threads are extremely lightweight to spawn, and it's not a big deal
to leave them active and blocked waiting for work. Processes are
heavyweight to spawn and they take up enough resources that they
should usually be killed when not running.
- Having multiple little helper apps inside your bundle complicates
the build process and is extremely difficult to debug with the GUI
tools at our disposal today. Building threaded code takes no extra
work. Debugging threaded code isn't exactly easy, but it's certainly
easier.
- Threads work almost the same everywhere. Launching a separate
process is much less portable; when you need to handle things like
sharing a block of memory, you can make it work on other platforms,
but it is likely to need major rethinking.
Threads are confusing for the uninitiated, but with Intel's roadmap,
they are the way of the future. Technology is always evolving; we
have to roll with the punches.
Spawning a separate process can make sense if you have a huge amount
of work to do and you can compartmentalize all the input and output.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden