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 thehesiod
Recipients christian.heimes, thehesiod
Date 2017-03-22.01:10:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490145031.23.0.122177607626.issue29870@psf.upfronthosting.co.za>
In-reply-to
Content
When upgrading to 3.5.3 we noticed that the requests module was leaking memory rather quickly.  This led to me logging the issue: https://github.com/kennethreitz/requests/issues/3933.  After more investigation I've found that the leak is caused by the raw python SSL sockets.  I've created a test file here: https://gist.github.com/thehesiod/ef79dd77e2df7a0a7893dfea6325d30a which allows you to reproduce the leak with raw python ssl socket (CLIENT_TYPE = ClientType.RAW), aiohttp or requests.  They all leak in a similar way due to their use of the python SSL socket objects.  I tried tracing the memory usage with tracemalloc but nothing interesting popped up so I believe this is a leak in the native code.

A docker cloud image is available here: amohr/testing:stretch_request_leak based on:
```
FROM debian:stretch

COPY request_https_leak.py /tmp/request_https_leak.py

RUN apt-get update && \
    apt-get install -y python3.5 python3-pip git

RUN python3 -m pip install requests git+git://github.com/thehesiod/pyca.git@fix-py3#egg=calib setproctitle requests psutil
```

I believe this issue was introduced in python 3.5.3 as we're not seeing the leak with 3.5.2.  Also I haven't verified yet if this happens on non-debian systems.  I'll update if I have any more info.  I believe 3.6 is similarly impacted but am not 100% certain yet.
History
Date User Action Args
2017-03-22 01:10:31thehesiodsetrecipients: + thehesiod, christian.heimes
2017-03-22 01:10:31thehesiodsetmessageid: <1490145031.23.0.122177607626.issue29870@psf.upfronthosting.co.za>
2017-03-22 01:10:30thehesiodlinkissue29870 messages
2017-03-22 01:10:30thehesiodcreate