From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Cedric Cellier Newsgroups: gmane.lisp.guile.user Subject: Memory leak with threads + guile 1.8.7 ? Date: Wed, 15 Sep 2010 15:47:24 +0200 Message-ID: <20100915134724.GA13622@securactive.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="CE+1k2dSO48ffgeK" X-Trace: dough.gmane.org 1284558553 7850 80.91.229.12 (15 Sep 2010 13:49:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Sep 2010 13:49:13 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Sep 15 15:49:10 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OvsLn-0000s4-RL for guile-user@m.gmane.org; Wed, 15 Sep 2010 15:49:09 +0200 Original-Received: from localhost ([127.0.0.1]:41278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvsLc-0005G6-1M for guile-user@m.gmane.org; Wed, 15 Sep 2010 09:48:28 -0400 Original-Received: from [140.186.70.92] (port=37811 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvsL3-0005Cw-OA for guile-user@gnu.org; Wed, 15 Sep 2010 09:47:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvsL2-0006JM-GU for guile-user@gnu.org; Wed, 15 Sep 2010 09:47:53 -0400 Original-Received: from smtp5-g21.free.fr ([212.27.42.5]:37715) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvsL1-0006Fr-Ti for guile-user@gnu.org; Wed, 15 Sep 2010 09:47:52 -0400 Original-Received: from apc.happyleptic.org (unknown [82.67.194.89]) by smtp5-g21.free.fr (Postfix) with ESMTP id CE727D48074 for ; Wed, 15 Sep 2010 15:47:24 +0200 (CEST) Original-Received: from ccellier.rd.securactive.lan (extranet.securactive.org [82.234.213.170]) by apc.happyleptic.org (Postfix) with ESMTP id C01B933812 for ; Wed, 15 Sep 2010 15:57:51 +0200 (CEST) Original-Received: from rixed by ccellier.rd.securactive.lan with local (Exim 4.71) (envelope-from ) id 1OvsKa-0000G4-MN for guile-user@gnu.org; Wed, 15 Sep 2010 15:47:24 +0200 Mail-Followup-To: Cedric Cellier , guile-user@gnu.org Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8169 Archived-At: --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello dear hackers ! I'm using guile in an C program that spawn a lot of short lived threads, each of which passing in guile mode (guile 1.8.7), and I'm facing a memory leak even when the threads does nothing (ie. the C function called by scm_with_guile consists only of a return NULL. After some time, if I call a gc-stats I have many many segments of 21Mb allocated, although gc-live-object-stats reports that almost nothing is alive (acording to expectations). I am under the impression that some of these segments, created by a now defunct thread, can not be reused by others. So I made a small program that continuously creates thread and run a NOP scm_with_guile in it, and then join it (so that thre thread local storage itself is not leaked). With the useless scm_with_guile call, this programm leaks memory very quickly. Comment out the scm_with_guile call and there is no more leak. What do you think ? --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Makefile CFLAGS += $(shell guile-config compile) -std=c99 CPPFLAGS += -D_GNU_SOURCE LDLIBS += $(shell guile-config link) -lpthread all: many_threads clean: rm -f *.o many_threads --CE+1k2dSO48ffgeK Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="many_threads.c" #include #include #include #include static void *thread_with_guile(void *null) { return NULL; } static void *the_thread(void *args) { (void)scm_with_guile(thread_with_guile, NULL); // comment me to remove the memory leak return NULL; } int main(void) { // We create many threads while (1) { pthread_t ptid; pthread_create(&ptid, NULL, the_thread, NULL); void *ret; pthread_join(ptid, &ret); } return 0; } --CE+1k2dSO48ffgeK--