Another point: if you are pinging people, and not too many, do you actually need to keep running perpetually? Could you just run the thing every 5 minutes on a crontab? This might be simpler than delving into memory management at this stage in the game...