Results 1 to 4 of 4

Thread: Detecting low memory

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Detecting low memory

    Hi,

    Any good strategies for detecting low memory? O/S is Win32.

    I'd like to emit a signal when memory gets too low and warn the user of this.

    Regards,
    Steve

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Detecting low memory

    QTimer or timerEvent seem to be good ways to start with...

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Detecting low memory

    Quote Originally Posted by wysota View Post
    QTimer or timerEvent seem to be good ways to start with...
    If I understand well he meant "detecting" before reporting... I'm afraid there's no "simple & smooth" (c) way to do that so you'll have to mess with low level system calls.

    Under Unix however there is a not-that-hard way to deal with this :
    $ cat /proc/meminfo
    Of course you got to parse the output but that's quite a synch...

    If you don't want to rely on subprocesses Qt can make your way easier (though I can certify that they don't use subprocesses under the hood to achieve that) because QFile can reads the content of such special files (only using readAll() if I remember well but that's not a too big limitations is it?)
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Detecting low memory

    I'm not quite sure what you mean by "detect", but there are surely function calls for each platform that return amount of virtual/physical memory available.

Similar Threads

  1. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42
  2. Any reason for memory leak?
    By steg90 in forum Newbie
    Replies: 2
    Last Post: 10th May 2007, 15:00
  3. Memory Problem with SIGNALS and SLOTS
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2007, 20:39
  4. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  5. Qt 4.1 Memory Leak
    By blackliteon in forum Qt Programming
    Replies: 14
    Last Post: 10th February 2006, 12:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.