Created
February 22, 2021 22:30
-
-
Save megpay/14681b8d953f17dfd1c1439cd4b5e2c9 to your computer and use it in GitHub Desktop.
Manual garbage collection when RAM is limited
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Manual garbage collection due to limited RAM - useful in Kaggle competitions | |
import sys | |
for i in dir(): | |
if sys.getsizeof(eval(i)) > 10000: | |
print("the size of {} is:".format(i), sys.getsizeof(eval(i))/1e+9) | |
import gc | |
del train # delete a data frame | |
gc.collect() # manual garbage collection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment