root icon indicating copy to clipboard operation
root copied to clipboard

Python Interface: assigning a numpy array to a std vector leaks memory

Open lwpiotr opened this issue 7 months ago • 0 comments

Check duplicate issues.

  • [ ] Checked for duplicates

Description

Assigning a numpy array to a std vector leaks memory. The attached script starts with 600 MB memory use and quickly goes into GBs. The commented-out vector::clear() does not help.

Reproducer

#!/usr/bin/python

import numpy as np
import ROOT

v = ROOT.vector["vector<vector<int>>"]()
a = np.arange(100**3, dtype=np.int32).reshape(100,100,100)

for i in range(10000):
    #v.clear()
    v += a

ROOT version

heads/master@v6-37-01-6541-g9a9e7697e4

Installation method

Source

Operating system

Linux

Additional context

No response

lwpiotr avatar May 31 '25 16:05 lwpiotr