Comment 7 for bug 525808

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

> I suppose this also applies to cases when arguments have an empty list ([]) as a default value doesn't it?

It does.

> Maybe this is the root cause of some not-freeing-memory problems I have seen when doing batch imports into OpenERP. After all, if you pass a BrowseObject into the context of a method with this problem, and never call again that method... the BrowseObject (and all the child objects) will never be freed!

Absolutely not. This is specifically an issue with *mutable default values* of functions and methods. Objects passed by argument (as a browse object would be, even if you pass it through the context) don't have this issue.

Unless, somewhere up your stack, you have a dict as default context argument and you put your Browse object in *that*. In that case, yes the Browse object will stay around forever.

> is it the same as

Off the cuff, I'd say no. This issue tends to generate weird bugs, but is rarely problematic enough to spawn actual memory leaks (in my experience, YMMV). Though if we're really unlucky, it could be happening. Some memory profiling could be in order here, but there are many way to leak memories even in python.