swagger-api / swagger-api/swagger-codegen

[Python] Memory leak in generated client

Open
#9,913 1 comment 0 reactions 1 assignee View on GitHub

@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
  1. Create and download a python client from https://editor.swagger.io/. Use any swagger you want.
  2. Create a.py:
import time
import swagger_client.api_client as api
while True:
    before = time.time()
    api.ApiClient()
    print time.time() - before
  1. $ python a.py
  2. At first it takes ~0.003 seconds per loop on my computer and the memory 51MB:
    Screenshot from 2019-12-04 18-54-29
  3. After 5 minutes it takes ~0.005 and the memory is up to 170MB
    Screenshot from 2019-12-04 18-59-49
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.