(May, 2003)
We want to hear from you! Please send us your FEEDBACK.
The following Technical Article may contain actual software programs in source code form. This source code is made available for developers to use as needed, pursuant to the terms and conditions of this license.
test.cpp
Out File
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 page, 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 adddress 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' address space
consumption,
and its mapping, step by step. We use swap -s as a tool to show
swap space consumption.
Step 1:
Let's consider the following memory requests in the code. Listed herea are six different cases of memory requests:
Case 1. A global array of 2MB
Case 2. A local array of 1MB defined in the main()
function
Case 3. A local array of 1MB defined in a function
other than main()
Case 4. A malloc of 1MB
Case 5. An mmap(MAP_PRIVATE) of 1MB
Case 6. An mmap(MAP_PRIVATE|MAP_NORESERVE) of
1MB
swap consumption:
All of the above memory requests will consume
process' 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, like kernel
mapping, done onto the process by default.
All of the above memory requests except
for Case 6 will reserve swap space. Any data (arrays, etc.)
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 Solaris Operating Environment (OE)
guarantees
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 OE 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.
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 OE 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) |
willreserve 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 process' 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' 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 OE keeps track of this swapout amount the anon Solaris OE
kernel structure. The anon pages with a non-NULL pointer to the
swap space are the actual
"swapped out" pages.
The sample code, test.cpp
included in this article, and the output generated by executing the code,
reinforces 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 |
% ./test
This will result in the following virtual address space mapping:
/usr/bin/pmap -x 27228
27228: ./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 -
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 are the actual swap allocations for
these physical pages.
The Locked column shows the physical memory locking; no swapout 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 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 virtual address itself.
Case 1. The global array of 2 MBs.
This gets mapped to the executable-data
section. A 2MB global array will consume 2MBs of process' 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 1MB 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 1MB 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 of 1MB.
The 1M malloc shows a 1MB process'
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) of 1MB.
The mmap shows a 1MB process
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)
of 1MB.
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.
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 process'
virtual address mapping between the two (as seen in pmap -x, except for
the R notication 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 needs to be changed according to your system's
swap configuration.
For example, in a system with 562MB 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.
//To compile: CC test.cpp
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#include <errno.h>
#define ONE_M (1024
* 1024)
#define TOOBIG_SIZE (ONE_M * 1000)
#define GLOBAL_SIZE (ONE_M * 2)
#define LOCAL_SIZE ONE_M
#define MALLOC_SIZE ONE_M
#define MMAP_SIZE ONE_M
#define 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);
//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";
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");
}
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
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
FFAFE000 1032 1032 1032 - rwx-- [ stack ]
-------- ------- ------- ------- -------
total Kb 4200 2088 1136 -
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.
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
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 7272 3128 2176 -
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
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
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 2632 -
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 -
DOC ID# 1857