diff --git a/lbry/lbry/extras/daemon/Daemon.py b/lbry/lbry/extras/daemon/Daemon.py index fb158e055..cc3e78ff1 100644 --- a/lbry/lbry/extras/daemon/Daemon.py +++ b/lbry/lbry/extras/daemon/Daemon.py @@ -9,6 +9,7 @@ import base58 import random import ecdsa import hashlib +import tracemalloc from urllib.parse import urlencode, quote from typing import Callable, Optional, List from binascii import hexlify, unhexlify @@ -145,6 +146,14 @@ DHT_HAS_CONTACTS = "dht_has_contacts" WALLET_IS_UNLOCKED = "wallet_is_unlocked" +def debug_log_tracemalloc(): + snapshot = tracemalloc.take_snapshot() + top_stats = snapshot.statistics('lineno') + log.debug("[ Top 10 memory usage ]") + for stat in top_stats[:10]: + log.debug(stat) + + class DHTHasContacts(RequiredCondition): name = DHT_HAS_CONTACTS component = DHT_COMPONENT @@ -795,6 +804,8 @@ class Daemon(metaclass=JSONRPCServerType): } } """ + if tracemalloc.is_tracing(): + debug_log_tracemalloc() connection_code = await self.get_connection_status()