Hi Dan,

On 5/30/06, Dan Pascu <[EMAIL PROTECTED]> wrote:
That is true, but why should the application waste time collecting
garbage on a constant basis when it can be avoided?

Agreed.

> The problem is that
>
>  o = SomeSQLObjectClass(...)
>
> adds an new object to the database (in your case the in
> memory database so memory usage grows).

I think you misread my example. The test script I attached
creates a database object and immediately destroys it with
o.destroySelf() so the net result should be zero because the
object is removed from both the database and the sqlobject
cache when it's destroyed.

My bad.

However, the reason the objects aren't being freed in your example
code is that you tell the garbage collector not to with
gc.set_debug(gc.DEBUG_LEAK) which also sets DEBUG_SAVEALL.

From the gc Python docs:

DEBUG_SAVEALL
   When set, all unreachable objects found will be appended to
garbage rather than being freed. This can be useful for debugging a
leaking program.

DEBUG_LEAK
   The debugging flags necessary for the collector to print
information about a leaking program (equal to DEBUG_COLLECTABLE |
DEBUG_UNCOLLECTABLE | DEBUG_INSTANCES | DEBUG_OBJECTS |
DEBUG_SAVEALL).

If you comment out gc.set_debug(gc.DEBUG_LEAK) the SQLObject objects
should get cleaned up.

Note that I have personally used SQLObject 0.7.0 to insert millions of
objects into a MySQL database and had the garbage collector
automatically work for me, which is why I'm fairly confident that your
issue goes a bit deeper than a simple set of cyclic references.

One issue I have had with SQLObject when inserting large numbers of
objects is that the cache didn't check to see how many items it was
storing when objects were inserted into it, only when they were
fetched. So storing lots of objects without doing any queries can
cause the cache to grow substantially (I don't know if this has been
fixed yet, I know I patched the version I was using). Not sure if this
might be your issue, just letting you know.

Schiavo
Simon


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to