`
ggsonic
  • 浏览: 260129 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

linux process memory

 
阅读更多


    How Does a Process Use Memory?

        When a process starts, the operating system allocates the amount of memory the process requires to run. Each process has four memory segments for executable code and data. The "code" segment contains the executable instructions. The "data" segment contains static and global variables. The "stack" contains local variables. The "heap" contains dynamically allocated objects. Processes may use shared libraries. Shared libraries are only loaded into memory once, and all processes using a particular shared library will use that copy.
    What Memory Statistics Does Linux Report?

        Virtual memory is the total amount of the address space reserved by the operating system to the process for its code, data and stack. The virtual memory size reported by Linux includes all the code, data and stack space reserved for use by a process, on both physical memory and swap space. This value includes space used by all shared libraries used by the process. The implication of this is that shared libraries count in full towards the size of a given process.

        The resident memory size of a process reported by Linux includes only the amount of physical memory the process and the shared libraries it references are using at a given time. Segments moved to swap space are not included. Like with virtual memory size, resident memory size includes the space used by shared libraries.
    Viewing a Simple Process Snapshot with ps

        The ps utility provides a snapshot of processes running on the system, reporting the virtual and resident memory size, CPU and memory percentages, and a wide variety of other information. To examine a single process, use the following options to ps, including vsz for the virtual memory size, and rss for the resident memory size. For example,

        ps p 3746 o pid,rss,vsz,comm

        outputs for process 3746:

        PID RSS VSZ COMMAND
        3746 14444 351216 httpd2
    Monitoring Processes with top
        The top utility customized to display process memory usage. Deborah Lee Soltesz

        The top utility provides a live view of system performance. To monitor one or more specific processes with top, use the --p option to provide a list of process IDs. For example:

        top -p 3746,6100,28753,23176,25544

        After launching top, hit the command key "f" to access the column selection screen. Turn on the display for the PID, VIRT, RES, SHR, SWAP, CODE, DATA, and COMMAND columns. As illustrated in the screen shot, the display now shows the following memory statistics:

        VIRT: Virtual memory size
        RES: Resident memory size
        SHR: Shared memory size
        SWAP: Swapped size
        CODE: Code size in physical memory
        DATA: Data plus stack size in physical memory
    Peeking in /proc

        Detailed status and process memory usage information can be found in /proc/<pid>/status and /proc/<pid>/smaps. A variety of information is contained in /proc/<pid>/status, including these memory statistics:

        VmPeak: Peak virtual memory size
        VmSize: Virtual memory
        VmData: Data segment size
        VmStk: Stack size
        VmExe: Executable segment size
        VmLib: Library code size

        /proc/<pid>/smaps provides a very detailed view of a process' memory usages, broken down by mapping for code, stack, heap and each shared library. The complete output of smaps is rather lengthy and difficult to digest. You can use the Linux:Smaps Perl module to parse and process the smaps file.


Read more: How Much Linux Memory is Used by a Process? | eHow.com http://www.ehow.com/about_5497321_much-linux-memory-used-process.html#ixzz2ABgUaeIA
分享到:
评论

相关推荐

    The Art of Memory Forensic

    The next era of malware and security breaches are more sophisticated and targeted, and the volatile memory of a computer is often overlooked or destroyed as part of the incident response process....

    Learning.Linux.Binary.Analysis.1782

    Insights into UNIX and Linux memory infections, ELF viruses, and binary protection schemes Book Description Learning Linux Binary Analysis is packed with knowledge and code that will teach you the ...

    The Linux Programming Interface

    A Linux and UNIX® System Programming Handbook Chapter 1: History and Standards Chapter 2: Fundamental Concepts Chapter 3: System Programming Concepts Chapter 4: File I/O: The Universal I/O Model ...

    Linux Kernel Development, 3rd Edition.pdf

    Specific topics covered include process management, scheduling, time management and timers, the system call interface, memory addressing, memory management, the page cache, the VFS, kernel ...

    GNU Linux Application Programming

    shared memory, message queues, semaphores, POSIX, file handling, sockets, and more Provides detailed discussion of scripting and integration with the GNU/Linux environment with bash, including ...

    linux kernel development 3rd edition

    Specific topics covered include process management, scheduling, time management and timers, the system call interface, memory addressing, memory management, the page cache, the VFS, kernel ...

    The Art of Memory Forensics

    The next era of malware and security breaches are more sophisticated and targeted, and the volatile memory of a computer is often overlooked or destroyed as part of the incident response process....

    The Art of Linux Kernel Design

    Examines the relationship between process and memory, memory and file, file and process, and the kernel Explores the essential association, preparation, and transition, which is the vital part of ...

    linux驱动开发的好书,老外写的

    Prentice.Essential Linux Device Drivers.2008 一个老外写的,写的非常详细 Chapter 1. Introduction Evolution The GNU Copyleft Kernel.org Mailing Lists and Forums Linux Distributions Looking at ...

    Linux System Programming

    of memory, such as the process address space and the page, and continues with a discussion of the interfaces for obtaining memory from and returning memory to the kernel. The chapter concludes with a ...

    Linux系统编程

    of memory, such as the process address space and the page, and continues with a discussion of the interfaces for obtaining memory from and returning memory to the kernel. The chapter concludes with a ...

    Understand Linux Kernel 2nd.pdf

    The new edition of Understanding the Linux Kernel takes you ...challenge of providing good system response during process scheduling, file access, and memory management in a wide variety of environments.

    Learning Linux Binary Analysis(PACKT,2016)

    You will learn about process tracing, and will explore the different types of Linux and UNIX viruses, and how you can make use of ELF Virus Technology to deal with them. The latter half of the book ...

    Understanding the Linux Kernel, 2nd Edition

    You'll learn what conditions bring out Linux's best performance, and how it meets the challenge of providing good system response during process scheduling, file access, and memory management in a ...

    Linux System Programming, 2nd edition.pdf

    A Linux kernel, C library, and C compiler overview Basic I/O operations, such as reading from and writing to files Advanced I/O interfaces, memory mappings, and optimization techniques The family of ...

    Professional_Linux_Programming.pdf

    The Linux Development Process 19 Working with Sources 20 Configuring to the Local Environment 21 Building the Sources 22 Components of the GNU Toolchain 23 The GNU Compiler Collection 23 The GNU ...

    Essential Linux Device Drivers

    Linux Distributions Looking at the Sources Building the Kernel Loadable Modules Before Starting Chapter 2. A Peek Inside the Kernel Booting Up Kernel Mode and User Mode Process Context and ...

    深入理解LINUX内核(影印版)(第3版)

    Preface The Audience for This Book Organization of the Material Level of Description Overview of the Book ...Research Papers Related to Linux Development About the Authors Colophon Index

    Essential Linux-DeviceDrivers

    It first takes you through the boot process and then describes kernel services particularly relevant to driver development such as kernel timers, concurrency management, and memory allocation. ...

    Mastering Embedded Linux Programming

    You will then learn how to use the two most commonly used build systems, Buildroot and Yocto, to speed up and simplify the development process. Building on this solid base, the next section considers...

Global site tag (gtag.js) - Google Analytics