Re: [pysqlite] unusual memory behavior

Gerhard Häring <[email protected]> Thu, 28 May 2009 09:37:16 +0200
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Gerhard H=E4ring wrote:
> [...]
> Internally, pysqlite has these objects: connections, cursors and
> statements. Connections need to have access to all cursors and
> statements ever created on them. So, the connection object has a *list*
> of weak references for cursors, and a *list* of weak references for
> statements. To keep things simple and efficient, this list is only ever
> appended to. The connection object has also two members
> created_statements and created_cursors that counts the number of
> statement and cursor allocations.
> =

> If created_statements or created_cursors reaches 200, the corresponding
> list is scanned for weak references that have unreachable objects (i. e.
> that were del-ed or removed by the gc). The list is then compacted to
> not contain any NULLs. And the counter member is reset to zero.

Suggestions on how to do this weakref management in a better/simpler way
are of course welcome. But it must work from the Python C API. Basically
it needs use weakref.ref and/or weakref.proxy and lists/dicts, etc.

-- Gerhard