By running only the following code in a single Jupyter Notebook cell, I load a file of 1GB in memory in a function and I return the result after the function definition:
import pickle
def fun():
with open('./data/input/train_test_clevr_pkls/train_clevr_1000.pkl', 'rb') as handle:
return pickle.load(handle)
fun()
The Jupyter Notebook will then print the output of the function. Looking at the memory consumed after I run the cell it sits at 1GB as expected. However, if I run the same cell multiple times the memory footprint increases by 1GB each time until my entire RAM is consumed and then my Windows Operating System uses page file swapping to handle even more memory marked as being consumed which destroys my application's performance. I already tried to use the gc.collect()
to free the memory but to no avail.
I saw similar questions being asked but I found no answer to my problem. The memory is NOT being reused internally, it only grows!