Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
threaded programs report bogus process size ?
Hi,
I just noticed that threaded processes may report increasing process
size of their life ...
The following sample which create a single thread in a loop does
illustrate this strange behaviour.
njoly@lanfeust [~]> cat thr_loop.c
#include <err.h>
#include <pthread.h>
void *thr_func(void *arg) { return NULL; }
int main() {
int res;
pthread_t thr;
while (1) {
res = pthread_create(&thr, NULL, thr_func, NULL);
if (res != 0)
errx(1, "pthread_create failed");
res = pthread_join(thr, NULL);
if (res != 0)
errx(1, "pthread_join failed");
}
return 0; }
njoly@lanfeust [~]> cc -pthread -o thr_loop thr_loop.c
njoly@lanfeust [~]> ./thr_loop
And then, both top(1) and ps(1) report an increasing process size over
the time.
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
11242 njoly 36 0 57M 1224K RUN/1 0:02 8.51% 4.49% thr_loop
[...]
11242 njoly 39 0 119M 1596K RUN/0 0:04 0.00% 6.40% thr_loop
[...]
11242 njoly 39 0 161M 1848K RUN/0 0:06 0.00% 7.03% thr_loop
[...]
11242 njoly 37 0 203M 2100K CPU/1 0:08 0.00% 7.57% thr_loop
I'm not sure this is a critical problem, as i do not see any drawback
with such a 19GB process in my machine; but i'm wondering where does
such numbers come from.
Any hint ?
Thanks.
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.
Home |
Main Index |
Thread Index |
Old Index