c++ – How to allocate the maximum amount of memory in C ++?

Question:

How to allocate the maximum amount of memory in C ++ under Windows, ideally all the RAM? Do you need to request a larger block, or is it better, on the contrary, small? If you request too many small blocks, will it run into OS limits (or slow down) before all memory is taken up?

Answer:

It is impossible to capture all memory in one block. But in a few pieces – a little more real. But even so, there is memory where the application itself, the operating system, and the like are located. You still cannot guarantee that all this memory will remain in the RAM, perhaps it will begin to partially go to swap if the system thinks that memory is now more needed by other applications. Either other applications will start to leave the swap, and yes – the work of the system will then slow down because of this.

Scroll to Top