Pages

Tuesday, January 17, 2012

Solaris Tip: How-To Identify Memory Mapped Files

A memory mapped (mmap'd) file is a shared memory object, or a file with some portion or the whole file was mapped to virtual memory segments in the address space of an OS process. Here is one way to figure out if a given object (file or shared memory object) was memory mapped in a process or not.

  1. find the file system inode number of the object
  2. look for that inode number in the address space of a given process

And here is an example. We are about to check a log file and a shared memory segment in a Siebel object manager's process address space.

# pfiles 8251
8251:   siebmtshmw /siebel/siebsrvr/admin/Siebel81.isve02.s
..
   1: S_IFREG mode:0744 dev:256,65539 ino:246660 uid:1234 gid:30 size:0
      O_WRONLY|O_APPEND|O_CREAT
      /siebel/siebsrvr/enterprises/Siebel81/isve02/log/StdErrOut/stderrout_8251_23311913.log
...
   9: S_IFREG mode:0700 dev:256,65539 ino:246640 uid:1234 gid:30 size:6889472
      O_RDWR|O_CREAT|O_EXCL
      /siebel/siebsrvr/admin/Siebel81.isve02.shm
..

# pmap -sx 8251 | grep 246660    
#               <== stderrout_8251_23311913.log file was not a memory mapped file

# pmap -sx 8251 | grep 246640
F6400000      64      64       -       -   8K r--s-  dev:256,65539 ino:246640   
F6410000     136     136       -       -    - r--s-  dev:256,65539 ino:246640
F6432000     128     128       -       -   8K r--s-  dev:256,65539 ino:246640
...
                <== Siebel81.isve02.shm was a memory mapped object

No comments:

Post a Comment