Creating and argsorting a Python-numpy array with a structured dtype leaks memory -
this week i've been hunting memory leak in python application has been causing memoryerrors, , have managed distill logic appears causing down 20 lines. following snippet of code consumes steadily increasing amounts of memory when run (even after calls gc.collect every 5000th iteration), observed task manager. why? bug in numpy?
import gc import numpy np while true: names = ["poh"] + \ ["head %d long data field name many words" % in xrange(200)] formats = [">f"] + [">i"] * 200 offsets = range(0, 804, 4) dt = np.dtype({"names": names, "formats": formats, "offsets": offsets}) array = np.zeros((1000,), dt) sortedindices = np.argsort(array, order=["poh"]) n += 1 if n % 1000 == 0: print n if n % 5000 == 0: gc.collect()
i running numpy 1.11.0 python 2.7.11 on 64-bit windows 7.
Comments
Post a Comment