python del keyword doesn't work on numpy arrays

80 Views Asked by At

I tested the two following code snippets in Colab.

The first one is a list of lists.

a = []
for i in range(100000):
  a.append([0 for _ in range(10000)])

After I run this, the system RAM jumps up from 1.0 GB to 8.8 GB. Then I try to delete this list.

del a

System RAM gets back to 1.0 GB.

Now I try the same thing with a list of numpy arrays

import numpy as np
b = []
for i in range(100000):
  b.append(np.zeros(10000))

System RAM jumps up from 1.0 GB to 7.6 GB. But now when I try to delete it:

del b

Nothing happens!

What's the reason behind this behaviour?
How can I delete b?

Thanks in advance

0

There are 0 best solutions below