Richard Bucker

Memory Leaks? Really?

Posted at — Nov 20, 2011

I don’t know anything about the specifics on this one… but when the project leader makes a statement like:I have yet to see one non-trivial #perl web application that doesn’t leak memory, wish we had cycle detection like #python does since 2000.Ya gotta wonder whether or not this is a good idea? Is the framework the problem or the language?When I did a search for “memory leak mojolicious” there was mention of some problems going back to version 1.56… but I’m so disgusted with the state of things that I hope he/they make a correction or statement addressing the issues… I also hope it’s not sarcasm.I cannot wait to update this post!!![update #1] “Take this little example, how would you explain what’s going on to a #perl beginner?” [ref: twitter: kraih][update #2] “Perl’s memory management is well-hidden, but is based on reference counts and garbage collection. It also has mortal variables, whose lifetimes are limited to the current context. It is possible to free(1) the memory(2) assigned to variables (including arrays) explicitly, by undef-ing the only reference to them.” (ref:[update #3] since perl uses a reference counter in order to determine what memory to release, this is not much different than Java and a host of other memory managers. It’s easy to cause a leak by having a circular linked list reference and then dropping all of the userspace references to that list. That can easily happen within a function that declares some local memory for a list of some kind and then exits without cleaning up. This is a perfect justification for functional programming style. “no side effects”