Howdy,

I ran into a weird issue today while playing around with pmap. In an effort to better understand the memory organization of a process, I created a test program [1] to malloc() memory, and to print the address
where the memory is located. When I run my test program, I get the
following output:

$ ./foo &
Touching memory pages starting at address 209f8
[1] 5890

To see where memory (especially the heap) is located, I ran pmap against the process:

$ pmap -x 5890
5890:   ./foo
 Address  Kbytes     RSS    Anon  Locked Mode   Mapped File
00010000       8       8       -       - r-x--  foo
00020000       8       8       8       - rwx--  foo
00022000    1032    1032    1032       - rwx--    [ heap ]
FF280000     864     808       -       - r-x--  libc.so.1
FF368000      32      32      32       - rwx--  libc.so.1
FF370000       8       8       8       - rwx--  libc.so.1
FF380000       8       8       8       - rwx--    [ anon ]
FF398000      16      16       -       - r-x--  libc_psr.so.1
FF3A0000      24      16      16       - rwx--    [ anon ]
FF3B0000     184     184       -       - r-x--  ld.so.1
FF3EE000       8       8       8       - rwx--  ld.so.1
FF3F0000       8       8       8       - rwx--  ld.so.1
FFBFE000       8       8       8       - rw---    [ stack ]
-------- ------- ------- ------- -------
total Kb    2208    2144    1128       -

If the heap starts at address 22000, how can the chunk of memory I allocated start at address 209f8?

Thanks for any insight,
- Ryan

[1]
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char**argv)
{
    int i;

    char *a = (char *) malloc(1024 *1024);

    printf("Touching memory pages starting at address %0x\n",a);

    for (i = 0; i < 1024 * 1024; i += 8192) {
        a[i] = 23;
    }
    sleep(300);
}
_______________________________________________
opensolaris-code mailing list
[email protected]
https://opensolaris.org:444/mailman/listinfo/opensolaris-code

Reply via email to