Skip to content

Commit

Permalink
BUG @127 not seeing a memory leak yet
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Nov 21, 2019
1 parent 772e81f commit 95f2587
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/leak_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python

"""
try to provoke the memory leak described
https://github.com/prjemian/spec2nexus/issues/127
file: /Users/hammonds/RSM_DATA/DanielHaskel/Brian-Nick/Fluorescence/lineup
We don't have that one.
"""


import gc
import os
import resource
from spec2nexus.spec import SpecDataFile
import sys
import time

_path = os.path.dirname(__file__)
# TESTFILE = "tests/data/issue119_data.txt"
TESTFILE = os.path.join(_path, "data", "issue119_data.txt")


def get_memory():
return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss

def task():
gc.collect()
before = get_memory()
# gc.set_debug(gc.DEBUG_LEAK)
a = SpecDataFile(TESTFILE)
after = get_memory()
a = None
gc.collect()
final = get_memory()

print(f"{before} {after} {final}")


if __name__ == "__main__":
for i in range(65):
task()
time.sleep(1.0)

0 comments on commit 95f2587

Please sign in to comment.