That part is not as surprising to me.

The resize array keeps a copy of the data before and after the operation.
If the data before the resize is 0 then that copy is very small.
If OTOH the data is 300MB then it needs to have 300 MB before and 4/3*300MB after.

I'm wondering if part of what we are seeing is simply on how Windows works.
In your code it clearly is all data allocated on the heap, no stack in there.
Normally the layout of a win32 app has a predefined stack size (which IIRC grows downwards, so it is as the bottom), The heap grows upwards towards kernel space. So I suppose not being able to fully allocate 2GB isn't that surprising as then there would be no space left for the stack.

I'm just a bit puzzled about on how easy it it so hit the OOM error.

--
Wil