More than 1GB memory allocation error
<p>I am trying to develop an application which allocates given number of GB's from the RAM. When i try to allocate 1 GB RAM it works fine but, more than 1GB, it crashes.</p>
<p>I am using Windows 7 - 64bit and I have 6 GB RAM (Installed Memory). I develop this application with Qt and I am using Visual Studio 2013.</p>
<p>Code is here:</p>
<pre><code>int size = 1024 * 1024 * 1024;
m_Size = ui.CPUAllocationEntry-&gt;text().toInt();


m_Arr =(char*) malloc(sizeof(char)*size*m_Size);
memset(m_Arr, 1, size*m_Size);
if (m_Arr == NULL)
{
    qDebug() &lt;&lt; &quot;Pointer Null&quot; &lt;&lt; endl;
}
else
    qDebug() &lt;&lt; &quot;Pointer NOT null&quot; &lt;&lt; endl;

return;
</code></pre>
<p>And the error is:</p>
<blockquote>
<p>First-chance exception at 0x0F993FD4 (msvcr120d.dll) in ttool.exe: 0xC0000005: Access violation writing location 0x00000000.</p>
<p>Unhandled exception at 0x0F993FD4 (msvcr120d.dll) in ttool.exe: 0xC0000005: Access violation writing location 0x00000000.</p>
</blockquote>
<p>I tried this as an 32-bit application but also 64-bit application and the result was the same. Also i tried /LARGEADRESSAWARE option for the linker. However i could not find a solution.</p>
<p>I know it may be about how much RAM i am using but when i using 3.02GB RAM and try to allocate 2GB, it crashes too.</p>
<p>How can i solve this problem?</p>