in reply to Perl program process
The reason for this is not in the way that Perl is forking, but the way unix itself handles forking. I strongly recommend you get a set of the "Unix Network Programming" books by W. Richard Stevens if you do not already have them and plan on doing a lot of work with forking programs.
The reason that this memory problem is happening is that every time you fork, the two new processes are sharing the same memory pages, but they are sharing them on a copy-on-write fashion. So, the moment one of the two processes tries to update any data stored within a memory page, both processes end up getting their own copy of the entire page. This is a very efficient way of doing things when your children live for a short while and don't do much writing. However, the longer your children live (or the more your children need to write to memory), the less efficient this becomes.
If you have children that need to live for a very long time, you should evaluate your situation and decide wether you are better off in a forking environment, or if you would be better off working with threads.
|
|---|