DreamT has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm working with a quite complex FastCGI script, where the memory usage gets bigger over time after the Apache process is started (maybe indicating a memory leak?).
Any tips on finding out what is using the memory? I'm aware of that I have to find the memory leak, but I'm looking for good techniques to find it.

Replies are listed 'Best First'.
Re: FastCGI / Apache memory usage?
by flexvault (Monsignor) on Jul 18, 2015 at 13:22 UTC

    DreamT,

    For me, I would need some more information:

    • *nix or MS?
    • Perl version and Apache version( 1 or 2 )?
    • Is it your application that's growing or Apache application that's growing?

    When using "Apache1" with AIX, I used FastCGI very sucessfully, but with Apache2 and Linux, I stopped using FastCGI due to memory problems. My guess, is that both Apache2 and FastCGI save a lot of $variables that I didn't care about. That may or may not be your problem.

    Some things for you to consider (if your using *nix)?

      Verify the hash(s) or array(s) that you clean up is(are) the actual one(s) being used. Print the actual address to a log file and visually verify that the addresses are exactly the same. Sometimes I was clearing a copy rather than the actual variable.

      Verify sizes with 'use Devel::Size qw(total_size);' on suspect variables. I usually check sizes every 3 to 5 seconds with almost no noticeable impact on performance. I think this is more a by product of multiple core servers today.

      Check the real and virtual page usage. A routine I use is here.

    Someone else will have to help with MS servers.

    Good Luck and best Regards...Ed

    "Well done is better than well said." - Benjamin Franklin

    A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.