http://www.perlmonks.org?node_id=277740


in reply to Memory leak issue with Embedded Perl

Well, I am by no means a C expert. Actually, I am by no means a Perl expert either. But let it pass. My one guess would be: your Perl code doesn't seem to be using my very much. Variables like %dbm and @list2 aren't lexically scoped with my so they will hang around after you exit the subroutine. Which you probably don't want, and might be causing the memory leak.

And you almost definitely want to put use strict; at the top of your Perl. That will complain about unscoped global variables, and a lot of other things, and enforce good code discipline.
A massive flamewar beneath your chosen depth has not been shown here

Replies are listed 'Best First'.
Re: Re: Memory leak issue with Embedded Perl
by tomw1975 (Sexton) on Jul 24, 2003 at 23:36 UTC
    Thanks I will take a look further into the  my function. The  use strict is also a good suggestion I will add that and see if it helps. This database subroutine only gets called once everytime we go through the process - would the memory still be hanging around even though we have effectively run the script and then terminated it? Or am I working under an incorrect assumption?.... Certainly wouldn't be the first time!!
      If the process truly is exiting then yes, the memory will be freed. This isn't a daemon? And while this does not directly address the issue of leaking memory but a couple other observations.
      1. Your foreach loop seems to contain a useless assignment ($^W=1 would expose that).
      2. There must be a C library for handling DBM files, such as http://www.sleepycat.com

      --
      I'm not belgian but I play one on TV.

        It is a client process running constantly under Tuxedo, which invokes the script via the embedding code. I was under the impression that after it had run the script and exited using the code:
        PUTBACK; TMPS; LEAVE;
        would release the memory associated with perl.

        Anyway I have changed everything over to  use strict and my and the probelm is still occuring.

        I have now taken out the usless assignment - thanks for spotting that one... some old test code hanging around.

        Anything else I should be checking?

        Thanks