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

Re: [MacPerl] Associative array memory hogging



I had a script that was using a 20M associative array
in memory;  i switched to DBM files and the program now
runs in under 3 Meg, with everything.   I haven't used DBM 
undewr MacPerl, but it looks like what you're looking
for here.

Just as a side note, the memory usage below is the sort you get
if you do something 'leaky' with your arrays.  If there is 
the product of some eval or some pattern matching around, perl
will cache it, and you'll see the memory size grow even though
the number of entries doesn't.  (I'm referring to the last
paragraph below).  This is discussed under 'Efficiency' in the
camel book.  So i was doing the 'bad' things with my arrays
and i'd see the 20M double... then triple....  I would be nice
to be able to 'force a garbage collection'.

kevin
lenzo@cs.cmu.edu


> >I have written a script to load a large associative array--a 5 x ~18,000
> >table (each entry is less than 5 bytes, using one of the columns as a key).
> >The problem is that although the table itself uses about 350 K of disk
> >space, to load it into memory I need to allocate over 6 MB of memory to
> >MacPerl. (I have also written another script using s/// to perform the same
> >search from the disk, but this is very very slow.)
> 
> I've also found that associative arrays take up a huge amount of memory.
> 750 entries of about 100 bytes each and a 50 byte key requires over 22
> megabytes of memory.
> 
> Craig Anderson