swagger-api / swagger-api/swagger-codegen
[Python] Memory leak in generated client
Open
@HugoMario is already working on this.
Since May 8, 2020.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Memory leak and accumulated slowness when initializing auto-generated python client from any swagger.
Swagger-codegen version
v2.4.10
Swagger declaration file content or url
When creating python client, and initializing it, a memory leak takes place. When doing it a lot of time, the memory goes up to GBs, and initializing another client can take 10s of seconds.
Steps to reproduce
- Create and download a python client from https://editor.swagger.io/. Use any swagger you want.
- Create
a.py:
import time
import swagger_client.api_client as api
while True:
before = time.time()
api.ApiClient()
print time.time() - before
$ python a.py- At first it takes ~0.003 seconds per loop on my computer and the memory 51MB:

- After 5 minutes it takes ~0.005 and the memory is up to 170MB

- After a few hours the memory is GBs and the time per loop is a few seconds
Suggest a fix/enhancement
Note the bug doesn't happen in version v3.0.14.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.