in reply to Re^3: Threading vs perl
in thread Threading vs perl
Fork actually copy the memory from one process to another
That depends on the operating system. I don't know of any Unix-like OSes worth using that don't have copy-on-write for forking.
With threads the memory *is* shared
That depends on the threading model. With a shared-everything model, threads can safely share most of everything (except for parts of the execution context). Of course, then you have the potential for deadlocks and weird execution order if you want atomic operations where it matters. With a shared-almost-nothing model, you won't even have the potential memory savings of copy-on-write unless the implementors did a lot of work.
if it did fork, these procesess that eat memory would run in a forked procecss and the memory would be given back to the Operating System.
The OS should reclaim the copied memory pages, yes, but not the shared memory pages.
|
|---|