[Tutor] Memory problem

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Jan 12 13:18:42 EST 2004



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


Hi Guillermo,

Are you doing anything else, like storing the results of the result set in
a container?  Do you do things like 'fetchall()' or 'fetchrow()' anywhere?

Also, what database interface are you using?  MySQLdb?



> > 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'.

That dbresult should contain a simple integer.  For SELECT statements, it
should simply be the number of values returned. I don't think the issue is
dbresult itself, but some other use of the 'cursor'.  I think we need to
see more code before we're able to diagnose this.


Talk to you later!




More information about the Tutor mailing list