On 28 October 2013 03:13, Georgios Exarchakis <gexarcha1@gmail.com> wrote:
If yes then how do you release memorry by slicing away parts of an array?

An array is a single Python object. In your example, there is always one reference pointing to the array (either the whole array or only a view), so the memory cannot be released.

In your case, a = a[:10000].copy() releases the memory by creating a new object and pointing a to this new one, so the big array gets unreferenced and thus, garbage collected. The price to pay is that, for some time, you have living in memory both the original array and your new one: if they were very big, you could run out of memory; and that you have to perform a memcopy (again, slow if you have lots of data).


/David.