r/IPython • u/Morgan243 • Apr 02 '15
Memory issues with IPython notebook server
I have interest in using the IPython notebook server as a persistent place to store workflows, algorithms, and ideas. This seems like the perfect use-case for the notebook server - however, I'm having trouble wrapping my head around the server's memory usage. Currently, the server doesn't appear to manage memory well enough to support even a single working for a day or two.
I've turned off output caching and I'm avoiding "%matplotlib inline" (issue #7270 on Github).
To be clear, it's the notebook server running in Python3, that is growing in memory, not the kernel's. It appears that with every new notebook opened, the server allocates more memory, which makes sense. But closing and shutting down a notebook doesn't appear to free all of this memory. So as I close and open notebooks of varying sizes, the memory allocation grows and grows. Furthermore, the server will allocate more memory on the heap as the notebook produces output (which makes sense) and occasionally as some other operations occur (which is harder understand). But again, it seems that the server almost never frees memory, so eventually I cannot start any notebooks (I get memory allocation exceptions) and I'm eventaully forced to restart the server.
The notebook server is on a RHEL 6 machine, with 4GB of memory. I realizes this isn't much memory, but that doesn't explain why the notebook server can end up using GBs of heap with very little assets and after all kernels are stopped. I'm using the latest stable versions of both Python 2 and 3 compiled from source. I have the most experience with this problem using the PyPi version for Python3, but I've also confirmed this same problem in the repo's master branch (pulled ealier this week). The memory usage I'm referring to is the Proportional Set Size of the processes heap, found in /proc/<pid>/smaps.
Is an IPython notebook server meant to be "up" long-term? Or is are the notebooks intended to be just a niceity for spontaneous local work? Is this a known issue I'm not aware of? Is anyone else using the server in this way succesfully? Please let me know if there is any other information I can provide.
1
u/Berecursive Apr 03 '15
Are you actually having problems with the memory usage - as in, are you running out of memory (are called failing with OutOfMemoryError)? Because, if not, it's because IPython aggressively caches cell output in case you rerun a cell. In general, my notebooks appear to be using many GB of memory, but I never actually run out or hit swap unless I run a very memory hungry command.