How can/should I respond to "memory pressure" events in a QML&C++ app?
I have an app which is mainly QML with some C++ components and am (fairly happily) running it on iPads.
It needs a bit more investigation but I suspect it's prone to being targeted for termination by iOS's logic for reducing "memory pressure", especially as the only "crashes" I've seen are when I run it with other applications open (not actually caught one with xcode attached though, which I believe would confirm a memory-pressure related kill).
Since the C++ components include some internal caches (in RAM; currently allowed to grow to 128MByte total... hmmm... probably a bit optimistic) which could and should happily be flushed clear when iOS issues a memory pressure warning to apps... well it would be great if there was some way of detecting such events in C++ and acting accordingly, but so far as I know Qt provides no such mechanism (am I missing something? If not, should there be something? The more you read about the iOS ecosystem the more you realize responding to memory pressure events is an important part of avoiding an app getting culled).
Any hints on how to deal with this sort of thing?
Do you mean your would like to do something in
@SGaist Yes, I think, but how do I do that in a "Qt way" without writing any Objective-C? I've yet to try anything like inserting Objective-C code into my QML & C++ codebase (and I've no idea where I'd start trying to do that because all the stuff I've found about handling memory pressure is described in terms of Apple's APIs... about which I know very little, 'cos I'd rather use Qt APIs everywhere!). I suppose ideally I'd hope there was some signal emitted for this sort of thing by some object and I'd just connect some "flushCache" slot on my objects with flushable caches to it and... Job Done.
AFAIK, you'll to write a bit of Objective-C++ in this case to send an event or a signal to your application to act on that situation.
You can also make a feature request to get something in Qt for that (or if you write for your application, make a submission with it :))