Products, Debug manager, and refcounts
Hello list, I've done large amounts of googling on the subject, but I can't find any simple explanation of what the Debug Manager is actually telling me concerning refcounts. It's clear from various sources that, if between REQUESTs one sees a significant jump for a particular type's refcount, there's clearly a problem. (Please feel free to correct me if this is an oversimplification.) What's not clear is what one should normally expect. I make use of some python modules from Zope, generally using the following pattern: [python script] from Products.MyProduct import facademodule try: result = facademodule.doSomething(inputParams) return result finally: del facademodule [facademodule.py] def doSomething(inputParams): import coremodule coreObject = coremodule.CoreClass() try: resultValue = coreObject.doSomething(inputParams) returnValue = {'resultValue':resultValue} del resultValue return returnValue finally: del coreObject del coremodule In the above example, I'm making hyper-vigilant use of 'del' to avoid keeping unneccessary references around. The facademodule's job is simply to send back the results of operations using primitive builtin types (int, list, dictionary) - because a) I don't want my user interface dependent on the coreObjects' structure; b) coremodule should be reusable outside the Zope process; and c) I don't want obsolete object references floating around. After all this, however, I go to the Debug Manager and see that with every REQUEST to a page which makes use of this pattern somewhere, the refcounts for all manner of coremodule's Classes involved in the facademodule's work appear to be incremented by 1. (ex. after a REQUEST using the above pattern I'll see the reference count for Products.MyProduct.coremodule.CoreClass go up by 1.) So, is this normal and expected? Or is it more likely that circular references in my code are causing the instances to be left hanging around? Is there some other approach that's recommended for using my own objects (residing outside of ZODB) and not bloating RAM, however slowly this may happen? Thanks for any clues, Jim
participants (1)
-
Jim Abramson