swagger-api / swagger-api/swagger-ui

Using swagger-ui in react app causing memory leak. Takes up lots of memory and CPU usage.

Open
#5,854 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: MacOS
  • Browser: Chrome
  • Version: 79.0.3945.130
  • Method of installation: npm
  • Swagger-UI version: 3.24.2
  • Swagger/OpenAPI version: Swagger 2.0
Content & configuration

Uploading a swagger spec more than 2 mb in size.

Note: Memory leak exists regardless of the size of the swagger, but impact is significant when using a large swagger file.

Example Swagger/OpenAPI definition:

b2bi.json.zip

Describe the bug you're encountering

After swagger component is rendered and interacting between the methods, memory used by the tab keeps increasing along with the CPU usage. Switching between components, even unmounting the component which uses swagger-ui component doesn't get rid of the memory used and keeps increasing the memory usage as the swagger-ui component is visited eventually crashing the application and browser.

To reproduce...

Steps to reproduce the behavior:

  1. Go to swagger component.
  2. Upload large swagger spec file.
  3. Switch between tabs and keep interacting with the application, visiting the swagger methods.
  4. See memory usage increase along with the CPU usage.
Expected behavior

Should not take up all the memory. No memory leak.

Screenshots

On initial render

Screen Shot 2020-02-19 at 5 06 55 PM

After expanding and interacting with methods

Screen Shot 2020-02-19 at 5 08 09 PM

Screen Shot 2020-02-19 at 5 09 21 PM

Additional context or thoughts

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.

Research direction

Start by reproducing the issue in the React app with Swagger UI 3.24.2, Chrome, and the provided large Swagger 2.0 definition. Exercise the methods, switch tabs, and unmount the Swagger component while monitoring memory and CPU; done means repeated interaction and unmounting no longer cause memory usage to keep increasing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.