[Tutor] Memory problem

hcohen2 hcohen2 at comcast.net
Sun Jan 11 18:19:46 EST 2004


Guillermo Fernandez Castellanos wrote:

> Hi,
>
> First of all, happy year to all :-)
>
> I'm playing with a database. I've done a user interface to this 
> database that do several queries and print the results. The problem is 
> that, this database being important (several hundred of thousands 
> entries), each 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' 
> afterwards. I mean to say to python somehow 'I don't need dbresult 
> anymore, so you can forget it and give me back the memory'. I've tried 
> the gc module, but it does not seem to answer my needs as it works 
> with the number of objects refered, and not with the memory they use.
>
> Thanks,
>
> Guille
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
Guille,

Could you just allow the process to die?  If you have an open connection 
awaiting the appearance of a query - it might be better to have a new 
instance of the process where the return of the result allows the code 
to terminate.

Probably jumping to conclusions.   If the term cursor is significant it 
sounds as if previous results still reside within the cursor, but only 
reporting the last data set.  {A cursor is a special database temporary 
table with ordered data set.  A standard sql table in principle is an 
unordered array of data that is retrieved via its relationship to keys 
(indexes).]

Perhaps you could outline your code showing where "dbresult = 
cursor.execute(query) resides and those much more skilled with python 
than I will clarify the issues.

Herschel




More information about the Tutor mailing list