Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

what are all the possibilites for memory leaks ?

by gube (Parson)
on Oct 10, 2007 at 11:22 UTC ( [id://643923]=perlquestion: print w/replies, xml ) Need Help??

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

Hi,

Our application have many subroutines particularly in one subroutine contains 100 lines and its calling some other packages subroutine which contains more than 200 lines. We are getting memory leakage while calling that routine. We are using module Apache::Leak, and through leak_test we found some more then 200 leakages in that subroutine. There is no circular reference used in the routines it seems. Is there any other way for memory leak other then circular reference? Even i super search in perlmonks and went through some earlier questions they mentioned some modules 'Devel::Leak', 'Test::Memory::Cycle', 'Devel::LeakTrace::Fast'. We cannot able to identify were the problem still. Please give some ideas.

Gubs
  • Comment on what are all the possibilites for memory leaks ?

Replies are listed 'Best First'.
Re: what are all the possibilites for memory leaks ?
by derby (Abbot) on Oct 10, 2007 at 12:05 UTC

    Is there any other way for memory leak other then circular reference

    Yes. Sloppy XS coding can lead to memory leaks.

    -derby
Re: what are all the possibilites for memory leaks ?
by lima1 (Curate) on Oct 10, 2007 at 12:17 UTC
    mod_perl memory leaks are often no "real" memory leaks (I have no experience with Apache::Leak and don't know what kind of memory leaks it reports). Often they are just growing data structures (that become a problem because the program never exits). Are you caching stuff?
Re: what are all the possibilites for memory leaks ?
by adrianh (Chancellor) on Oct 10, 2007 at 12:55 UTC
    Misbehaving XS code and the allocation pattern causing memory fragmentation are two options that spring to mind.
Re: what are all the possibilites for memory leaks ? (repeat)
by tye (Sage) on Oct 10, 2007 at 14:55 UTC

    There will be tons of things that get allocated and not freed when you run new code for the first time in that process. Those are not leaks.

    A good way to narrow down the list of candidates significantly is to check for new things being allocate when a nearly identical request is made via that process for the second time.

    - tye        

Re: what are all the possibilites for memory leaks ?
by sen (Hermit) on Oct 10, 2007 at 12:54 UTC

    Take a look at B::LexInfo. something that might appear to be a leak.
    B::LexInfo

Re: what are all the possibilites for memory leaks ?
by zentara (Archbishop) on Oct 10, 2007 at 14:29 UTC
    have many subroutines particularly in one subroutine contains 100 lines and its calling some other packages

    I don't have much experience with mod_perl or Apache::Leak, but in Tk , Gtk2 gui programming, and commandline programs, objects can leave a non-zero ref count so they don't get destroyed when leaving the subroutine. I usually make a point of always trying to reuse objects. If you read their docs, there usually is a way to clear out all user data and start fresh. Then you can make your objects global and fill them with fresh data on each subroutine call.

    But you don't any code, so we can only guess.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://643923]
Approved by lima1
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-23 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found