[Tutor] Memory problem

John P Speno speno at isc.upenn.edu
Tue Jan 13 11:05:02 EST 2004


On Tue, Jan 13, 2004 at 09:00:13AM -0000, Alan Gauld wrote:
> > time I do a query the use of RAM increases very substancially
> (several
> > dozens, sometimes a few undreds of Mb). I do something like:
> > dbresult=cursor.execute(query)
> >
> > I was wondering if there is a way of making that memory 'free'
> 
> I assume you tried the simple del() function to mark it for gc?

Wether or not this actually frees up memory will depend on what OS the
program runs on. On some unix systems, once the memory has been allocated
to a process, the kernel might not try to reclaim it. Either use less
memory to start, or have the process kill itself.

You might be able to use use code like this to check your processes memory
size:

import resource
mem_used = resource.getrusage(resource.RUSAGE_SELF)[2]

Take care.



More information about the Tutor mailing list