Question

If i have a 500 MB RAM and a program which uses malloc to allocate 600 MB memory .
What will happen , will it be allocated using the concept of virtual memory or not , if yes how?

Était-ce utile?

La solution

You do not always have available disk space for virtual memory, but in general, the answer is yes, it is getting there. The operating system will do the paging for you, e.g. in the swap partition created on Linux.

Either way, you could run out of memory, and if that is any concern, you should check against that in your application.

Please note that it is much slower to do disk I/O though than reading and writing real RAM memory.

I think this should get you going:

What is virtual memory?

Virtual memory combines your computer’s RAM with temporary space on your hard disk. When RAM runs low, virtual memory moves data from RAM to a space called a paging file. Moving data to and from the paging file frees up RAM so your computer can complete its work.

Autres conseils

In worst case Windows will warn You about running out memory and will automatically shutdown most expensive programs. Windows use swapping to "save" programs with are not being used for now but it's still in RAM.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top