def setUp(self):
        if tracemalloc.is_enabled():
            self.skipTest("tracemalloc must be disabled before the test")

        tracemalloc.clear_filters()
        tracemalloc.add_exclusive_filter(tracemalloc.__file__)
        tracemalloc.set_traceback_limit(1)
        tracemalloc.enable()
 def setUp(self):
     tracemalloc.enable()
def clear_stats():
    tracemalloc.disable()
    tracemalloc.enable()
Esempio n. 4
0
# From http://www.evanjones.ca/memoryallocator/
# Improving Python's Memory Allocator
# Evan Jones

import gc, time

if 1:
    import tracemalloc
    import tracemalloctext

    tracemalloc.enable()
    if 1:
        task = tracemalloctext.DisplayTopTask(10)
        task.display()

        def dump_memory(what):
            print("***** %s *****" % what)
            task.display()
    else:
        def dump_memory(what):
            pass

elif 1:
    import tracemalloc
    import tracemalloctext

    def func():
        size, max_size = tracemalloc.get_traced_memory()
        print("Traced memory: %.1f MB"
              % (size / 1024.0 ** 2))
Esempio n. 5
0
 def setUp(self):
     tracemalloc.enable()
Esempio n. 6
0
def clear_stats():
    tracemalloc.disable()
    tracemalloc.enable()