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.
2
u/Morgan243 Apr 07 '15
I've been logging the IPython's memory usage since the end of last week. When I left, after a few hours of light use, the server had over a GB of PSS. It stayed at this level of usage up until today because no one was using it. It's had heavy usage today though - saving figures and displaying them (avoiding matplotlib inline), restarting notebookes, building small DataFrames (less than 20MB) - and it has reached ~3.4 GB PSS. Only 225MB of memory remain on the server, though only ~10% of a 4GB swap is in use. At this point, all notebooks are off but I cannot start any of them do to the lack of memory: 'OSError: [Errno 12] Cannot allocate memory'
Memory is not being reclaimed and I'll have to restart the IPython notebook server in order to make it usable again. Whether the memory is being used for some caching methodology I'm not privey too or it's from an actual memory leak is irrelevant; what matters is that the implementation is making the IPython notebook server unusable in a produciton environment and should be addresed.