How to release memory after pickle.load(file_)

Question:

I have to load multiple pickle files and do some work on them, I am getting a memory error.

Is there a way to release the memory after pickle.load?

My pickle file is gpickle, I have to load it and do some operations on it, once loaded I don’t really need the loaded pickle file once the data inside it has been read.

Asked By: aryan singh

||

Answers:

One possibility is to del the object after it’s not needed, rough pseudocode:

data1 = pickle.load(pickle_file1)
# do some work
del data1

data2 = pickle.load(pickle_file2)
# do some work
del data2
Answered By: SultanOrazbayev
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.