http://qs321.pair.com?node_id=1086846


in reply to Design advice: Classic boss/worker program memory consumption

A typical solution is to have the code for the boss and the worker in different executables. When spawning a worker, the boss does a fork, immediately followed by an exec, which is much more memory friendly (on modern Linux/Unix systems, copy-on-write means you need barely extra memory for a fork when neither of the programs modify the data).Then have some kind of IPC to transfer the work unit to the worker.

That way the worker only needs modest amounts of memory, and spawning many of them isn't that expensive. No intermediate process either.