parent
50755d7db3
commit
53f6fb9876
|
@ -34,6 +34,10 @@ from electrum.plugins import run_hook
|
||||||
from electrum import SimpleConfig, Wallet, WalletStorage
|
from electrum import SimpleConfig, Wallet, WalletStorage
|
||||||
from electrum.paymentrequest import InvoiceStore
|
from electrum.paymentrequest import InvoiceStore
|
||||||
from electrum.contacts import Contacts
|
from electrum.contacts import Contacts
|
||||||
|
from electrum.synchronizer import Synchronizer
|
||||||
|
from electrum.verifier import SPV
|
||||||
|
from electrum.util import DebugMem
|
||||||
|
from electrum.wallet import Abstract_Wallet
|
||||||
from installwizard import InstallWizard
|
from installwizard import InstallWizard
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +68,10 @@ class ElectrumGui:
|
||||||
|
|
||||||
def __init__(self, config, network, plugins):
|
def __init__(self, config, network, plugins):
|
||||||
set_language(config.get('language'))
|
set_language(config.get('language'))
|
||||||
|
# Uncomment this call to verify objects are being properly
|
||||||
|
# GC-ed when windows are closed
|
||||||
|
#network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
|
||||||
|
# ElectrumWindow], interval=5)])
|
||||||
self.network = network
|
self.network = network
|
||||||
self.config = config
|
self.config = config
|
||||||
self.plugins = plugins
|
self.plugins = plugins
|
||||||
|
|
27
lib/util.py
27
lib/util.py
|
@ -1,6 +1,7 @@
|
||||||
import os, sys, re, json
|
import os, sys, re, json
|
||||||
import platform
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
|
from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -45,6 +46,31 @@ class ThreadJob(PrintError):
|
||||||
"""Called periodically from the thread"""
|
"""Called periodically from the thread"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class DebugMem(ThreadJob):
|
||||||
|
'''A handy class for debugging GC memory leaks'''
|
||||||
|
def __init__(self, classes, interval=30):
|
||||||
|
self.next_time = 0
|
||||||
|
self.classes = classes
|
||||||
|
self.interval = interval
|
||||||
|
|
||||||
|
def mem_stats(self):
|
||||||
|
import gc
|
||||||
|
self.print_error("Start memscan")
|
||||||
|
gc.collect()
|
||||||
|
objmap = defaultdict(list)
|
||||||
|
for obj in gc.get_objects():
|
||||||
|
for class_ in self.classes:
|
||||||
|
if isinstance(obj, class_):
|
||||||
|
objmap[class_].append(obj)
|
||||||
|
for class_, objs in objmap.items():
|
||||||
|
self.print_error("%s: %d" % (class_.__name__, len(objs)))
|
||||||
|
self.print_error("Finish memscan")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
if time.time() > self.next_time:
|
||||||
|
self.mem_stats()
|
||||||
|
self.next_time = time.time() + self.interval
|
||||||
|
|
||||||
class DaemonThread(threading.Thread, PrintError):
|
class DaemonThread(threading.Thread, PrintError):
|
||||||
""" daemon thread that terminates cleanly """
|
""" daemon thread that terminates cleanly """
|
||||||
|
|
||||||
|
@ -555,4 +581,3 @@ def check_www_dir(rdir):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
print_error("downloading ", URL)
|
print_error("downloading ", URL)
|
||||||
urllib.urlretrieve(URL, path)
|
urllib.urlretrieve(URL, path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue