Skip to content
This repository was archived by the owner on May 2, 2025. It is now read-only.
This repository was archived by the owner on May 2, 2025. It is now read-only.

Memory leak which doesn't create python objects #38

@michwill

Description

@michwill

I've noticed a strange memory leak when trying to index texts from wikipedia. Even when in-memory cache size is small, python client process which creates records, occupies more and more memory. The minimal example which recreates this error and shows that everything looks fine to a memory profiler:

import zerodb
import random
import transaction

from zerodb.models import Model, Text
from pympler import tracker

all_chars = map(chr, range(ord('a'), ord('z') + 1))
get_word = lambda: "".join([random.choice(all_chars) for i in range(1, 8)])
words = [get_word() for i in range(10000)]
get_text = lambda: " ".join([random.choice(words) for i in range(50)])

memory_tracker = tracker.SummaryTracker()


class Doc(Model):
    text = Text()


if __name__ == "__main__":
    username = "root"
    passphrase = "very insecure passphrase - never use it"

    db = zerodb.DB(("localhost", 8001), username=username, password=passphrase)

    for i in range(10000):
        print i
        memory_tracker.print_diff()
        with transaction.manager:
            for j in range(1000):
                doc = Doc(text=get_text())
                db.add(doc)

    db.disconnect()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions