I bet there's a simple function that can return the amount of RAM available on the computer, or perhaps the total RAM on the chip.
Basically I want a way of making sure my program never tries to allocate memory when it can't... I know that Windows should stop this happening anyway but I want to make sure the program can take care of certain things if it happens.
I bet there's a simple function that can return the amount of RAM available on the computer, or perhaps the total RAM on the chip.
No. In any case, you can't hog all of your computers resources if you're running on an OS anyway, so the question is pointless for what you're trying to do. new throws and malloc returns NULL when it fails, just check for that. If you're dealing with large datasets, let the user decide how much memory you're allowed to use at once.