Package: procps
Version: 1:3.2.7-8

The top command show used memory size incorrectly if an application  use
threads.

There is a test  c-file  in  the  attachment  which  runs  350  threads.
The top command on my system shows that compiled from this  file  'test'
application used in 2 times more memory than it is.

And if you apply ps command to detect used memory size then you will see
that  really  used  just   0.1%   of   memory   from   available   size.
The top command in the %MEM field show the size  correctly  (0.1%),  but
the value in the DATA field is wrong.

It's obvious that the problem is that the  top  command  get  the  wrong
value by the following way.

It's multiply the one thread size on the threads quantity.

--
... mpd is off

. ''`. Dmitry E. Oboukhov
: :’  : [EMAIL PROTECTED]
`. `~’ GPGKey: 1024D / F8E26537 2006-11-21
  `- 1B23 D4F8 8EC0 D902 0555  E438 AB8C 00CF F8E2 6537
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void thread_foo(void * data)
{
	int num=*(int *)data;
	int i;
	int pause=100+random()%10000;
	while(1)
	{
		for (i=0; i<num+10; i++) usleep(pause);
	}
}

int main(void)
{
	int i;
    pthread_t h;
    for (i=0; i<350; i++)
    {
        pthread_create (&h, NULL, (void *)&thread_foo, &i);
        usleep(500);
    }
    thread_foo(&i);
}

Attachment: signature.asc
Description: Digital signature

Reply via email to