Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory usage and prpsinfo

10 views
Skip to first unread message

Alex Vinokur

unread,
Dec 7, 1999, 3:00:00 AM12/7/99
to


Here are results of measuring memory usage in SunOS 5.6.
These results made me ask several questions (see below).

Thanks in advance,
Alex

//#########################################################
//------------------- Environment -------------------------

g++ -v : gcc version egcs-2.91.57 19980901
(egcs-1.1 release)

uname -sr : SunOS 5.6

//---------------------------------------------------------

//#########################################################
//------------------- C++ code : BEGINNING ----------------

//#####################################
//---------------------------
// File #1 of 5 (BEGINNING)
// File memory_usage.H
//---------------------------

#ifndef memory_usage_H
#define memory_usage_H

//=====================================
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/resource.h>

#include <iostream>
#include <string>
#include <vector>
#include <strstream>


//=====================================
#define FAULT_MSG(msg) \
cout << "FAULT ::: " \
<< msg \
<< " : " \
<< (strerror (errno)) \
<< " [ " \
<< __FILE__ \
<< ", #" \
<< __LINE__ \
<< " ]" \
<< " -> " \
<< __PRETTY_FUNCTION__ \
<< endl

#define ERROR_MSG(msg) \
cout << "ERROR ::: " \
<< msg \
<< " : " \
<< " [ " \
<< __FILE__ \
<< ", #" \
<< __LINE__ \
<< " ]" \
<< " -> " \
<< __PRETTY_FUNCTION__ \
<< endl


//=====================================
//=====================================
//-------------------------------------
string int_to_dec_str (int value_i);

bool popen_cplusplus (
const string& command_i,
vector<string>& result_o
);


bool get_info_from_sysconf (long& kbytes_in_system_o);
bool get_info_from_getrusage (
long& maximum_resident_set_size,
long& integral_resident_set_size
);

//=====================================
#endif

//---------------------------
// File memory_usage.H
// File #1 of 5 (END)
//---------------------------


//#####################################
//---------------------------
// File #2 of 5 (BEGINNING)
// File memory_prpsinfo.H
//---------------------------

#ifndef memory_prpsinfo_H
#define memory_prpsinfo_H

//=====================================
#include "memory_usage.H"
#include <sys/procfs.h>

//=====================================
//=====================================
//-------------- prpsinfo -------------
bool get_prpsinfo_t (
prpsinfo_t& retval_prpsinfo_t_o,
int pid_i = getpid ()
);

bool get_info_from_prpsinfo (
u_short& pr_pctmem_o, //
percent_of_system_memory_used_by_the_process
u_long& pr_byrssize_o, //
resident_set_size_in_bytes
int pid_i = getpid ()
);

int do_main_USING_prpsinfo (int argc, char** argv);
//=====================================
#endif

//---------------------------
// File memory_prpsinfo.H
// File #2 of 5 (END)
//---------------------------


//#####################################
//---------------------------
// File #3 of 5 (BEGINNING)
// File memory_usage.C
//---------------------------

#include "memory_usage.H"

//=====================================
string int_to_dec_str (int value_i)
{
string ret_stringValue;
strstream tmp_strstream;

tmp_strstream << value_i;
tmp_strstream << ends;
ret_stringValue = tmp_strstream.str();
tmp_strstream.rdbuf()->freeze (0);

return ret_stringValue;
} // string int_to_dec_str (int value_i)

//=====================================
bool popen_cplusplus (
const string& command_i,
vector<string>& result_o
)
{
bool ret_boolValue = true;
FILE* fp;
const int SIZEBUF = 1234;
char buf [SIZEBUF];

//================================
result_o = vector<string> ();
//================================

if ((fp = popen(command_i.c_str (), "r")) == NULL)
{
FAULT_MSG ("Files or processes cannot be created");
ret_boolValue = false;
return ret_boolValue;
}

//================================
string cur_string;
while (fgets(buf, sizeof (buf), fp))
{
cur_string = buf;
if (cur_string [cur_string.size () - 1] != '\n')
{
ERROR_MSG ("SIZEBUF too small ("
<< SIZEBUF
<< ")");
ret_boolValue = false;
return ret_boolValue;
}
assert (cur_string [cur_string.size () - 1] == '\n');
result_o.push_back (cur_string.substr
(0,
cur_string.size () - 1)
);
}

//================================
if (pclose(fp) == -1)
{
FAULT_MSG ("Cannot execute pclose");
ret_boolValue = false;
}

return ret_boolValue;

} // bool popen_cplusplus (...)


//=====================================
bool get_info_from_sysconf (long& kbytes_in_system_o)
{
bool ret_boolValue = true;
long total_physical_pages;
long bytes_per_page;


//----------------------------
total_physical_pages = sysconf(_SC_PHYS_PAGES);
if (total_physical_pages == -1)
{
FAULT_MSG ("Cannot executed sysconf(_SC_PHYS_PAGES)");
ret_boolValue = false;
return ret_boolValue;
}
if (total_physical_pages < 0)
{
FAULT_MSG ("Bug in system : Cannot executed
sysconf(_SC_PHYS_PAGES)");
ret_boolValue = false;
assert (0);
return ret_boolValue; // unused
}

//----------------------------
bytes_per_page = sysconf(_SC_PAGESIZE);
if (bytes_per_page == -1)
{
FAULT_MSG ("Cannot executed sysconf(_SC_PAGESIZE)");
ret_boolValue = false;
return ret_boolValue;
}
if (bytes_per_page < 0)
{
FAULT_MSG ("Bug in system : Cannot executed
sysconf(_SC_PAGESIZE)");
ret_boolValue = false;
assert (0);
return ret_boolValue; // unused
}

//---------------------------------
kbytes_in_system_o = (total_physical_pages *
bytes_per_page)/1024;

return ret_boolValue;
} // bool get_info_from_sysconf (long& kbytes_in_system_o)

//=====================================
bool get_info_from_getrusage (
long& maximum_resident_set_size,
long& integral_resident_set_size
)
{
bool ret_boolValue = true;
int ret_getrusage;
struct rusage r_usage;


ret_getrusage = getrusage (RUSAGE_SELF, &r_usage);
//----------------------------
if (ret_getrusage == -1)
{
FAULT_MSG ("Cannot executed getrusage)");
ret_boolValue = false;
return ret_boolValue;
}
if (!(ret_getrusage == 0))
{
FAULT_MSG ("Bug in system : Cannot executed getrusage");
ret_boolValue = false;
assert (0);
return ret_boolValue; // unused
}

//----------------------------
maximum_resident_set_size = r_usage.ru_maxrss;
integral_resident_set_size = r_usage.ru_idrss;

return ret_boolValue;
} // bool get_info_from_getrusage


//---------------------------
// File memory_usage.C
// File #3 of 5 (END)
//---------------------------


//#####################################
//---------------------------
// File #4 of 5 (BEGINNING)
// File memory_prpsinfo.C
//---------------------------

#include "memory_prpsinfo.H"

const int BYTES_IN_KBYTE = 1024;

//=====================================
bool get_prpsinfo_t (
prpsinfo_t& retval_prpsinfo_t_o,
int pid_i
)
{
bool ret_boolValue = true;
string lwpName = "/proc/" + int_to_dec_str (pid_i);
int fd = open (lwpName.c_str (), O_RDONLY);

//==============================
if (fd == -1)
{
ret_boolValue = false;
//------------------------
FAULT_MSG ("Cannot open lwpFileName of this process - <"
<< lwpName
<< ">"
);
//------------------------
return ret_boolValue;
}

//==============================
if (ioctl (fd, PIOCPSINFO, &retval_prpsinfo_t_o) < 0)
{
ret_boolValue = false;
//------------------------
FAULT_MSG ("Cannot execute ioctl function for lwpFile -
<"
<< lwpName
<< ">"
);
//------------------------
return ret_boolValue;
}

//==============================
switch (close (fd))
{
case 0 :
// Success
break;

case -1 :
ret_boolValue = false;
//------------------------
FAULT_MSG ("Cannot close lwpFileName of this
process - <"
<< lwpName
<< ">"
);
//------------------------
break;

default :
assert (0);
} // switch (close (fd))

//==========================
return ret_boolValue;
//==========================

} // prpsinfo_t get_prpsinfo_t (


//=====================================
bool get_info_from_prpsinfo (
u_short& pr_pctmem_o,
u_long& pr_byrssize_o,
int pid_i
)
{
prpsinfo_t this_prpsinfo_t;
bool ret_boolValue = get_prpsinfo_t (this_prpsinfo_t, pid_i);

//=========================
if (ret_boolValue)
{
pr_pctmem_o = this_prpsinfo_t.pr_pctmem;
pr_byrssize_o = this_prpsinfo_t.pr_byrssize;
}
//=========================
return ret_boolValue;

} // bool get_info_from_prpsinfo


//=====================================
int do_main_USING_prpsinfo (int argc, char** argv)
{
u_short prpsinfo_result__memory_usage;
u_long prpsinfo_result__resident_set_size;
long sysconf_result__kbytes_in_system;
long getrusage_result__maximum_resident_set_size;
long getrusage_result__integral_resident_set_size;
vector<string> popen_result;

string popen_command = "ps -o user,pid,pmem,rss -o args -p "
+ int_to_dec_str (getpid ());

char* ptr_str = NULL;
//====================================

for (int the_index = 0; the_index < 10; the_index++)
{
cout << endl;
cout << endl;
cout << "##### STEP ["
<< the_index
<< "] : pid = "
<< getpid ()
<< " #####"
<< endl;

//-----------------
ptr_str = new char [500000];


//--------------------
cout << "--- getrusage ---" << endl;
if (get_info_from_getrusage (

getrusage_result__maximum_resident_set_size,

getrusage_result__integral_resident_set_size
))
{
cout << "(A1) Maximum resident set size\t : "
<<
getrusage_result__maximum_resident_set_size
<< " pages"
<< endl;
cout << "(A2) Integral resident set size\t : "
<<
getrusage_result__integral_resident_set_size
<< " pages"
<< endl;
}
else
{
cout << "Cannot get info USING getrusage"
<< endl;
return 1;
}


//--------------------
cout << "--- sysconf ---" << endl;
if (get_info_from_sysconf
(sysconf_result__kbytes_in_system))
{
cout << "(B1) Physical memory in system\t : "
<< sysconf_result__kbytes_in_system
<< " kbytes"
<< endl;
}
else
{
cout << "Cannot get info USING sysconf"
<< endl;
return 1;
}

//--------------------
cout << "--- prpsinfo_t ---" << endl;
if (get_info_from_prpsinfo (
prpsinfo_result__memory_usage,
prpsinfo_result__resident_set_size
))
{
cout << "(C1) Memory Usage\t : "
<<
static_cast<float>(prpsinfo_result__memory_usage)/100
<< " percent"
<< endl;

cout << "(C2) Resident Set Size\t : "
<<
prpsinfo_result__resident_set_size/BYTES_IN_KBYTE
<< " kbytes"
<< endl;

cout << "(C3) = (C2)/(B1)\t : " <<
((static_cast<float>(prpsinfo_result__resident_set_size)/BYTES_IN_KBYTE)/sysc
onf_result__kbytes_in_system)*100 << " percent" << endl; } else { cout
<< "Cannot get info USING prpsinfo" << endl; return 1; }

//--------------------
if (!popen_cplusplus (popen_command, popen_result))
{
cout << "Cannot execute popen_cplusplus"
<< endl;
return 1;
}

cout << "--- popen ---" << endl;
for (unsigned int i = 0; i < popen_result.size (); i++)
{
cout << popen_result [i] << endl;
}

//----------------
sleep (1);
} // for (int the_index = 0; the_index < 100; the_index++)

return 0;
} // int do_main_USING_prpsinfo

//---------------------------
// File memory_prpsinfo.C
// File #4 of 5 (END)
//---------------------------


//#####################################
//---------------------------
// File #5 of 5 (BEGINNING)
// File main_USING_prpsinfo.C
//---------------------------

//======================
#include "memory_usage.H"
#include "memory_prpsinfo.H"
//======================

//======================
int main (int argc, char** argv)
{
return do_main_USING_prpsinfo (argc, argv);
}

//---------------------------
// File main_USING_prpsinfo.C
// File #5 of 5 (END)
//---------------------------


//------------------- C++ code : END ----------------------

//#########################################################
//------------------- Compilation Results : BEGINNING -----
%g++ -Wall memory_usage.C memory_prpsinfo.C main_USING_prpsinfo.C -o
b.out
// No errors
// No warnings

//------------------- Compilation Results : END -----------

//#########################################################
//------------------- Running Results : BEGINNING ---------

%b.out


##### STEP [0] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 3.84 percent
(C2) Resident Set Size : 736 kbytes
(C3) = (C2)/(B1) : 1.12305 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.2 752 b.out


##### STEP [1] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.01 percent
(C2) Resident Set Size : 768 kbytes
(C3) = (C2)/(B1) : 1.17188 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 768 b.out


##### STEP [2] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.05 percent
(C2) Resident Set Size : 776 kbytes
(C3) = (C2)/(B1) : 1.18408 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 776 b.out


##### STEP [3] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.09 percent
(C2) Resident Set Size : 784 kbytes
(C3) = (C2)/(B1) : 1.19629 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 784 b.out


##### STEP [4] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.14 percent
(C2) Resident Set Size : 792 kbytes
(C3) = (C2)/(B1) : 1.2085 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 792 b.out


##### STEP [5] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.18 percent
(C2) Resident Set Size : 800 kbytes
(C3) = (C2)/(B1) : 1.2207 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 800 b.out


##### STEP [6] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.2 percent
(C2) Resident Set Size : 804 kbytes
(C3) = (C2)/(B1) : 1.22681 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 804 b.out


##### STEP [7] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.22 percent
(C2) Resident Set Size : 808 kbytes
(C3) = (C2)/(B1) : 1.23291 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 808 b.out


##### STEP [8] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.24 percent
(C2) Resident Set Size : 812 kbytes
(C3) = (C2)/(B1) : 1.23901 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 812 b.out


##### STEP [9] : pid = 2195 #####
--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---
(C1) Memory Usage : 4.26 percent
(C2) Resident Set Size : 816 kbytes
(C3) = (C2)/(B1) : 1.24512 percent
--- popen ---
USER PID %MEM RSS COMMAND
alexv 2195 1.3 816 b.out

//------------------- Running Results : END ---------------


//#########################################################
//------------------- SunOS 5.6 Info : BEGINNING ----------

=======================================
===== SunOS 5.6
===== man getrusage
=======================================
<quote>


C Library Functions getrusage(3C)

NAME
getrusage - get information about resource utilization

SYNOPSIS
#include <sys/resource.h>

int getrusage(int who, struct rusage *r_usage);

DESCRIPTION
The getrusage() function provides measures of the resources
used by the current process or its terminated and waited-for
child processes.
[snip]

The members of rusage are as follows:

[snip]
long ru_maxrss;/* maximum resident set size */
long ru_idrss;/* integral resident set size */
[snip]

The fields are interpreted as follows:


[snip]
ru_maxrss The maximum resident set size. Size is given
in pages (the size of a page, in bytes, is
given by the getpagesize(3C) function). See
the NOTES section of this page.

ru_idrss An "integral" value indicating the amount of
memory in use by a process while the process
is running. This value is the sum of the
resident set sizes of the process running
when a clock tick occurs. The value is given
in pages times clock ticks. It does not take
sharing into account. See the NOTES section
of this page.
[snip]

NOTES
Only the timeval fields of struct rusage are supported in
this implementation.
[snip]


</quote>
=======================================
===== SunOS 5.6
===== man getrusage
=======================================


=======================================
===== SunOS 5.6
===== <sys/old_procfs.h> file
=======================================

<quote>
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */

/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */

#ifndef _SYS_OLD_PROCFS_H
#define _SYS_OLD_PROCFS_H

#pragma ident "@(#)old_procfs.h 1.34 97/04/18 SMI"

/*
* This file contains the definitions for the old ioctl()-based
* version of the process file system. It is obsolete but will
* continue to be supported in SunOS until the next major release.
* Note that <sys/procfs.h> and <sys/old_procfs.h> contain conflicting
* definitions and cannot be included together in the same source file.
*/

[snip]

/* Information for the ps(1) command */

#define PRFNSZ 16 /* max size of execed filename
*/
#define PRARGSZ 80 /* Number of chars of arguments
*/

typedef struct prpsinfo {
[snip]
u_long pr_bysize; /* size of process image in bytes */
u_long pr_byrssize; /* resident set size in bytes */
[snip]
u_short pr_pctmem; /* % of of system memory used by the
process */
[snip]

} prpsinfo_t;

[snip]

#endif /* _SYS_OLD_PROCFS_H */
</quote>
=======================================
===== SunOS 5.6
===== <sys/old_procfs.h> file
=======================================


//------------------- SunOS 5.6 Info : END ----------------

//#########################################################
//------------------- Questions : BEGINNING ---------------

Question#1.
Using prpsinfo_t and popen we have got different results.
1.1 Why are
values of *(C1), (C3) and %MEM* (See Running Results)
different?
Note that (C2) and RSS have got the same values.
1.2 Do *(C1), (C3) and %MEM* reflect
different parametres of the system?

Question#2. Which kinds of memory usage is it worth measuring?

Question#3. Which kinds of memory usage can we measure?

Question#4. When will *the memory fields of struct rusage*
be are supported by getrusage?

Question#5. In example above the following features have been used
to measure memory usage :
- getrusage(3C), // NULL-result in current implementation
- sysconf(3C),
- proc(4),
- the prpsinfo_t structure (see <sys/old_procfs.h>)
// It is possible use the psinfo_t structure (see
<sys/procfs.h>) as well
// I think it is preferable to use psinfo_t instead of
prpsinfo_t
- popen(3S),
- ps(1).
Are there another features to measure memory usage?


//------------------- Questions : END ---------------------

//#########################################################

Sent via Deja.com http://www.deja.com/
Before you buy.

Roger A. Faulkner

unread,
Dec 7, 1999, 3:00:00 AM12/7/99
to
In article <82ipgo$1nf$1...@nnrp1.deja.com>,
Alex Vinokur <alexande...@telrad.co.il> wrote:
>
[ snip incredibly long C++ code ]

>
>--- sysconf ---
>(B1) Physical memory in system : 65536 kbytes
>--- prpsinfo_t ---
>(C1) Memory Usage : 3.84 percent
>(C2) Resident Set Size : 736 kbytes
>(C3) = (C2)/(B1) : 1.12305 percent
>--- popen ---
> USER PID %MEM RSS COMMAND
> alexv 2195 1.2 752 b.out
>
[ snip more verbosity ]

>
>Question#1.
> Using prpsinfo_t and popen we have got different results.
> 1.1 Why are
> values of *(C1), (C3) and %MEM* (See Running Results)
> different?
> Note that (C2) and RSS have got the same values.
> 1.2 Do *(C1), (C3) and %MEM* reflect
> different parametres of the system?

You did not use pr_pctmem correctly in (C1).
The comment directly above its definition tells you what to do:
/* The following percent numbers are 16-bit binary */
/* fractions [0 .. 1] with the binary point to the */
/* right of the high-order bit (one == 0x8000) */
u_short pr_pctcpu; /* % of recent cpu time, one or all lwps */


u_short pr_pctmem; /* % of of system memory used by the process */

You print it as:
static_cast<float>(prpsinfo_result__memory_usage)/100
It should be printed as:
static_cast<float>(prpsinfo_result__memory_usage*100)/0x8000

You will still notice a small but not significant difference between
(C1) and (C3) because /proc divides by the available physical memory
as opposed to the total physical memory on the machine.
(Available phys. mem is slightly smaller than the total phys. mem;
don't ask me to explain. It's what's left after boot.)

I can't answer your other questions.

Roger Faulkner

Alex Vinokur

unread,
Dec 8, 1999, 3:00:00 AM12/8/99
to
In article <82jolq$rb9$1...@engnews1.eng.sun.com>, r...@sunraf.Sun.COM
(Roger A. Faulkner) wrote:
[snip]

> You did not use pr_pctmem correctly in (C1).
> The comment directly above its definition tells you what to do:
> /* The following percent numbers are 16-bit binary */
> /* fractions [0 .. 1] with the binary point to the */
> /* right of the high-order bit (one == 0x8000) */
> u_short pr_pctcpu; /* % of recent cpu time, one or all lwps
> */
> u_short pr_pctmem; /* % of of system memory used by the
> process */
> You print it as:
> static_cast<float>(prpsinfo_result__memory_usage)/100
> It should be printed as:
> static_cast<float>(prpsinfo_result__memory_usage*100)/0x8000
> You will still notice a small but not significant difference
> between
> (C1) and (C3) because /proc divides by the available physical
> memory
> as opposed to the total physical memory on the machine.
> (Available phys. mem is slightly smaller than the total phys. mem;
> don't ask me to explain. It's what's left after boot.)
[snip]

Thank you very much.

-------------------------
Now (C1) and (C3) are printed as following :

float tmp_float1;
float tmp_float2;
int tmp_int

tmp_float1 =
(static_cast<float>(prpsinfo_result__memory_usage)*100)/0x8000;
tmp_int = static_cast<int> ((tmp_float1 + 0.05) * 10);
tmp_float2 = static_cast<float> (tmp_int)/10;


cout << "(C1) Memory Usage\t : "

<< tmp_float2
<< " [ "
<< tmp_float1
<< " ]"
<< " percent"
<< endl;

tmp_float1 =
((static_cast<float>(prpsinfo_result__resident_set_size)/BYTES_IN_KBYTE)/sysconf_result__kbytes_in_system)*100;
tmp_int = static_cast<int> ((tmp_float1 + 0.05) * 10);
tmp_float2 = static_cast<float> (tmp_int)/10;


cout << "(C3) = (C2)/(B1)\t : "

<< tmp_float2
<< " [ "
<< tmp_float1
<< " ]"
<< " percent"
<< endl;

-------------------------
The new test results seem
to be better tnan the previous one.
Nevertheless, there is a small difference
between (C1) and %MEM.


##### STEP [0] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.2 [ 1.15967 ] percent
(C2) Resident Set Size : 728 kbytes
(C3) = (C2)/(B1) : 1.1 [ 1.11084 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.2 744 b.out


##### STEP [1] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.2 [ 1.21155 ] percent
(C2) Resident Set Size : 760 kbytes
(C3) = (C2)/(B1) : 1.2 [ 1.15967 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.2 760 b.out


##### STEP [2] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.2 [ 1.22375 ] percent


(C2) Resident Set Size : 768 kbytes

(C3) = (C2)/(B1) : 1.2 [ 1.17188 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 768 b.out


##### STEP [3] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.2 [ 1.23596 ] percent


(C2) Resident Set Size : 776 kbytes

(C3) = (C2)/(B1) : 1.2 [ 1.18408 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 776 b.out


##### STEP [4] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.2 [ 1.24817 ] percent


(C2) Resident Set Size : 784 kbytes

(C3) = (C2)/(B1) : 1.2 [ 1.19629 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 784 b.out


##### STEP [5] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.3 [ 1.25427 ] percent
(C2) Resident Set Size : 788 kbytes
(C3) = (C2)/(B1) : 1.2 [ 1.20239 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 788 b.out


##### STEP [6] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.3 [ 1.26343 ] percent


(C2) Resident Set Size : 792 kbytes

(C3) = (C2)/(B1) : 1.2 [ 1.2085 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 792 b.out


##### STEP [7] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.3 [ 1.26953 ] percent
(C2) Resident Set Size : 796 kbytes
(C3) = (C2)/(B1) : 1.2 [ 1.2146 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 796 b.out


##### STEP [8] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.3 [ 1.27563 ] percent


(C2) Resident Set Size : 800 kbytes

(C3) = (C2)/(B1) : 1.2 [ 1.2207 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 800 b.out


##### STEP [9] : pid = 3942 #####


--- getrusage ---
(A1) Maximum resident set size : 0 pages
(A2) Integral resident set size : 0 pages
--- sysconf ---
(B1) Physical memory in system : 65536 kbytes
--- prpsinfo_t ---

(C1) Memory Usage : 1.3 [ 1.28174 ] percent


(C2) Resident Set Size : 804 kbytes

(C3) = (C2)/(B1) : 1.2 [ 1.22681 ] percent


--- popen ---
USER PID %MEM RSS COMMAND

alexv 3942 1.3 804 b.out


//=======================

Alex

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!


0 new messages