Skip to content

Possible memory leak using python 2.7, zodb 5 and cacheMinimize #203

@azmeuk

Description

@azmeuk

After upgrading from zodb 4.4.5 to zodb 5.4.0 I experienced an increasing memory consumption in a daemon process I developed. At some point it saturated the whole memory in my server so I tried to understand what was going on, and I managed to reproduce the memory growth with this script:

import transaction
import ZODB
from BTrees.OOBTree import OOBTree

conn = ZODB.DB(None).open()
conn.root()["foobar"] = OOBTree()
transaction.commit()

for i in range(10 ** 7):
    conn.root()["foobar"]
    conn.cacheMinimize()

conn.close()

If you run this script with python 2.7 and zodb 5 the memory consumption of the python process will grow slowly but steadily. The size of the chunks I observed was sometimes 256kB, sometimes 4kB, but I do not really know how to reproduce specifically a growth by 256 or 4kB.

If you comment the line conn.cacheMinimize() or the line conn.root()["foobar"] the memory usage will not grow.

I wrote a proof of concept that generates a memory consumption chart comparison :
Memory usage

I also asked other developers at my company to test how the memory consumption behave on their computers with python 2.7, 3.4, 3.5, 3.6 and zodb 4.4.5 and zodb 5.4.0. The only case that always grows is python 2 and zodb 5. You can see the results here, with the Linux distributions used. We did not test on Mac or Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions