Author Ofer Sadan
Recipients Ofer Sadan
Date 2019-09-22.11:29:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569151788.73.0.0306600169217.issue38251@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-09-22 11:29:48Ofer Sadansetrecipients: + Ofer Sadan
2019-09-22 11:29:48Ofer Sadansetmessageid: <1569151788.73.0.0306600169217.issue38251@roundup.psfhosted.org>
2019-09-22 11:29:48Ofer Sadanlinkissue38251 messages
2019-09-22 11:29:48Ofer Sadancreate