Virt, res, SHR, virtual memory and physical memory)

Source: Internet
Author: User

Virt:

1Process"Required"Virtual Memory size, including the database used by the process,Code, Data, andMalloc,NewAllocated heap space and allocated stack space;

2If the process has a new application10 MBMemory, but actually only used1 MB, It will increase10 MBInstead of the actual1 MBUsage.

3,Virt = swap + Res

Res:

1The memory size currently used by the process, includingMalloc,NewAllocated heap space and allocated stack space, but not includingSwap outQuantity;

2, Including sharing of other processes;

3If you apply10 MBMemory, actually used1 MB, It only grows1 MB, AndVirtOpposite;

4Only the memory occupied by the loaded library files is counted.

5,Res = code + Data

SHR:

1In addition to the shared memory of its own processes, it also includes the shared memory of other processes;

2, Although the process only uses several shared library functions, it contains the size of the entire shared library;

3Formula for Calculating the physical memory occupied by a process:Res-SHR;

4,Swap outIt will be downgraded.

Example

# Include <iostream>

 

Int main ()

{

Char * P = new char [1024*1024*512];

Getchar ();

Return 0;

}

Top:

PID user PR Ni virt res shr s % CPU % mem time + command

401 hhhhh 17 0 523 M 916 s 792 0.0. 00./main

Original article:

Http://blog.csdn.net/huyiyang2010/article/details/7815491

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.