This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients levkivskyi, methane, serhiy.storchaka, vstinner
Date 2019-04-09.12:05:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If I modify libregrtest with the following patch:

diff --git a/Lib/test/libregrtest/ b/Lib/test/libregrtest/
index 0bb8a0a2bf..f0225a9768 100644
--- a/Lib/test/libregrtest/
+++ b/Lib/test/libregrtest/
@@ -128,7 +128,7 @@ def dash_R(ns, the_module, test_name, test_func):
     failed = False
     for deltas, item_name, checker in [
         (rc_deltas, 'references', check_rc_deltas),
-        (alloc_deltas, 'memory blocks', check_rc_deltas),
+        (alloc_deltas, 'memory blocks', check_fd_deltas),
         (fd_deltas, 'file descriptors', check_fd_deltas)
         # ignore warmup runs

And I add the following file Lib/test/

import unittest

class NoopTests(unittest.TestCase):
    def test_noop(self):

regrtest detects a "leak":

$ ./python -m test -R 3:3 test_noop
Run tests sequentially
0:00:00 load avg: 0.55 [1/1] test_noop
beginning 6 repetitions
test_noop leaked [0, 1, 0] memory blocks, sum=1
test_noop failed

== Tests result: FAILURE ==

1 test failed:

Total duration: 113 ms
Tests result: FAILURE

The issue comes from this look in Lib/test/libregrtest/

    for i in range(repcount):
        alloc_after, rc_after, fd_after = dash_R_cleanup(fs, ps, pic, zdc,
        print('.', end='', file=sys.stderr, flush=True)
        if i >= nwarmup:
            rc_deltas[i] = get_pooled_int(rc_after - rc_before)
            alloc_deltas[i] = get_pooled_int(alloc_after - alloc_before)
            fd_deltas[i] = get_pooled_int(fd_after - fd_before)
        alloc_before = alloc_after
        rc_before = rc_after
        fd_before = fd_after

Because of "if i >= nwarmup:", get_pooled_int() isn't call during "warmup", whereas the purpose of the warmup is to warmup *everything*.

Maybe get_pooled_int() allocates one frame object and keeps it alive in its "zombi frame". Maybe something else is allocated and kept alive.

Anything, removing "if i >= nwarmup:" to always compute deltas fix this specific issue.

Attached PR 12744 fix this bug.
Date User Action Args
2019-04-09 12:05:09vstinnersetrecipients: + vstinner, methane, serhiy.storchaka, levkivskyi
2019-04-09 12:05:09vstinnersetmessageid: <>
2019-04-09 12:05:09vstinnerlinkissue36560 messages
2019-04-09 12:05:09vstinnercreate