Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Feb 1999 17:21:57 +0300 (MSK)
From:      "Sergey S. Kosyakov" <ks@itp.ac.ru>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   Memory leak in pthread?
Message-ID:  <XFMail.990205172157.ks@itp.ac.ru>

next in thread | raw e-mail | index | archive | help

Just simple program:

#define MAX_THREADS 500
  
  while(1)
   {
    for(i=0;i<MAX_THREADS;i++)
     {
      id[i]=i;
      pthread_create(&thr[i],NULL,doit,&id[i]);
     }
    for(i=0;i<MAX_THREADS;i++) 
     pthread_join(thr[i],NULL);
    printf("Cycle.\n");
   }

This programm very quickly eats all the virtual memory. In "freebsd-hackers
archive" I found some words about thread management by hand. More complicated
program, where stacks are allocated/deallocated by malloc()/free() for each
thread, eats memory not so quickly, but still eats, e.g. resident size (for each
"cycle" printed)
1528K
1792K
2036K
2296K
2552K
3100K
and so on.

Another effect - program runs slower and slower.
What is the cause? When stack management, pthread_cleanup_push was used. 

Sergey.

---
----------------------------------
Sergey Kosyakov
Laboratory of Distributed Computing
Department of High-Performance Computing and Applied Network Research
Landau Institute for Theoretical Physics
E-Mail: ks@itp.ac.ru
Date: 05-Feb-99
Time: 17:08:58
----------------------------------
---

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.990205172157.ks>