I'm going to write an application that needs a lot of memory dynamically. Most of the memory is used for caching purposes and is just used for speed ups. Those parts could actually be freed on demand.
Unfortunately my kernel will kill the process if it runs out of memory. But it could simply free memory. So what I want is very similar to the linux page cache as it is explained here. Is it possible to implement such behaviour in userspace in a convenient way?
I'm thinking about implementing such a cache with "cache files" which are stored on a ramfs/tmpfs with memory mapped file IO, but i'm sure, that there is a more comfortable way.
Thanks in advance!