# Notes on debugging memory leaks in the worker

# apt-get update && apt-get install graphviz
# pip install objgraph

import objgraph
import gc
import random
from aleph.logic.documents import process_documents

objgraph.show_most_common_types()

process_documents(21)
# objgraph.show_most_common_types()

objgraph.show_chain(
    objgraph.find_backref_chain(
        random.choice(objgraph.by_type("_DebugQueryTuple")), objgraph.is_proper_module
    ),
    filename="chain.png",
)  # noqa
gc.collect()

1ea90f6a299acb45fb56c5226d013e958100fc7f
<mask token>

<mask token>
objgraph.show_most_common_types()
process_documents(21)
objgraph.show_chain(objgraph.find_backref_chain(random.choice(objgraph.
    by_type('_DebugQueryTuple')), objgraph.is_proper_module), filename=
    'chain.png')
gc.collect()

import objgraph
import gc
import random
from aleph.logic.documents import process_documents
objgraph.show_most_common_types()
process_documents(21)
objgraph.show_chain(objgraph.find_backref_chain(random.choice(objgraph.
    by_type('_DebugQueryTuple')), objgraph.is_proper_module), filename=
    'chain.png')
gc.collect()

# Notes on debugging memory leaks in the worker

# apt-get update && apt-get install graphviz
# pip install objgraph

import objgraph
import gc
import random
from aleph.logic.documents import process_documents

objgraph.show_most_common_types()

process_documents(21)
# objgraph.show_most_common_types()

objgraph.show_chain(
    objgraph.find_backref_chain(
        random.choice(objgraph.by_type("_DebugQueryTuple")), objgraph.is_proper_module
    ),
    filename="chain.png",
)  # noqa
gc.collect()
