Skip to content

[Bug]: Massive memory leak with 'maintainAspectRatio:false' with bar graphs (React-ChartJS-2) #11299

Closed
@lkarvec

Description

@lkarvec

Expected behavior

Expected: Probably not a huge memory leak, and probably not active resizing without setting it

Attached is a fork of your test repo where I pretty much just add a bootstrap button, the height for the graph, and the option for the aspect ratio.

Current behavior

Current: upon setting maintainAspectRatio to false on a bar graph so I can manually set height (per your docs suggestion) and placing another prebuilt component next to it (I've used different ones like buttons, query builders, cards), the page renders the desired size, and then starts infinitely expanding the height of the graph, and using about 1-2GB of ram extra for every extra second it resizes.

Sometimes it slows down or stops resizing, and when I hover over one of the bars on the graph, and the tool tip appears; while the tooltip is visible, it continues to expand size and memory usage.

It does NOT do this when I just have the graph in a card on the page, but the moment I add something else to the page, it does this. It also does NOT do this when maintainAspectRatio is true. It also does NOT do this when I slap some sort of container, like a react-bootstrap grid, around it.

Reproducible sample

https://codesandbox.io/s/async-star-dfvloy?file=/App.tsx

Optional extra steps/info to reproduce

reactchartjs/react-chartjs-2#1168 is the bug form I filled over there.

Possible solution

No response

Context

No response

chart.js version

4.3.0

Browser name and version

Chrome 113.0.5672.93

Link to your project

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions