Skip to content

Commit

Permalink
Merge pull request #162 from romgar/fix_flaky_memory_test
Browse files Browse the repository at this point in the history
Call gc.collect() before measuring memory usage.
  • Loading branch information
LincolnPuzey committed Jan 3, 2021
2 parents ee039fe + cf748e2 commit 9c31f45
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/test_memory_leak.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gc
import resource

import pytest
Expand All @@ -9,8 +10,10 @@

def test_rss_usage():
DirtyMixinModel()
gc.collect()
rss_1 = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
for _ in range(1000):
DirtyMixinModel()
gc.collect()
rss_2 = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
assert rss_2 == rss_1, 'There is a memory leak!'

0 comments on commit 9c31f45

Please sign in to comment.