Skip to content

memory leak? #1056

@Shreartiq-sinara

Description

@Shreartiq-sinara

Hi,

I’m seeing an unbounded memory leak when embedding a bare fastplotlib.Figure in a PyQt6 app on Windows.

The leak occurs even with:

no plotted data
no user-defined animations
an otherwise empty figure embedded in a QMainWindow
In my full application, this eventually grows to tens of GB and the process crashes after running for a long time.

During debugging, I compared against a raw rendercanvas.qt.RenderCanvas + pygfx.WgpuRenderer test, which stayed stable. The leak appeared when using fastplotlib.Figure.

The most suspicious part seems to be the continuous redraw loop in Figure._render():

self._call_animate_functions(self._animate_funcs_pre)

for subplot in self:
subplot._render()
...

self._call_animate_functions(self._animate_funcs_post)

if draw:
self.canvas.request_draw()

Is the unconditional canvas.request_draw() in Figure._render() intentional for non-animated figures?

it looks like the Figure with no animations is still continuously rendering forever, and that repeated render/present cycle leaks memory somewhere in the fastplotlib/pygfx/wgpu stack.

Has this issue been raised before by someone else?.
he performance of the fastplotlib has been excellent and fits well into my app. But i also need my app to stay alive. I tried a few patches which fixed the ram overrun issue but..... then run into performance issues because of those patches.

Also i just updated/reinstalled the fastplotlib package to see if that fixes the issues, but now the cpu usage is through the roof. the memory leak is still present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions