Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How can/should I respond to "memory pressure" events in a QML&C++ app?
QtWS25 Last Chance

How can/should I respond to "memory pressure" events in a QML&C++ app?

Scheduled Pinned Locked Moved Mobile and Embedded
iosmemory
4 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    timday
    wrote on 27 Apr 2016, 23:11 last edited by timday
    #1

    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).

    I assume the QML and its javascript engine must already have its own mechanisms for responding to memory pressure (not looked at the sources yet or paid much attention to how big QML-only - apart from a QQuickView host - apps get or behave on iOS though).

    Any hints on how to deal with this sort of thing?
    Thanks
    Tim

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Apr 2016, 21:58 last edited by
      #2

      Hi,

      Do you mean your would like to do something in didReceiveMemoryWarning ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply 29 Apr 2016, 00:35
      0
      • S SGaist
        28 Apr 2016, 21:58

        Hi,

        Do you mean your would like to do something in didReceiveMemoryWarning ?

        T Offline
        T Offline
        timday
        wrote on 29 Apr 2016, 00:35 last edited by timday
        #3

        @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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 29 Apr 2016, 20:37 last edited by
          #4

          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 :))

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          3/4

          29 Apr 2016, 00:35

          • Login

          • Login or register to search.
          3 out of 4
          • First post
            3/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved