@leledumbo
You were discussing "approach" outside the snippet I have shown

and I can't show that code because I'm not the owner (sam707 is) and because it's not a 20 lines

code.
that said, I'm happy for you if you've been hired by a billion dollar company. No Problem, I'm pretty sure billion dollars craps hurt better, in time HEHEHE
... I start the app, MemAvail reports around 1.1GB free, I then start the app, with Blender rendering sumthing on povray plugin, MemAvail repports 1.1GB, I then start libreoffice and load a big presentation, MemAvail repports 1.1GB, as long as no allocation inside the app, MemAvail is CONSTANT because of the memory virtualization, the app has its own address space, ... SO WTF "multitasking environment where available memory changes in millisecond boundary if not less" billion dollars bummer !