From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25205 invoked by alias); 2 Dec 2011 02:11:59 -0000 Received: (qmail 25134 invoked by uid 22791); 2 Dec 2011 02:11:56 -0000 X-SWARE-Spam-Status: No, hits=1.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-vx0-f169.google.com (HELO mail-vx0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Dec 2011 02:11:43 +0000 Received: by vcbfk26 with SMTP id fk26so2346056vcb.0 for ; Thu, 01 Dec 2011 18:11:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.0.131 with SMTP id 3mr1583137vcb.213.1322791902777; Thu, 01 Dec 2011 18:11:42 -0800 (PST) Received: by 10.52.38.195 with HTTP; Thu, 1 Dec 2011 18:11:42 -0800 (PST) Date: Fri, 02 Dec 2011 02:11:00 -0000 Message-ID: Subject: Possible memory leak in Pthreads-Win32 From: Jason Jones To: pthreads-win32@sourceware.org Content-Type: multipart/mixed; boundary=f46d0448f2cb7a115c04b3127d01 X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2011/txt/msg00032.txt.bz2 --f46d0448f2cb7a115c04b3127d01 Content-Type: text/plain; charset=ISO-8859-1 Content-length: 906 Hello! I am having memory leaks when using Pthreads-Win32. I have attached a very simple example program that illustrates the problem. It is very simple: 1) Inside a for loop, I create two threads with pthread_create. 2) Each of these threads executes a function that just returns 0; 3) I print out the return from the pthread_create calls. 4) Then use pthread_join on the two threads and the execute the next iteration of the loop. As I run this program, I can watch the memory constantly growing ( through task manager ). If I let it run long enough, I have seen it use 600 megabytes of memory. If I run the same program on Linux with native pthreads, I do not see any memory growth no matter how long I let it run. On Windows I see the memory leak with Visual Studio 2008 and also with the latest version of the Intel compiler. Is this a memory leak? Or am I doing something stupid? Thanks, Jason --f46d0448f2cb7a115c04b3127d01 Content-Type: text/x-csrc; charset=US-ASCII; name="pthread_leak.c" Content-Disposition: attachment; filename="pthread_leak.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gvok4n8f0 Content-length: 1286 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1 ZGUgPHB0aHJlYWQuaD4KLyoqKioqKioqKiBDT01QSUxFL0xJTksgTElORSAq KioqKioqKioqKioqKioqKioqKioqLwovKioqIGNsIC1JLi9wdGhyZWFkcy4y IHB0aHJlYWRfbGVhay5jIHB0aHJlYWRzLjIvcHRocmVhZFZDMi5saWIgKioq KioqLyAKLyoqKiBpY2wgcHRocmVhZF9sZWFrLmMgLUkuL3B0aHJlYWRzLjIg cHRocmVhZF9ncmFuZGNoaWxkLmMgcHRocmVhZHMuMi9wdGhyZWFkVkMyLmxp YiAqKioqKiovIAoKaW50ICpjYWxsX3ByaW50KHZvaWQgKnB0cik7CiAKaW50 IG1haW4oKQp7CiAgcHRocmVhZF90IHRocmVhZDEsIHRocmVhZDI7CiAgY2hh ciAqbWVzc2FnZTEgPSAiMSI7CiAgY2hhciAqbWVzc2FnZTIgPSAiMiI7CiAg aW50ICBpcmV0MSwgaXJldDIsIGk7CiAKIC8qIENyZWF0ZSBpbmRlcGVuZGVu dCB0aHJlYWRzIGVhY2ggb2Ygd2hpY2ggd2lsbCBleGVjdXRlIGZ1bmN0aW9u ICovCgogICBmb3IoaT0wO2k8NDAwMDAwMDtpKyspCiAgIHsgCiAgICAgaXJl dDEgPSBwdGhyZWFkX2NyZWF0ZSggJnRocmVhZDEsIE5VTEwsIGNhbGxfcHJp bnQsICh2b2lkKikgbWVzc2FnZTEpOwogICAgIGlyZXQyID0gcHRocmVhZF9j cmVhdGUoICZ0aHJlY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