Sunteți pe pagina 1din 16

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the SolarisTM OS

Hae Hirdler May 2003 (originally published on Access1) Sun Microsystems, Inc.

Copyright 2007 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved. U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms. This distribution may include materials developed by third parties. Parts of the product may be derived from Berkeley BSD systems, licensed from the University of California. UNIX is a registered trademark in the U.S. and in other countries, exclusively licensed through X/Open Company, Ltd. X/Open is a registered trademark of X/Open Company, Ltd. Sun, Sun Microsystems, the Sun logo, and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This product is covered and controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited. DOCUMENTATION IS PROVIDED "AS IS" AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

Table of Contents
Introduction................................................................................................................................................4 Theoretical Concepts..................................................................................................................................4 Step 1 ...............................................................................................................................................4 Step 2................................................................................................................................................5 Sample Code..............................................................................................................................................5 Tests...........................................................................................................................................................6 Results........................................................................................................................................................7 Case 1. The global array of 2 Mbyte ...............................................................................................7 Case 2. A local array of 1 Mbyte Defined in the main() Function ..............................................7 Case 3. A local array of 1 Mbyte Defined in a Function..................................................................7 Case 4. A malloc Process of 1 Mbyte...........................................................................................7 Case 5. An mmap(MAP_PRIVATE) Process of 1 Mbyte ..............................................................7 Case 6. An mmap(MAP_PRIVATE | MAP_NORESERVE) Process of 1 Mbyte........................7 More on mmap(MAP_PRIVATE) Versus mmap(MAP_PRIVATE | MAP_NORESERVE) ......8 Concepts: mmap(MAP_PRIVATE) Versus mmap(MAP_PRIVATE | MAP_NORESERVE) ...8 mmap MAP_RESERVE Flag ...........................................................................................................8 The Sample test.cpp File.....................................................................................................................8 The Sample out File...............................................................................................................................11

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

Introduction
This article is for developers interested in understanding process address space consumption and its mappings in response to memory requests in executing code. In addition, the article also explains physical memory and swap consumption in relation to the above-mentioned memory requests. In order to supplement the information found in the man pages, code examples and shell commands have been included to demonstrate these functions and to explain their inner workings. The sample code in this article illustrates the concepts discussed here. It shows the ways in which a process occupies its address space when different memory requests are executed. In this sample code, we demonstrate the use of global array, local array, malloc, mmap(MAP_PRIVATE), and mmap(MAP_PRIVATE|MAP_NORESERVE).We use pmap -x as a tool to show the executing process's address space consumption and its mapping, step by step. We use swap -s as a tool to show swap space consumption.

Theoretical Concepts
Step 1
Let's consider the following memory requests in the code. Listed here are six different cases of memory requests:

Case 1. A global array of 2 Mbyte Case 2. A local array of 1 Mbyte defined in the main() function Case 3. A local array of 1 Mbyte defined in a function other than main() Case 4. A malloc process of 1 Mbyte Case 5. An mmap(MAP_PRIVATE) process of 1 Mbyte Case 6. An mmap(MAP_PRIVATE|MAP_NORESERVE) process of 1 Mbyte

The outcome of this code execution will result in the following with respect to the process's virtual address space mapping, system memory, and swap consumption: All of the above memory requests will consume the process's virtual address (VA) space by the sizes requested. The virtual address space of the process is limited to 4GB in the 32-bit operating environment. What is actually available to the executing code is a lot less, since there are other virtual address mappings, such as kernel mapping, done to the process by default. All of the above memory requests except for Case 6 will reserve swap space. Any data (arrays, and so on) allocated on stack or through malloc will cause swap reservation for that process. This consumption is swap reservation only; there is no actual swap allocation yet. The SolarisTM Operating System ensures that all memory requests which returned with success will result in memory being available when it is to be used. This is done by reserving swap space up front, when the request is made. If your code requests a large amount of memory, even if it is not being used later, the Solaris OS will reduce that same amount from swap. Thus, this will reduce the overall amount of memory available (system memory + swap) in the system, and could inadvertently prevent other processes from acquiring the needed memory.
Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS 4

