Help with finding how much memory a variable is using

Kirk S ksaranat at yahoo.com
Sun Mar 4 01:05:38 EST 2001


"Rich Somerfield" <rich_somerfield at tertio.com> writes:

> Hi,
> 
> I am generating a huge, huge list of data (cant think of a decent way to
> reduce the required storage size and have it in a usable form).  Everytime i
> try to keep this list for future derivations I get a memory problem from
> Windows (effectively terminating my python script).
> 
> I presume this is because of the huge list.  Is it possible to find out the
> amount of memory a variable [not a type of the variable, the actual data
> contained within the variable] is taking up?  This variable is local to a
> class and it would appear that it is when i go out of scope of that class
> that the memory error is being issued.  Would I be better making this
> variable global (across all classes)? e.g. would this problem still happen
> if the variable was not just local to 1 class?
> 
> Would a different python datatype solve this problem for me ?
> 
> If I cant handle this amount of data then I will have to think of a way of
> better representing it, this will be unfortunate though as and compression /
> reduction of data will [as far as i can think] vastly reduce performance -
> which is already a concern.
> 
> Regards
> Rich
> 
> 
> 

Hello Rich.  I'm new to python myself but with 75 gig hard drives
available why wouldn't you just settle for a huge swap file on your hard
drive?  If 75 gigs isn't enough I know there is a way (in freebsd/linux at
least) to make multiple drives look like 1 to the OS.  

Then again improving the code for the program is a better first step.
Anyways, good luck.

kirk

-- 
Public key @ http://www.geocities.com/ksaranat/pub-key.txt



More information about the Python-list mailing list