[New-bugs-announce] [issue38251] urllib.request memory leak / overflow

Ofer Sadan report at bugs.python.org
Sun Sep 22 07:29:48 EDT 2019


New submission from Ofer Sadan <ofersadan85 at gmail.com>:

running `urllib.request.urlopen` multiple times causes the memory usage to increase with each run, even after calling `close()` on the request or using `del` on the result

To recreate this problem, run code:

    import urllib.request
    def ip():
        r = urllib.request.urlopen('https://api.ipify.org')
        b = r.read()
        r.close()
        print(len(b))
        return b

    for i in range(1000):
        result = ip()
        del result

Even though `len(b)` has a maximum value of 15 (for this url at least), the memory increases with each run by 200KB - 1MB

----------
components: Library (Lib)
messages: 352968
nosy: Ofer Sadan
priority: normal
severity: normal
status: open
title: urllib.request memory leak / overflow
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38251>
_______________________________________


More information about the New-bugs-announce mailing list