For mmap(MAP_PRIVATE), in Case 6, the memory request with MAP_NORESERVE can be used to avoid swap reservation. However, when you do this, the Solaris OS does not guarantee that the memory you have requested will actually be available when you need to use it. Regarding the mmap() flag options: MAP_SHARED will not reserve swap. MAP_PRIVATE (writable) will reserve swap. MAP_PRIVATE | MAP_NORESERVE will not reserve swap. In the case of a memory shortage, a SIGBUS or SIGSEGV will be generated; your code needs to handle this failure.

Step 2
Let's consider that, from the above memory requests, we use the requested memory by touching the first 20 pages and the last page. The result will be as follows: There should be no increase in the process's virtual address space with this operation, since it was already consumed in the earlier memory requests. The amount touched, and in turn, the number of physical pages brought into memory as a result of the memory touch operation (either read or written to the process's virtual memory location), will be shown under the RSS (Resident Set Size) section in the pmap -x command. Also, the same amount of swap allocation for RSS will take place. This swap allocation is consumed from the amount of swap reservation reserved during the earlier memory request (in Step 1), except for Case 6. Since the Case 6 memory request did not reserve swap space up front, it will start using (allocating) swap space as the pages are touched and brought in. If an actual swap occurs, the swap allocation amount will be used to swap out the RSS pages. The Solaris OS keeps track of this swap-out amount using the anon Solaris kernel structure. The anon pages with a non-NULL pointer to the swap space are the actual swapped out pages.

Sample Code
The sample code, test.cpp, included in this article, and the output generated by executing the code, reinforce the concepts discussed from this point forward. This code will generate a file called out. We suggest you compare the sample code with its output, and read the explanation here, step by step.

To compile: CC -o test test.cpp To run: ./test To view the result: screen output + out file

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

Tests
% ./test This will result in the following virtual address space mapping:
/usr/bin/pmap -x 27228: Address 00010000 00020000 00022000 00220000 FEF00000 FF080000 FF200000 FF2BA000 FF2C0000 FF310000 FF330000 .1 FF340000 FF366000 FF370000 FF388000 FF38C000 FF3A0000 FF3B0000 FF3C0000 FF3F6000 FF9FE000 total Kb 96 8 40 16 16 8 8 152 8 2056 8296 72 8 40 16 8 8 152 8 2056 3744 8 16 8 8 2056 2792 - r-x-- rwx-- r-x-- rwx-- rwx-- r-x-- rwx-- r-x-- rwx-- rwx-libm.so.1 libm.so.1 libCrun.so.1 libCrun.so.1 libCrun.so.1 libw.so.1 [ anon ] ld.so.1 ld.so.1 [ stack ] ./test Kbytes 8 8 2040 1048 1024 1024 680 24 8 16 8 RSS 8 8 152 184 160 160 648 24 8 16 8 Anon 8 152 184 160 160 24 8 Locked Mode - r-x-- rwx-- rwx-- rwx-- rw--R - rw--- r-x-- rwx-- rwx-- r-x-- r-x-Mapped File test test test [ heap ] dev:32,56 ino:390102 dev:32,56 ino:390102 libc.so.1 libc.so.1 libc.so.1 libc_psr.so.1 libdl.so 27228

-------- ------- ------- ------- -------

Each mapping as marked under the Address column shows the virtual address of the first page of each mapping. The Kbytes column shows the size of the mapping. The RSS column shows how many pages out of the virtual mapping are currently resident in memory. This comes as a result of touching (writing to) the virtual address space. Thus, this creates a real mapping between the virtual page and the physical page. The Anon column shows backup storage in the event that the physical pages need to be swapped out. The Anon amounts are the actual swap allocations for these physical pages.

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

The Locked column shows the physical memory locking; no swap out will occur for these locked pages. They are guaranteed to remain in physical memory. The Mode column shows the permissions and flags of the mapping. That is, if you use mmap() with the MAP_NORESERVE flag, you will see the R flag under the Mode column. The Mapped File column is broken down into the separate segments that make up and process a virtual address itself.

Results
Case 1. The global array of 2 Mbyte
This gets mapped to the executable-data section. A 2 Mbyte global array will consume 2 Mbyte of the process's virtual address mapping. The mapping starts at 00022000 in this example. Until the pages are actually touched, the physical memory page is not used and the swap remains as reserved (not allocated). Once pages are touched, you will see an increase in RSS and Anon.

Case 2. A local array of 1 Mbyte Defined in the main() Function


This gets mapped to the stack section (FFAFE000). The stack address space mapping can grow up to the maximum stack size configured in the system (by default, it is 8MB per process; run the limit command from your system to see what your limit is set to).

Case 3. A local array of 1 Mbyte Defined in a Function


We created another local array in a function other than the main() function simply to show the mapping before and after the function enters/exits. This gets mapped to the stack section (FF9FE000). Please note that the mapping in the stack will remain mapped unless there is a memory shortage later.

Case 4. A malloc Process of 1 Mbyte


The 1M malloc shows a 1 Mbyte process's VA space consumption, and is mapped to heap section 00220000. As virtual addresses are touched, the physical pages will be brought in and will be seen in RSS and Anon increases.

Case 5. An mmap(MAP_PRIVATE) Process of 1 Mbyte


The mmap shows a 1 Mbyte process's VA space consumption, and is mapped under the file inode we opened (FF080000). As virtual addresses are touched, the physical pages will be brought in and will be seen in RSS and Anon increases.

Case 6. An mmap(MAP_PRIVATE | MAP_NORESERVE) Process of 1 Mbyte


mmap() with the MAP_NORESERVE flag shows mapping to the file inode we opened (FEF00000). The R flag under Mode indicates the MAP_NORESERVE flag. As virtual addresses are touched, the physical pages will be brought in and will be seen in RSS and Anon increases.

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

More on mmap(MAP_PRIVATE) Versus mmap(MAP_PRIVATE | MAP_NORESERVE)


It's worthwhile to note a bit more about the mmap flag MAP_NORESERVE to reinforce our points on swap reservation. In order to supplement the preceding information, extra testing was run to explain what takes place. When running this test, you will note that, for the same mapping size, mmap(MAP_PRIVATE) will fail, but mmap(MAP_PRIVATE | MAP_NORESERVE) will not. If you do not see this from the sample code, you need to change the TOOBIG_SIZE in the code to a value larger than your current swap availability.

Concepts: mmap(MAP_PRIVATE) Versus mmap(MAP_PRIVATE | MAP_NORESERVE)


There is no difference in a process's virtual address mapping between the two (as seen in pmap -x, except for the R notification under Mode). However, swap -s will show the difference between the two mappings: mmap(MAP_PRIVATE) will reduce the swap availability but, with the MAP_NORESERVE flag, it will not. The TOOBIG_SIZE defined in the code demonstrates this. This value needs to be changed according to your system's swap configuration. For example, in a system with 562 Mbyte of swap availability, asking for a 1GB writable private mapping without the MAP_NORESERVE flag will return failure. % ./a.out COMMAND: /usr/bin/pmap -x 2693 >> out See the out file for results.

mmap MAP_RESERVE Flag


Try asking for mapping beyond what your system can reserve, and observe the mmap(MAP_PRIVATE) failure unless MAP_NORESERVE is specified. Your current mmap size is: 1048576000 Your swap availability shown by '/usr/sbin/swap -s' is: total: 40352k bytes allocated + 9544k reserved = 49896k used, 562952k available Trying mmap()... mmap failed as expected. errno: Resource temporarily unavailable Trying mmap(MAP_NORESERVE)... It did not fail. This is expected for MAP_NORESERVE.

The Sample test.cpp File


//To compile: CC test.cpp #include #include #include #include <stdio.h> <stdlib.h> <sys/types.h> <sys/stat.h>

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

#include #include #include #include #include #define #define #define #define #define #define #define

<fcntl.h> <unistd.h> <sys/mman.h> <string.h> <errno.h> ONE_M (1024 * 1024) TOOBIG_SIZE (ONE_M * 1000) GLOBAL_SIZE (ONE_M * 2) LOCAL_SIZE ONE_M MALLOC_SIZE ONE_M MMAP_SIZE ONE_M mapfile "/usr/tmp/mem.mem"

//CASE #1 char global_array[GLOBAL_SIZE]; size_t page_size = getpagesize(); void use_local_array(char *local_array) { } local_array[0] = local_array[LOCAL_SIZE -1] = 'E';

void create_local_array(char *command) { char local_array[LOCAL_SIZE]; use_local_array(local_array); system(command);

void touch_pages(char *array, int size) { array[size - 1] = 'A'; for( int indx = 20; indx--; ) { array[indx * page_size + 1] = 'D'; }

int open_file_to_size() { int fd; remove(mapfile); if (-1 == (fd = open(mapfile, (O_RDWR | O_CREAT), (S_IRUSR | S_IWUSR)))) { printf( "ERROR: open failed..." ); exit(EXIT_FAILURE); } if( -1 == ftruncate(fd, ONE_M * 500)) { printf("ERROR: ftruncate failed..."); exit(EXIT_FAILURE); } return(fd);

void put_heading(FILE *fname, const char *heading) { fprintf(fname, heading); fflush(fname); } int main( int argc, char *argv[] ) { //CASE #2 char local_array_main[LOCAL_SIZE]; remove("out"); FILE *fname = fopen("out", "a"); int pid = getpid(); char command[50]; sprintf(command,"/usr/bin/pmap -x %d >> out", pid); printf("COMMAND: %s\n", command);

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

//MAPPING OF GLOBAL ARRAY AND LOCAL ARRAY IN MAIN() const char *case_12 = "MAPPINGS Per /USR/BIN/PMAP -X <PID>\n\n" \ "2M Global Array in the Executable-data (test)\n" \ "1M Local Array from main() in the Stack.\n"; put_heading(fname, case_12); system (command); //CASE #3 - MAPPING OF LOCAL ARRAY IN FUNCTION const char *case_3= "\n1M Local Array in function mapped in the Stack\n"; put_heading(fname, case_3); create_local_array(command); const char *case_3_after= "\n1M Local Array remains mapped in the Stack" \ " after return.\n"; put_heading(fname, case_3_after); system(command); //CASE #4 - MAPPING OF MALLOC const char *case_4 = "\n1M Malloc Request in Heap.\n"; put_heading(fname, case_4); char *malloc_memory; if (0 == (malloc_memory = (char *) malloc(MALLOC_SIZE))) { printf( "ERROR: malloc failed..." ); exit(EXIT_FAILURE); } system (command); //CASE #5 - MAPPING OF MMAP() const char *case_5_open = "\n1M File Open - no change in mapping.\n"; put_heading(fname, case_5_open); int fd; fd=open_file_to_size(); system (command); const char *case_5 = "\n1M Mmap(MAP_PRIVATE) Request on File.\n"; put_heading(fname, case_5); char *mem_mmap; if (MAP_FAILED == (mem_mmap = (char *) mmap( 0, (MMAP_SIZE), (PROT_WRITE | PROT_READ), MAP_PRIVATE, fd, 0 ))) { printf( "ERROR: mmap of 1 MB failed..." ); exit(EXIT_FAILURE); } system (command); //CASE #6 - MAPPING OF MMAP(MAP_NORESERVE) char *mem_mmap_NR; if (MAP_FAILED == (mem_mmap_NR = mmap( 0, (MMAP_SIZE), (PROT_WRITE | PROT_READ), (MAP_PRIVATE | MAP_NORESERVE), fd, 0 ))) { printf("ERROR: mmap of 1 MB with MAP_NORESERVE failed..."); exit(EXIT_FAILURE); } const char *case_6 = "\n1MB Mmap with MAP_NORESERVE Request on File.\n"; put_heading(fname, case_6); system (command); // ALL MEMORY DEFINED, NOW PERFORM TOUCH OPERATIONS... fflush( NULL ); const char *touch_1 = "\nTouch first 20 & last pages of global_array.\n"; put_heading(fname, touch_1); touch_pages(global_array, GLOBAL_SIZE); system (command); const char *touch_2 = "\nTouch first 20 & last pages of local_array in main.\n"; put_heading(fname, touch_2); touch_pages(local_array_main, LOCAL_SIZE); system (command); const char *touch_3 = "\nTouch first 20 & last pages of malloc memory.\n";

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

10

put_heading(fname, touch_3); touch_pages(malloc_memory, MALLOC_SIZE); system (command); const char *touch_4 = "\nTouch first 10 pages of mmaped(MAP_PRIVATE) memory.\n"; put_heading(fname, touch_4); touch_pages(mem_mmap, 1); system (command); const char *touch_5 = "\nTouch first 10 pages of mmaped(MAP_NORESERVE) memory.\n"; put_heading(fname, touch_5); touch_pages(mem_mmap_NR, 1); system (command); // ALL DONE, NOW ABOUT SWAP RESERVATION... printf("\n See the out file for results\n\n"); printf("MMAP MAP_RESERVE FLAG \n\n"); printf(" Ask for mapping beyond your system can reserve and\n"); printf(" observe mmap(MAP_PRIVATE) failure unless MAP_NORESERVE" \ " flag is specified.\n\n"); printf(" Your mmap size (see TOOBIG_SIZE in the code) is: %d\n",TOOBIG_SIZE); printf(" your swap availability shown by '/usr/sbin/swap -s' is:\n\n"); system("/usr/sbin/swap -s"); printf("\n\n Trying mmap()...\n"); if (MAP_FAILED == (mem_mmap = (char *) mmap( 0, (TOOBIG_SIZE), (PROT_WRITE| PROT_READ), MAP_PRIVATE, fd, 0 ))) { printf(" Mmap failed as expected.\n"); char *myerr = strerror(errno); printf(" errno: %s\n", myerr); } else { printf(" It did not fail. Check your swap availability.\n" \ " Maybe it needs a bigger size mapping to fail.\n"); printf(" Change TOOBIG_SIZE in the test code bigger than the " \ "available\n swap shown the above.\n\n"); system("/usr/sbin/swap -s"); } printf("\n\n Trying with MAP_NORESERVE flag...\n"); if (MAP_FAILED == (mem_mmap_NR = mmap( 0, (MMAP_SIZE), (PROT_WRITE | PROT_READ), (MAP_PRIVATE | MAP_NORESERVE), fd, 0 ))) { printf(" Mmap should have worked. Maybe other problem. " \ "Check the errno.\n"); char *myerr = strerror(errno); printf(" errno: %s\n", myerr); } else { printf(" It did not fail. This is expected for MAP_NORESERVE.\n"); } return (EXIT_SUCCESS); }

The Sample out File


MAPPINGS Per /USR/BIN/PMAP -X 2M Global Array in the Executable-data (test) 1M Local Array from main() in the Stack. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 - rwx-- test 00220000 24 24 24 - rwx-[ heap ] FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

11

FF310000 16 16 FF330000 8 8 FF340000 96 72 FF366000 8 8 8 FF370000 40 40 FF388000 16 16 16 FF38C000 16 FF3A0000 8 8 FF3B0000 8 8 8 FF3C0000 152 152 FF3F6000 8 8 8 FFAFE000 1032 1032 1032 -------- ------- ------- ------- ------total Kb 4200 2088 1136 -

r-x-r-x-r-x-rwx-r-x-rwx-rwx-r-x-rwx-r-x-rwx-rwx--

libc_psr.so.1 libdl.so.1 libm.so.1 libm.so.1 libCrun.so.1 libCrun.so.1 libCrun.so.1 libw.so.1 [ anon ] ld.so.1 ld.so.1 [ stack ]

1M Local Array in function mapped in the Stack 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 - rwx-- test 00220000 24 24 24 - rwx-[ heap ] FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 5224 3112 2160 1M Local Array remains mapped in the Stack after return. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 - rwx-- test 00220000 24 24 24 - rwx-[ heap ] FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 5224 3112 2160 1M Malloc Request in Heap.

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

12

5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 - rwx-- test 00220000 1048 40 40 - rwx-[ heap ] FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 6248 3128 2176 1M File Open - no change in mapping. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 - rwx-- test 00220000 1048 40 40 - rwx-[ heap ] FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 6248 3128 2176 1M Mmap(MAP_PRIVATE) Request on File. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 - rwx-- test 00220000 1048 40 40 - rwx-[ heap ] FF080000 1024 - rw--- dev:32,56 ino:390102 FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

13

FF38C000 16 FF3A0000 8 8 FF3B0000 8 8 8 FF3C0000 152 152 FF3F6000 8 8 8 FF9FE000 2056 2056 2056 -------- ------- ------- ------- ------total Kb 7272 3128 2176 -

rwx-r-x-rwx-r-x-rwx-rwx--

libCrun.so.1 libw.so.1 [ anon ] ld.so.1 ld.so.1 [ stack ]

1MB Mmap with MAP_NORESERVE Request on File. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 - rwx-- test 00220000 1048 40 40 - rwx-[ heap ] FEF00000 1024 - rw--R dev:32,56 ino:390102 FF080000 1024 - rw--- dev:32,56 ino:390102 FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 8296 3128 2176 -

Touch first 20 & last pages of global_array. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 152 152 - rwx-- test 00220000 1048 40 40 - rwx-[ heap ] FEF00000 1024 - rw--R dev:32,56 ino:390102 FF080000 1024 - rw--- dev:32,56 ino:390102 FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 8296 3280 2328 Touch first 20 & last pages of local_array in main. 5472: ./test

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

14

Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 152 152 - rwx-- test 00220000 1048 40 40 - rwx-[ heap ] FEF00000 1024 - rw--R dev:32,56 ino:390102 FF080000 1024 - rw--- dev:32,56 ino:390102 FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 8296 3280 2328 Touch first 20 & last pages of malloc memory. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 152 152 - rwx-- test 00220000 1048 184 184 - rwx-[ heap ] FEF00000 1024 - rw--R dev:32,56 ino:390102 FF080000 1024 - rw--- dev:32,56 ino:390102 FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 8296 3424 2472 Touch first 10 pages of mmaped(MAP_PRIVATE) memory. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 152 152 - rwx-- test 00220000 1048 184 184 - rwx-[ heap ] FEF00000 1024 160 - rw--R dev:32,56 ino:390102 FF080000 1024 160 160 - rw--- dev:32,56 ino:390102 FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

15

FF340000 96 72 FF366000 8 8 8 FF370000 40 40 FF388000 16 16 16 FF38C000 16 FF3A0000 8 8 FF3B0000 8 8 8 FF3C0000 152 152 FF3F6000 8 8 8 FF9FE000 2056 2056 2056 -------- ------- ------- ------- ------total Kb 8296 3744 2632 -

r-x-rwx-r-x-rwx-rwx-r-x-rwx-r-x-rwx-rwx--

libm.so.1 libm.so.1 libCrun.so.1 libCrun.so.1 libCrun.so.1 libw.so.1 [ anon ] ld.so.1 ld.so.1 [ stack ]

Touch first 10 pages of mmaped(MAP_NORESERVE) memory. 5472: ./test Address Kbytes RSS Anon Locked Mode Mapped File 00010000 8 8 - r-x-- test 00020000 8 8 8 - rwx-- test 00022000 2040 152 152 - rwx-- test 00220000 1048 184 184 - rwx-[ heap ] FEF00000 1024 160 160 - rw--R dev:32,56 ino:390102 FF080000 1024 160 160 - rw--- dev:32,56 ino:390102 FF200000 680 648 - r-x-- libc.so.1 FF2BA000 24 24 24 - rwx-- libc.so.1 FF2C0000 8 8 8 - rwx-- libc.so.1 FF310000 16 16 - r-x-- libc_psr.so.1 FF330000 8 8 - r-x-- libdl.so.1 FF340000 96 72 - r-x-- libm.so.1 FF366000 8 8 8 - rwx-- libm.so.1 FF370000 40 40 - r-x-- libCrun.so.1 FF388000 16 16 16 - rwx-- libCrun.so.1 FF38C000 16 - rwx-- libCrun.so.1 FF3A0000 8 8 - r-x-- libw.so.1 FF3B0000 8 8 8 - rwx-[ anon ] FF3C0000 152 152 - r-x-- ld.so.1 FF3F6000 8 8 8 - rwx-- ld.so.1 FF9FE000 2056 2056 2056 - rwx-[ stack ] -------- ------- ------- ------- ------total Kb 8296 3744 2792 -

Licensing Information
Unless otherwise specified, the use of this software is authorized pursuant to the terms of the license found at http://developers.sun.com/berkeley_license.html

Process Memory Requests: Process Virtual Address Space, Memory, and Swap in the Solaris OS

16

S-ar putea să vă placă și