Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

memory 1

Status
Not open for further replies.

shetlandbob

Programmer
Mar 9, 2004
528
GB
Hi,

I have an application where the users can load in a scientific test into my program for analysis. In fact they can load X number of similar tests. Each one is read into its own class.

At present I limit the number of tests they can load (for memory reasons), I know how much memory each run will hold so I know how much memory X number of tests requires.

I want to add the functionality that the user can specify the maximum number of tests they can load.

How can I tell how much memory the user has on there machine so I can calculate if the user is requesting too many tests, i.e. the machine will either crash or run slowly if they try to load too much into memory. Can I tell if they are using other programmes and how this will effect the performance.

 
See GlobalMemoryStatus() Win API (Win NT++) and GlobalMemoryStatusVlm() (Win 2000+) functions and MEMORYSTATUS structure.
Code:
#include <windows.h>
...
MEMORYSTATUS ms;

GlobalMemoryStatus(&ms);
cout << "dwMemoryLoad\t" << ms.dwMemoryLoad << endl;
cout << "dwTotalPhys\t" << ms.dwTotalPhys << endl;
cout << "dwAvailPhys\t" << ms.dwAvailPhys << endl;
cout << "dwTotalPhys\t" << ms.dwTotalPhys << endl;
cout << "dwTotalPageFile\t" << ms.dwTotalPageFile << endl;
cout << "dwAvailPageFile\t" << ms.dwAvailPageFile << endl;
// an so on...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top