File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
bindings/pyroot/pythonizations/test Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -191,3 +191,6 @@ endif()
191191
192192# TComplex pythonizations
193193ROOT_ADD_PYUNITTEST(pyroot_tcomplex tcomplex_operators.py)
194+
195+ # Tests with memory usage
196+ ROOT_ADD_PYUNITTEST(pyroot_memory memory.py)
Original file line number Diff line number Diff line change 1+ import gc
2+ import ROOT
3+ import unittest
4+
5+
6+ class MemoryStlString (unittest .TestCase ):
7+
8+ def test_15703 (self ):
9+ """Regression test for https://github.com/root-project/root/issues/15703"""
10+
11+ ROOT .gInterpreter .Declare ("""
12+ #include <string>
13+ class foo {
14+ public:
15+ const std::string leak (std::size_t size) const {
16+ std::string result;
17+ result.reserve(size);
18+ return result;
19+ }
20+ };
21+
22+ auto get_rss_MB() {
23+ ProcInfo_t info;
24+ gSystem->GetProcInfo(&info);
25+ return info.fMemResident;
26+ }
27+ """ )
28+ obj = ROOT .foo ()
29+ for _ in range (1000000 ):
30+ __ = obj .leak (2048 )
31+
32+ gc .collect ()
33+
34+ before = ROOT .get_rss_MB ()
35+
36+ for _ in range (1000000 ):
37+ __ = obj .leak (2048 )
38+
39+ gc .collect ()
40+ after = ROOT .get_rss_MB ()
41+ delta = after - before
42+ self .assertLess (delta , 4 )
43+
44+
45+ if __name__ == '__main__' :
46+ unittest .main ()
You can’t perform that action at this time.
0 commit comments