Skip to content

Commit

Permalink
Merge 07e9525 into 454ed73
Browse files Browse the repository at this point in the history
  • Loading branch information
swryan committed Oct 23, 2023
2 parents 454ed73 + 07e9525 commit bc1a258
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# .coveragerc to control coverage.py

[run]
disable_warnings = module-not-measured

[report]
omit =
*/tests/*
Expand Down
10 changes: 7 additions & 3 deletions openmdao/core/tests/test_setup_memleak.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import tracemalloc
import gc
import os
import os.path

import openmdao.api as om
Expand All @@ -15,6 +16,8 @@
# 0.2 KiB.
MAX_MEM_DIFF_KB = 200


@unittest.skipIf(os.environ.get('COVERAGE_RUN') == 'true', "Invalid when running with coverage.")
class TestSetupMemLeak(unittest.TestCase):
""" Test for memory leaks when calling setup() multiple times """

Expand All @@ -29,7 +32,6 @@ def test_setup_memleak(self):

for memtest in ITERS:
prob.model = SellarMDA()
snapshots = []

for i in range(memtest):
prob.setup(check=False) # called here causes memory leak
Expand All @@ -41,9 +43,11 @@ def test_setup_memleak(self):
# Force garbage collection now instead of waiting for an
# optimal/arbitrary point since we're tracking memory usage
gc.collect()
snapshots.append(tracemalloc.take_snapshot())
if i == 0:
snapshot0 = tracemalloc.take_snapshot()

top_stats = snapshots[memtest - 1].compare_to(snapshots[0], 'lineno')
snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.compare_to(snapshot0, 'lineno')

total_mem = 0
for stat in top_stats:
Expand Down

0 comments on commit bc1a258

Please sign in to comment.