does anyone have any nifty code for checking that the device has a "required" amount of space avaliable to run an application?
i.e to terminate the program if not enough!
Hey brendan,
There is a function you can use to ask the device, and it'll put some free and used memory information in a struct (also defined), which you can then access. I used it when I was having memory problems and wanted to check if I was using too much.
I'll try and find out what it's called when I get home. In the meantime, one of the other guys can help you, or you can find it yourself in the help.
Nathan
- Code:
MEMORYSTATUS* myMemoryInfo;
myMemoryInfo = new MEMORYSTATUS;
GlobalMemoryStatus(myMemoryInfo);
//
// Access the MEMORYSTATUS struct and find out the info.
//
delete myMemoryInfo;
I think this will work.
BTW, you can use a debug build to investigate the contents of your MEMORYSTATUS struct step by step, but it might not accurately reflect memory used in a release build.
Nathan
I recommend trying to allocate the memory you need, as opposed to checking the free memory and giving up if it is not large enough. The OS will dynamically adjust the memory depending on how much is required.
Dan East