Isolate low memory notification
I'm developing a platform that runs 3rd party jars inside isolates. The problem is that memory is very limited. If I start an app and it tries to allocate memory, but that allocation generates an out of memory exception I would like the chance to kill and unload any back ground isolates first. Currently my only two solutions are to kill all apps before launching a new one or picking a random number and killing the least recently used apps until an arbitrary amount of memory is available.
The apps don't technically run in the back ground so it's fine that I kill them, but if the end user switches between apps a lot it would be nice not to reload them each time.
My question is has anyone implemented something like this or has an idea on how they might achieve it?