In a large system I try to allocate about 1GB of memory on a 4GB system
and it blows up (returns a NULL pointer in C), Now I tried to allocate
1GB from a small test program and it also returns null.
Also, I have implemented the /LARGEADDRESSLIMIT switch on the Linker,
to be able to address more than 2GB RAM. But the system does not want
to allocate 1GB, when the available memory is 1.8GB according to the
Task Manager!!
ex: BYTE *bb=(BYTE*) calloc(0.9, 0x40000000);
where BYTE is unsigned char
I can only allocate about 400MB, otherwise I get NULL
How much memory I can allocate from a C program ?
It looks like there is something I don't quite understand about the x86
memory model.
Memory allocation overflow in c program
Started by bassam_fci, May 19 2009 06:38 AM
4 replies to this topic
#1
Posted 19 May 2009 - 06:38 AM
|
|
|
#2
Posted 19 May 2009 - 07:08 AM
The amount of memory you can allocate will depend on the OS, the hardware, the compiler, and various other parameters. You have given us very little information to help you determine the answer.
#3
Posted 19 May 2009 - 07:22 AM
WingedPanther:
I knew that i didn't give you the whole picture, but my question is specific in the area of:
How can I avoid this problem in c program, with 86x memory system and 4GB of RAM .
I knew that i didn't give you the whole picture, but my question is specific in the area of:
How can I avoid this problem in c program, with 86x memory system and 4GB of RAM .
#4
Posted 19 May 2009 - 07:34 AM
Again, as WingedPanther said, its totally dependent. The language itself has no limitation, bar the limit of an int (32 or 64bits) Now, most OS's are limited to 4GB because they either don't run in long mode or they don't use PAE. Linux provides mmap() which can be used to map and unmap far more memory then is normally available to a single process. Windows provides VirtualAlloc.
Unless you give us more details, we can't give you an exact amount.
Unless you give us more details, we can't give you an exact amount.
#5
Posted 19 May 2009 - 12:15 PM
Thanks a lot WingedPanther & TkTech, I'll try something and if there is any other problem i'll inform you with more details ... thanks again


Sign In
Create Account

Back to top









