Python Garbage Collection sometimes not working in Jupyter Notebook : <p>I'm constantly running out of RAM with some Jupyter Notebooks and I seem to be unable to release memory that is no longer needed. Here is an example:</p>

<pre><code>import gc
thing = Thing()
result = thing.do_something(...)
thing = None
gc.collect()
</code></pre>

<p>As you can presume, <code>thing</code> uses a lot of memory to do something and then I don't need it anymore. I should be able to release the memory it uses. Even though it doesn't write to any variables that I can access from my notebook, garbage collector isn't freeing up space properly. The only workaround I've found is writing <code>result</code> into a pickle, restarting kernel, loading <code>result</code> from pickle, and continuing. This is really inconvenient when running long notebooks. How can I free up memory properly?</p>
