ipython/ipython — Issue #1131: reduce client caching of results
Author: minrk
Created: 2011-12-09 03:50:01+00:00
State: open
Labels: parallel, prio-medium, status-dormant, type-enhancement

The current parallel code doesn't *need* to store much in memory. But it does, particularly in the Client. We cache results for convenience in the Client's `results` and `metadata` dicts. This data is readily reproducible from the the Hub, so discarding it beyond a certain point shouldn't be an issue.

To easily run your client out of memory, simply echo a large array a number of times:

```python
A = np.zeros(1024*1024)
for i in range(100):
rc[0].apply_sync(lambda x:x, A)
```

And bam, you have 100 copies of A in memory.

We should figure out a sensible scheme for purging old results, so the client doesn't grow too much during data-intensive tasks.

One thing we could do is have AsyncResult objects *remove* results from the Client's result dict when they are retrieved. It's true that it's possible to have multiple AsyncResults pointing to the same message, but it's not likely, and shouldn't come up in normal use.