mrkn / pycall.rb

Calling Python functions from the Ruby language
MIT License
1.05k stars 72 forks source link

Cope with numpy memleak (e.g. np.array([1,2,3]) < 1) #168

Closed mknkmyzk closed 1 year ago

mknkmyzk commented 1 year ago

memleak with numpy e.g.

require 'pycall/import'
include PyCall::Import

# require 'numpy'
# np = Numpy
pyimport :numpy, as: :np

zzz = np.zeros(1000000)
10000.times{
  zzz[zzz == 255] = 0   # mem leak !!
  zzz > 100             # mem leak !!
  gc.collect()
  GC.start
}
mrkn commented 1 year ago

@mknkmyzk Thank you very much!