I am running a Perl server with 10 threads. They never get destroyed until the program exits, but this is something I intend to have as much uptime as possible, so that's why this is an issue for me. The threads handle a simple task many times. When I start the server and all the threads are started, I see that I have 288.30 MB free. After a couple iterations through each thread, it reports 285.96 MB free. That isn't so bad..maybe it's just some stack space getting allocated or something during those iterations. But after 15 minutes, the free memory goes down to 248.24 MB! What has happened to my memory?? Now, interestingly, it DOES plateau. It continues to slowly consume but not as quickly as at first. I thought maybe it was my fault so I tried double checking the scope of all my variables and even undefining all of them at the end of the thread loop.
I print out the free space after EVERY iteration of the threads so I can watch it slowly go down. Now what is also interesting is that it doesn't decrease every time. Sometimes the free memory stays the same after iterating.
I am using Perl 5.8.8 built from source on Linux 2.6
Does anybody have any ideas at all or even suggestions as to what may be causing this? I am considering upgrading my Perl to a later version to rule out a memory leak within the Perl core.
UPDATE: Could this be a thread stack size issue? Could I be allocating more memory for the stack than I need. When I create my threads I don't change the setting from the default. Should I? The threads doc says default is generally 16MB depending on system. 16x10 threads=160MB -> which could be the culprit. Thoughts?
UPDATE: I built and installed Perl 5.12.1 and rebuilt the modules and everything. Been running the script for about an hour now and here's what I've noticed. The memory usage is manageable now, but not ideal.
- At the beginning just after spawning my threads