I don't know why are you doing all that, but such allocation depends on the platform. Also, the actual possibility to allocate so much memory depends on the actual use of the memory at the moment; I guess you understand it.
Let's see. The address space of a 32-bit process is limited by the type of its address word, which it 32 bits, which gives you 4G. You require 2G. On a 32-bit platform, this is all the memory dedicated to all code taken together, those in the outer (user) protection ring. Other 2G is dedicated to the OS internals. According to documentation, system configuration can be changed to leave 3G to the applications, but I never tried it.
But it looks like you are only interested in allocation of the memory on a 64-bit system. Then, even if your process is a 32-bit one, it can use up to 4G of memory (excluding the memory already used by code and static data, plus some overhead, of course, hard to say how much; you can experiment with it). This is because each process is given its own address space (32-bit address space, in your case, 4G); different 32-bit processes don't compete over the common 4G space; instead, they are loaded independently using the Windows sub-system WoW64, which is a 64-bit layer used to support 32-bit processes:
http://en.wikipedia.org/wiki/WoW64[
^].
—SA