As you see, while the memory consumption of the line np.ones((n,), dtype=np.float32) is constant, only the first measurement is correct; the next measurements seem to not notice that the Python interpreter is reusing memory it had previously claimed from the OS and freed in garbage collection.
Is there any way to handle this problem? It makes it difficult to find where memory is being actually used, as opposed to finding the very first big allocation.
As you see, while the memory consumption of the line
np.ones((n,), dtype=np.float32)
is constant, only the first measurement is correct; the next measurements seem to not notice that the Python interpreter is reusing memory it had previously claimed from the OS and freed in garbage collection.Is there any way to handle this problem? It makes it difficult to find where memory is being actually used, as opposed to finding the very first big allocation.