This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Pthread_create memory usage (pthread BUG?)
- From: Bin Chen <binary dot chen at gmail dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 02 Mar 2007 19:18:56 +0800
- Subject: Pthread_create memory usage (pthread BUG?)
I wrote a simple program that spawn a lot of threads using pthread,
after ran the program the memory usage of the process increase very
fast, soon it become:
cat /proc/5243/status abcde.
Name: tthread
State: S (sleeping)
SleepAVG: 88%
Tgid: 5243
Pid: 5243
PPid: 4804
TracerPid: 0
Uid: 1000 1000 1000 1000
Gid: 1000 1000 1000 1000
FDSize: 256
Groups: 4 20 24 25 29 30 44 46 109 111 114 116 1000
VmPeak: 116404 kB
VmSize: 116404 kB
VmLck: 0 kB
VmHWM: 488 kB
VmRSS: 488 kB
VmData: 114912 kB ***** why so high *****
VmStk: 88 kB
VmExe: 4 kB
VmLib: 1364 kB
VmPTE: 64 kB
Threads: 1
SigQ: 0/4294967295
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000180000000
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
Cpus_allowed: ff
Mems_allowed: 1
by cat /proc/<pid>/status.
uname -a
Linux binch-laptop 2.6.17-10-generic #2 SMP Fri Oct 13 18:45:35 UTC 2006
i686 GNU/Linux
/lib/libc.so.6
GNU C Library development release version 2.4, by Roland McGrath et al.
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.1.2 20060928 (prerelease) (Ubuntu
4.1.1-13ubuntu5).
Compiled on a Linux 2.6.17-10 system on 2007-01-24.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
GNU libio by Per Bothner
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
List program below:
#include <pthread.h>
pthread_t my_thread;
void thread_proc(void)
{
printf("abcde.\n");
}
int main(void)
{
int i;
for (i = 0;i < 1024;i ++)
{
if (pthread_create(&my_thread, NULL, &thread_proc, NULL) != 0)
{
printf("pthread create error.\n");
exit(0);
}
sleep(1);
}
}