Community
cancel
Showing results for 
Search instead for 
Did you mean: 
aurora_s
Beginner
110 Views

Memory allocation and virtual memory

Hi,
I have a question about memory reservation. If I run my test application main.cpp in 32 bits11.1.070 [IA-32], the output its an out of memory in the moment that I ask for more memory than 2gb.
In 64 bits (same compiler version), the SO starts to allocate memory and when it reaches the maximum of my computer (8gb), it gets hanged competely when paging (I suppose).
How can I achieve to return an "out of memory" error instead of using unlimited virtual memory and hang my computer?
Thanks in advance!
main.cpp
0 Kudos
5 Replies
JenniferJ
Moderator
110 Views

is this on Linux? we tried on Windows, it works as expected.

please post your compile and link options as well.

thanks,
Jennifer
110 Views

Hi,

at the moment the memory limit of a 64 bit process is out of reach. So you will not get an out of memory exception until all the virtual memory is used completely. Normally the OS starts paging if the physical memory is short and the system behaves really slow.

If you want to avoid that, you have several options. One would be to query the OS about the free physical memory. Check if the amount is below a certain threshold and then throw an out of memory exception.
To check the memory you can use the following APIs:
Windows*: http://msdn.microsoft.com/en-us/library/aa366589%28VS.85%29.aspx
Linux: Read /proc/meminfo

Thanks,
Alex

aurora_s
Beginner
110 Views

Which are the other options?
I've reproduced that it in Win7 64 bits with the default release/debug options of visual studio 2008.
This issue is being investigated in the premier support (issue number638135) since July, but now I want to know if are there any alternatives
Thanks!
Om_S_Intel
Employee
110 Views

I tried your test case. It works as expected in Windows7 64 bit version, Intel 64, using VS2010 and icl 12.0.

c:\forum\U84518>icl /EHsc maincpp.cpp

Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Ve

rsion 12.0.5.221 Build 20110719

Copyright (C) 1985-2011 Intel Corporation. All rights reserved.

maincpp.cpp

Microsoft Incremental Linker Version 10.00.40219.01

Copyright (C) Microsoft Corporation. All rights reserved.

-out:maincpp.exe

maincpp.obj

c:\forum\U84518>maincpp.exe

Out of memory with i=25742.... 1627Mb/37636Mb

Press any key to continue . . .

aurora_s
Beginner
110 Views

So its a bug solved in version 12? I use11.1.070 64 bits
Reply