A bit off-topic, but still: it's not a very good idea to make your application's behavior/logic dependent on amount of free memory reported by the system. Reasons: 1) most, if not all, modern OSes use "delayed allocation" strategy, so a successful malloc() or its equivalent doesn't guarantee you actually will be able to use that memory; 2) multitasking means there's always a chance that during the period between you request information about available RAM and try to use it another process will allocate some amount of memory for its own needs, causing your allocation to fail.
My suggestion is either to: 1) use system's native functions to get total amount of memory and use it to determine the upper limit for your allication (e.g. never allocate more than 50% of RAM even if it's not used by anything else); 2) enlarge your buffers when necessary until you get an "out of memory" signal in form of std::bad_alloc, NULL returned by an allocation function, etc.. On Jul 8, 2013 4:20 PM, <[email protected]> wrote: > Using 4.8 under windows / mingw, I catch a std::bad_alloc exception > raised somewhere, that I do not seem to have raised. At that point, > there is still 66% of system memory available according to windows. > > 1) Is there a Qt way to programmatically monitor the amount of RAM yet > available to the current process ? > > 2) Is there a standard way to debug this, in order to find where the > exception was raised ? > > Quentin > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest >
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
