Skip to content

Memory leak when returning numpy arrays #47

Open
@mferrero

Description

@mferrero

When numpy arrays are returned, a small amount of memory leaks. This amount of memory (I think it is 32 bytes) does not depends on the actual size of the array that is returned, so it is probably related to some object that is created while preparing the numpy array. The following code produces a leak

from triqs.gf import *

g = GfImFreq(indices = [0], beta=10, n_points=1000)
#g = GfImFreq(target_shape = [], beta=10, n_points=1000) ## no memory leak with this
# memory usage here is about 42 Mb

for k in range(10000000): x = g(1)
# memory usage here is about 350 Mb

In the code above, the memory usage is about 300 Mb larger after the loop. Similar behavior is observed calling other functions that return an array. I don't see leaks when the functions return a float.

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