Skip to content

Commit

Permalink
Use gc for memory usage control instead of psutils (#154)
Browse files Browse the repository at this point in the history
* Use gc for memory usage control instead of psutils

* Relax a check
  • Loading branch information
asvetlov committed Oct 3, 2017
1 parent 6e8f82a commit 498c718
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
1 change: 0 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
ipdb==0.10.3
pytest-sugar==0.9.0
ipython==6.2.0
psutil==5.3.1
1 change: 0 additions & 1 deletion requirements/wheel.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cython==0.27.1
pytest==3.2.2
psutil==5.3.1

16 changes: 3 additions & 13 deletions tests/test_istr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import gc
import sys

import psutil

from multidict._compat import USE_CYTHON

Expand Down Expand Up @@ -69,20 +66,13 @@ def _create_strs():

def test_leak(self):
gc.collect()
p = psutil.Process()
info = p.memory_info()
cnt = len(gc.get_objects())
for _ in range(10000):
self._create_strs()

gc.collect()
info2 = p.memory_info()
rss_diff = info2.rss - info.rss
if sys.platform == 'win32':
# on windows one page could be not returned
# to OS
assert rss_diff <= 4096
else:
assert rss_diff == 0
cnt2 = len(gc.get_objects())
assert abs(cnt - cnt2) < 10 # on PyPy these numbers are not equal


if USE_CYTHON:
Expand Down

0 comments on commit 498c718

Please sign in to comment.