Memory leak with conversion from numpy array to System.Single[]
Hi, I have been using Python for .Net quite successfully to access an I/O library that allows me to perform some numerical calculations in Numpy. This library primarily requires the data to be fed back as Single Arrays. However when I perform many conversions from numpy arrays (or even just lists) to Single[] I am experiencing a memory leak that eventually causes a crash. The following distills the problem. By switching between the two different Array types (Single & Double) the leak is controlled so it would seem there is some issues with Single. It does not appear to matter whether change the dtype of the numpy array to float32. I have also tried Array.ConvertAll but the same problem arrises. import numpy as np import clr from System import Array, Single, Double N = 100000 M = 1000 for i in range(N): # Numpy calculations A = np.random.random( M ) # Convert to single array - creates memory leak sgl_arry = Array[Single](A) # Convert to double array - does NOT create memory leak #dbl_arry = Array[Double](A) # call library requiring Single[] # .... Any help would be appreciated. Thanks, James
participants (1)
-
James