[Home]Perl Memory Usage

Contents | (Visit Preferences to set your user name.) | Related To Perl Memory Usage | RecentChanges | Preferences | Index | Login | Logout

Featured: Featured Stories | Picture Gallery

Physical Sciences | Planar Array
Google
Chat11.com Web Bible11.com MyBibleCenter.com
Cover of ISBN 0834003465 Cover of ISBN 0785201688
Cover of ISBN 081297476X The Bush Survival Guide - 250 Ways to Make It Through The NExt Four Years Without Misunderestimating the Dangers Ahead, and Other Subliminable Stategeries
Links:

What To Do If You Suspect A Perl Memory Leak

And some general advice about structuring a program to avoid memory leaks in Perl

Subjects > Computers > Software > Computer Programming > Perl?Create

I run into this problem a lot also.

Perl is known to use memory at a great rate. I saw some posts that said figure out how much memory a reasonable program would use, and then multiply by three to estimate Perl's memory usage. Amazingly there is very little advice on the net about memory efficiency in perl. It is astounding to me that there is not some kind of function to tell how much total memory the perl interpreter has allocated. How difficult could it be to keep a counter that is added to when memory is allocated, and substracted from when memory is freed? Even better would be deeper functions to let you see the reference count of an object, or maybe even walk the object chain (if there is one) and show object still remaining in memory.

One thing I've noticed is that when deleting a hash element that contains a hash, it seems like the inner hash does not get freed. And I've discovered it appears to help to walk through the elements of a hash deleting each one in turn, and to make nested walk throughs if the has contains nested hashes of hashes.

Also, it is probably better to use delete on each element, than to use undef. Using undef just sets that key of the hash to be "undef", deleting it deletes the item and the key from the hash. However, I am not sure if it is a good idea to be doing a delete on declared elements within a pseudohash.

Another possible work around is to structure your program so it does small discrete units of work, then if you have a lots of separate tasks for it to do, start a fresh copy of the program for each task. For example, a perl program operating on records in an address book might restart after every 100 records are processed. This is a drastic solution to the problem of leaked memory, and it's practicality depends on the amount of information you need to maintain between the execution of discrete tasks.

See also Garnet's Interesting Articles


Check out [Facts About Trees]


Search for books about:

Computer Programming, Computers, Perl, Software

Search The Net:
Computers
Software
Computer Programming
Perl

Contents | (Visit Preferences to set your user name.) | Related To Perl Memory Usage | RecentChanges | Preferences | Index | Login | Logout
Edit this chat11.com page | View other versions
Last edited March 21, 2008 7:30 pm (diff)
Search:
Sign up for PayPal and start accepting credit card payments
instantly.
Bobsgear - Get A Free Enterrpise Wiki Space!
Review: The Bobsgear Project was started to develop a variety of Confluence plugins. This installation of the Confluence Enterprise wiki includes flexible attachments, many Confluence plugins, personal blogs, interesting articles, and more. Bobsgear already has spaces related to politics, art and photography wiki, technical issues wiki, ediscovery wiki, health, Christian theology and Sabbath School wiki, the bible, book reviews, and quotations. Bobsgear allows free signup, and invites anyone to create a free hosted Confluence wiki space.


NEW USERS CLICK HERE! for a quick introduction to Wiki.

 

 Interested in Risk Of Travelling To Space Worth The Benefit?
5872 total hits since 9/2007
Recently accessed pages: African American Avatar012004 Case Of Mistaken Nice Guy Copy Protection Dentistry, Bleeding Gums, And Toothpicks Dogs - Tibetan Spaniel Durian Fruit Deaths Handbook For Lent - The Tradition Of The Stations Of The Cross HowToImportFromOtherWiki How To Change The Folder Viewing Default In Windows XP From Icons To List Modeling Clay Overeating Simple Food Is Harmful Phil Henry Show Notes For April 14, 2004 Stretching FAQ 1.2.1 - How Muscles Contract

Elapsed:0