Dynamic memory allocation seems instant in debugging but gradual in release mode

I have a large dynamically allocated array (C ++, MSVC110), and I initialize it as follows:

try {
    size_t arrayLength = 1 << 28;
    data = new int[arrayLength];
    for (size_t i = 0; i < arrayLength; ++i) {
        data[i] = rand();
    }
}
catch (std::bad_alloc&) { /* Report error. */ }

Everything was in order before I tried to allocate more than the real system RAM, for example 10 GB. I expected to get an exception bad_alloc, but the system (Win7) began to change like crazy, etc., you know what I'm talking about.

Then I examined the situation in my task manager and noticed an interesting thing, in debug mode the selection was instantaneous, but in the release it was gradual.

Debug Mode:

Debug mode allocation graph

Release Mode:

Release mode allocation graph

What causes this? Could this adversely affect performance? Did I do something wrong? Is the OS causing this? Or C ++ allocator?

, , . , ++?

, ​​Windows, .

+4
1

, , . , , .

, , .

, , . , , Windows.

, , , - , ( ).

(.. ), , .

, .

, ; , , , , .

swap - , , (.. - 500 1 )

+2

Source: https://habr.com/ru/post/1524149/


All Articles