On Wed, Jul 14, 2004 at 02:33:49PM +0530, Anish Mehta wrote: > > I am new to POE. I want to what difference it makes in terms of memory > if i use POE instead of fork system call?
The short answer: "It depends." The long answer: POE takes memory, so a single perl process running POE will be larger than a single perl process that does not run it. $additional_memory_used_by_poe = memory($process_with_poe) - memory($parent_process); POE sessions share a single Perl interpreter and POE::Kernel instances. Forked processes require parts of perl to be copied before they begin running (and perhaps others during runtime). Assuming each POE session runs identical code as the child process: memory($session) < memory($child_process) so $memory_saved_per_task = memory($child_process) - memory($session); Assuming that each version of the hypothetical program is running under identical conditions: $poe_memory_use = memory($process_with_poe) + $task_count * memory($session); $fork_memory_use = memory($parent_process) + $task_count * memory($child_process); Therefore POE will use more memory than forking for small values of $task_count. The difference between $poe_memory_use and $fork_memory_use will decrease as $task_count increases, as long as $memory_saved_per_task is positive. Assuming you know all the memory() values above, you can calculate the number of tasks it will take for the POE version to use less memory: $tasks_where_poe_is_smaller = int($additional_memory_used_by_poe / $memory_saved_per_task) + 1; ... unless my math is wrong. -- Rocco Caputo - http://poe.perl.org/