8000 Reference leak when comparing structured scalars · Issue #6250 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Reference leak when comparing structured scalars #6250
@pitrou

Description

@pitrou

If you execute the following code, you'll it leaks a reference to the array:

recordtype = np.dtype([('a', np.float64), ('b', np.int32), ('d', (np.str, 5))])

a = np.zeros(2, dtype=recordtype)

print(sys.getrefcount(a))
u, v = a[0], a[1]
u == v
del u, v
gc.collect()
print(sys.getrefcount(a))

The leak disappears if you remove the comparison (u == v) or if you remove the character string member in the dtype (the d member here). I've tried to diagnose this but I'm ending up completely lost in the comparison logic (which creates multiple temporary arrays).

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

      0