[ZODB-Dev] ZODB Ever-Increasing Memory Usage (even with cache-size-bytes)

Jim Fulton jim at zope.com
Mon May 10 17:01:29 EDT 2010


On Mon, May 10, 2010 at 4:58 PM, Jim Fulton <jim at zope.com> wrote:
...
> The first thing to understand is that options like cache-size and
> cache-size bytes are suggestions, not limits. :)  In particular, they
> are only enforced:
>
> - at transaction boundaries,
>
> - when an application creates a savepoint,
>
> - or when an application invokes garbage collection explicitly via the
>  cacheGC or cacheMinimize methods.
>
> Note that objects that have been monified but not committed won't be
> freed even if the suggestions are exceeded.
>
> The reason that ZODB never frees objects on it's own is that doing so
> could lead to surprising changes to object state and subtle
> bugs. Consider:
>
>    def append(self, item):
>        self._data.append(item) # self._data is just a Python dict
>        # At this point, ZODB doesn't know that self has changed.
>        # If ZODB was willing to free an object whenever it wanted to,
>        # self could be freed here, losing the change to self._data.
>        self._length += 1
>        # Now self is marked as changed, but too late if self was
>        # freed above.

I meant to add that it might be interesting to error or warn when a cache
gets much larger than a suggestion.

Jim

-- 
Jim Fulton


More information about the ZODB-Dev mailing list