[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] 'my' memory leak?



Is it possible that 'my', as implemented in MacPerl 5.0.7r1m, leaks memory?
As referred to in an earlier message (when I was pleading for help with
trying to track memory usage in MacPerl) I have a relatively simple program
that creates a few objects and then loops over the lines of a large file.
This program was running inexplicably out of memory after a certain number
of iterations, although nothing within the loop was doing anything that I
would expect to allocate heap memory permanently.

Using the 'About this Macintosh' display to study the memory consumed as it
ran confirmed that it was eating memory steadily, but I couldn't see why.
Eventually, I tried replacing all the 'my' calls with 'local'. Result: no
more memory problems. It works just as intended.

>From my reading of the documentation of 'my', I might expect problems if
subroutines were called recursively, and the recursion got out of hand, but
this doesn't seem to be the case - I don't have any recursive calls. It
looks to me as if either 'my' leaks, or there's something special about
using object methods within a 'while' loop. My loop construct is:

        while($parser->next($entry)) {

                # ... do stuff ...

        }

Is MacPerl somehow seeing each call to 'next' as a distinct subroutine instance?

        A