[Tutor] Memory problem

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jan 13 04:00:13 EST 2004


> 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?

The other approach is to use less memory in the first place.
Its very unusual to actually need all of the entries in the
datbase at once, so you can tell the cursor to only fetch
the firt N - say 1000. By fetching in batches of 1000 at
a time you should find the memory demands are less. How you
do that will probably depend on your database SQL dialect.

But I don't know how you use the data, maybe you do need all
the records at one go...

Alan G.




More information about the Tutor mailing list