Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: How to find process memory consumption on HP-UX 11.11 ?

Re: How to find process memory consumption on HP-UX 11.11 ?

From: Tim Gorman <tim_at_evdbt.com>
Date: 2006-01-06 19:58:21
Message-id: BFE40BDD.30708%tim@evdbt.com


Helmut,

Some time ago, I found an HP-UX system call named ³pstatvm_size()², whose use is illustrated in the following ³C² source:

#define _PSTAT64
#include
#include
#include
#include
#include

void pstatvm(pid)

    int pid;
{

    struct pst_vm_status pst;
    int idx, count;
    long long shared_vm = 0;
    long long shared_ram = 0;
    long long private_vm = 0;
    long long private_ram = 0;

    idx=0;
    count = pstat_getprocvm(&pst, sizeof(pst), (size_t)pid, idx);     while (count > 0) {

        switch ((long)pst.pst_type) {
            case PS_IO: break;
                /* Don't count IO space. It really is not RAM or swap. */
            default:
                if (pst.pst_flags & PS_SHARED) {
                    shared_vm += (long long) pst.pst_length;
                    shared_ram += (long long)pst.pst_phys_pages;
                } else {
                    private_vm += (long long) pst.pst_length;
                    private_ram += (long long)pst.pst_phys_pages;
                } 
                break;
        } 

        idx++; 
        count = pstat_getprocvm(&pst, sizeof(pst), (size_t)pid, idx);
    }
    printf("%d\t\t", pid);
    printf("%lldK\t\t", shared_vm*4);
    printf("%lldK\t\t", shared_ram*4);
    printf("%lldK\t\t", private_vm*4);
    printf("%lldK\n", private_ram*4);

}

void pstatvm_all()
{
#define BURST ((size_t)10)

    struct pst_status pst[BURST];
    int i, count;
    int idx = 0; /* index within the context */

    /* loop until count == 0, will occur when all have been returned */     while ((count = pstat_getproc(pst, sizeof(pst[0]), BURST, idx)) > 0)     {

        /* got count (max of BURST) this time. process them */
        for (i = 0; i < count; i++) {
            if (pst[i].pst_pid==0) continue; /* Can't getprocvm real pid 0
*/ 
            pstatvm(pst[i].pst_pid);
        } 


        /* 
         * now go back and do it again, using the next index after
         * the current 'burst'
         */ 
        idx = pst[count-1].pst_idx + 1;

    }

    if (count == -1)

        perror("pstat_getproc()");

#undef BURST

}

main(argc, argv)

    int argc;
    char *argv[];
{

    int i;
    printf("pid\t\tshared_vm\tshared_ram\tprivate_vm\tprivate_ram\n");     if (argc > 1) {

        for (i=1; i Hi!

> 
> Is there a way to find the exact memory that a dedicated server process is
> using on HP-UX 11.11? If I have 200 dedicated server proceses, I found out
> that the active ones are using about 40 MB of RAM whereas the inactive ones
> were using about 12-15 MB. So my memory consumption is mostly based on
> guessing.
> 
> I remember from my Solaris days the "pmap" uptility. Is there anything like
> that for HP-UX? 
> 
> This is 9.2.0.6 on HP-UX 11.11.
> 
> Thanks, 
> Helmut 
> 
> 
Received on Fri Jan 06 2006 - 19:58:21 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US