PumpkinDB icon indicating copy to clipboard operation
PumpkinDB copied to clipboard

Problem: EnvHeap never releases memory

Open yrashk opened this issue 8 years ago • 0 comments

This is fine for short-running scripts but will become a problem for longer-running ones.

Proposed solution: every once in a while (when a script hits an allocation or runtime threshold, for example), check if all the allocations in EnvHeap are on the stack. If not, deallocate it. It's important to notice that once zero-copy reading will be possible (see #8), for example, by transmuting the database reference to Env lifetime (and making sure to copy them once the transaction ends), there will be a case when the data doesn't point to EnvHeap.

This solution implies that EnvHeap will have to learn how to reuse memory chunks. This might mean that it would need to prefix every allocation with a usize and a bit that would indicate whether the sub-chunk is still used, and use that during allocation. Something like that...

yrashk avatar Feb 27 '17 05:02 yrashk