IronPython throw InsufficientMemoryException when using numpy in threads IronPython throw InsufficientMemoryException when using numpy in threads multithreading multithreading

IronPython throw InsufficientMemoryException when using numpy in threads


I believe that numpy is not thread-safe. I had a similar problem where using np.asarray() with threading would crash my program. It seems that the way that numpy's array function builds the array is not thread-safe. The way around this I found was to use np.fromiter() instead. Apparently, it is thread safe. It is slightly slower, which makes since if it is not using threading, but it works. Try putting your data into a list (or some other iterable data structure) and using np.fromiter() to convert it to a numpy array.

Also, just so you know, it actually runs fine on my computer so it could just be that you don't have enough memory to handle threading (or at least not when using numpy).