Click here to Skip to main content
15,915,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Suppose I have 3 gb of ram and 250 gb hard disk in my pc.
Now I wrote a simple C program having only one statement malloc() to allocate 4 gb of memory as 32 bit os can address 4gb address space then will the malloc succeed?
If yes then how it will get extra 1 gb of memory?
Does the process gets memory only from RAM or also from harddisk?
Posted
Updated 30-Nov-11 0:00am
v2

Hi,

When the requested memory is higher than RAM size, The OS uses virtual memory technique.
take a look at this artical:
Virtual_memory[^]


Best regards.
EL GAABEB.
 
Share this answer
 
v2
Usually heap size is lower than 4 Gb, see, for instance "Why can't I get a larger heap with the 32-bit JVM?"[^].
The process gets virtual memory that is partly mapped on the hard-disk, see "How Virtual Memory Works"[^].
 
Share this answer
 
Comments
rupeshkp728 1-Dec-11 2:50am    
Thanks pallini for the link.
CPallini 1-Dec-11 4:21am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900