memory - Checking the amount of available RAM within a running program -


One of my friends was asked to write a program during a job interview, which measures the amount of available RAM is. The expected response was using malloc () in a binary-search manner: until the failure message is received, the size of the part is reduced, and the amount of memory allocated in a nutshell is large and large Allocation to the part.

I believe that this method will not measure the quantity of virtual, physical, memory, but I find curiosity about this matter.

What is the use of RAM from within the program, asking to do without exec (dmesg | grep -i memory) ?

You are right: malloc () does not make any difference between physical or virtual memory In fact, This is the complete point of virtual memory: to make irrelevant to such details programs.

You can find out but it is OS-specific, for example.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -