Reputation: 47
I'm trying to run a perl script with threads using the detach methode. The application is supposed to run permanent, 24/7. I'm trying to use the this example.
But when i run this example in a longer time period it turns out that there is a constant
increase of memory. How can i avoid this? How can i use the threads->detach
method without the increase of memory?
Upvotes: 1
Views: 176
Reputation: 160
Can you post your code or what you are trying to detach?
you dont need to use pool.pl just to run a detached program.
The simplest you can do is
use threads;
use threads::shared; # if required,
###loop main prog
my $detach_thread = threads->create(
sub {
# DO YOUR STUFF here
return;
}
);
$detach_thread->detach();
Other alternative to consider is running in background (in unix: yourcommand &
).
Upvotes: 0
Reputation: 13792
Another approach may be the use of Parallel::ForkManager module (A simple parallel processing fork manager). I have used it and I get my work done (long running processes without memory leaks).
Upvotes: 1