CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Location
    Denver
    Posts
    353

    Obtaining process size

    Does anyone know how to "programmatically" obtain the size of a process in memory on a Solaris 8 operating system? What I'm trying to do is obtain something similar to what you get from the "top" or "pmap" shell command. I do not want to run a system command and parse the results either. From what I've learned so far, there is a /proc directory with this type of information (containing subdirectories of the process id's for all the processes running). I've been able to read the various files contained within the subdirectory of interest for the process I'm experimenting with and I've filled the appropriate structures (I think) from the procfs.h header file. I'm pretty sure I'm reading these files correctly because I've successfully confirmed some of the data (like the pid and ppid for instance). I'm also fairly sure the file I'm really interested in is the psinfo file. My problem is every time I read this file from within my process, and then examine the process size, I always get 4,294,967,296 bytes (which is 4 GB, which is the "max" size of a 32 bit process, not the current size as it's running). I know the process doesn't start that large because I can monitor it with the "top" command and watch as it grows. In fact, it starts very small and eventually grows to 4 Gigs after about 15 minutes. I don't understand why I don't get the same results from within my process by reading these /proc files periodically. I'm either reading the wrong file, or I don't understand what I'm really doing. I've found very little information on this online, and the man pages don't really tell you what files are associated with which structures in the procfs.h header file. It's mostly been trial and error trying to determine what to read and where to put the results. Is the psinfo file not the correct file? I've also looked at various other files like the "status", "map", and "as" files. If anyone can please help me with this, or at least point me in the right direction, I'd really appreciate it. Thank you.

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Obtaining process size

    It's hard to believe you can find a Solaris8Guru around here.
    However we never know...
    Alternatively, you can try a search: "Solaris 8" + "size of a process".
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured