This is a discussion on A problem about top-3.5 on Tru64 UNIX - Unix ; Hi, I'm looking for the answers. I compiled top-3.5 source on a Tru64 UNIX 5.1 (OSF1) machine and executed it. then, I've seen the Top process occupied 45Mb of memory. It's too large! On another Tru64 machine, only less than ...
I'm looking for the answers.
I compiled top-3.5 source on a Tru64 UNIX 5.1 (OSF1) machine
and executed it.
then, I've seen the Top process occupied 45Mb of memory.
It's too large!
On another Tru64 machine, only less than 1Mb.
I tried to search for reason of the overload
and found the overload happenes in the part
of getting process information.
In progress, first, Top requests the number of all processes
into "nproc". next, iterating for "nproc" times in a loop,
requests the information of each processes.
But, in the machine of the former, "nproc" value was
When Top calls table(...) function for 300,000 times,
it's memory usage grows up seriously.
What is worse, sometimes Top occurs a fault and the process dies.
In the machine of the latter, "nproc" was less than 70,000.
When iterating the loop, it ignores the processes whose PID is zero.
Actually, it takes just about 130 processes.
"nproc" is too large as compared to the number of actual processes.
Why must it spend memory of 300,000 cases for getting just 130 cases?
Isn't there a way to act for need only?
I'm expecting valuable replies.
Below is a part of top-3.5 source getting process info.
nproc = table(TBL_PROCINFO, 0, (struct tbl_procinfo *)NULL,
for (j=0; j
r = table(TBL_PROCINFO, j, (struct tbl_procinfo *)p_i, 8,
for (k = 0; k < r; k++, pp++)
if(p_i[k].pi_pid == 0)
pp->p_pid = 0;
pp->p_pid = p_i[k].pi_pid;
pp->p_ruid = p_i[k].pi_ruid;
pp->p_flag = p_i[k].pi_flag;
pp->p_nice = getpriority(PRIO_PROCESS,p_i[k].pi_pid);
/* Load useful values into the proc structure */