View Full Version : Detecting low memory
steg90
11th June 2007, 15:40
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
wysota
11th June 2007, 16:56
QTimer or timerEvent seem to be good ways to start with...
fullmetalcoder
11th June 2007, 17:34
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?)
wysota
11th June 2007, 18:54
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.