in reply to Parallel::ForkManager and possible memory leak

The server hangs

How? in which way?

Calling alarm may leak memory, but not so much and so fast as to hang a server. In the other hand, you may be leaving lots of zombie processes behind.

Try moving the alarm(300) code after the line calling $pm->start, so that it runs on the children.

Also, add some print statements here and there in order to see what your script is doing.

Update: oh, and BTW, you may like to check my module Net::OpenSSH::Parallel!