Re: Memory Management
- From: Michael Carman <mjcarman@xxxxxxxxx>
- Date: Sat, 28 Apr 2007 16:59:21 GMT
On 4/27/2007 10:18 PM, Shiraz wrote:
I need to keep a hash of arrays in memory and keep adding things to it and
when the hash has so many things in it that it can cause a perl out of memory
error, i want to prune it. almost like a cache.
So whatever gets flushed from the cache can be recalculated if necessary? You
haven't said how you're filling it, but take a look at the Memoize and
Memoize::Expire modules on CPAN. They *might* do what you want.
If not, my advice is to create a class for your cache with get/set methods. When
it gets too big, start undef'ing entries. Devel::Size will give you accurate
results but be slow. If your array refs are of roughly equal size, you could use
scalar keys on the hash for a faster (but crude) estimate.
-mjc
.
- References:
- Memory Management
- From: Shiraz
- Re: Memory Management
- From: Michael Carman
- Re: Memory Management
- From: Shiraz
- Re: Memory Management
- From: Michael Carman
- Re: Memory Management
- From: Shiraz
- Memory Management
- Prev by Date: Re: Rounding up to the next .5
- Next by Date: Re: Weird error after a configuration change
- Previous by thread: Re: Memory Management
- Next by thread: Memory Management
- Index(es):
Relevant Pages
|