Skip to content

Possible memory leak moving arrays to and from python #333

@mikeWShef

Description

@mikeWShef

Hi I brought this up on the gitter and people said to post here. It seems like there is a memory leak when moving arrays between rust and python.

I have made an minimal example repo here:
https://github.com/mikeWShef/leak

I am explicitly copying the arrays using into_pyarray and as_array, but as far as I know this should not be an issue.

The jupyter notebook example will quickly fill >30GB of memory when really there are only a maximum of 6 arrays of 2048**2 float64 so ~200MB.

When the rust program ends the memory is cleaned up again, but adding gc.collect() into the python function dosn't fix the leek.

Windows 11, python 3.8, numpy 1.20.3 tested

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions