From: Roman Savochenko <rom_as@diyaorg.dp.ua> To: sisyphus@altlinux.ru Subject: [sisyphus] Странные грабли с Pthread !!! Date: Wed, 10 Nov 2004 20:46:29 +0200 Message-ID: <41926205.8010406@diyaorg.dp.ua> (raw) Привет народ! Обнаружил тута странные грабли с потоками (pthread)! А суть в следующем. При открытии-закрытии потока наблюдается утечка памяти. Обнаружилось на серверной задаче которая использует потоки для распараллеливания обработки клиентских запросов. При этом, задача, клиентские потоки не держит открытыми, а создаёт при поступлении запроса. Т.е при каждом запросе клиента размер сервера в памяти увеличивается на 2Мб!!! (Контролирую по параметру VmSize в ksisguard) Хотя физически память не расходуется! Для проверки предположения я написал тестовую программку: //--------------------- test_threads.c ----------------------------- #include <stdio.h> #include <unistd.h> #include <pthread.h> void *Task(void *prm) { printf("Start pthread: %d!!!\n",*(int *)prm); pthread_exit(NULL); } int main() { int cnt = 100; pthread_t pthr_tsk; pthread_attr_t pthr_attr; pthread_attr_init(&pthr_attr); pthread_attr_setschedpolicy(&pthr_attr,SCHED_OTHER); sleep(10); while(cnt--) { pthread_create(&pthr_tsk,&pthr_attr,Task,&cnt); sleep(1); } pthread_attr_destroy(&pthr_attr); sleep(10); return 0; } //--------------------- test_threads.c ----------------------------- Имеем значения параметра VmSize: - в начале теста: 2.424 Мб - в конце теста: 207.360 Мб!!! Круто для такой маленькой программки! :) Кстате это актуально не только для ALTLinux2.4 но и для древнего ASPLinux7.3! Это я чего-то не понял или это действительно грабли? С уважением Роман!
next reply other threads:[~2004-11-10 18:46 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-11-10 18:46 Roman Savochenko [this message] 2004-11-10 19:51 ` Denis Ovsienko 2004-11-11 7:47 ` Roman Savochenko 2004-11-11 7:49 ` Denis Ovsienko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=41926205.8010406@diyaorg.dp.ua \ --to=rom_as@diyaorg.dp.ua \ --cc=sisyphus@altlinux.ru \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Sisyphus discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \ sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru public-inbox-index sisyphus Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.sisyphus AGPL code for this site: git clone https://public-inbox.org/public-inbox.git