From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59235 invoked by alias); 2 Mar 2017 21:34:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 56654 invoked by uid 89); 2 Mar 2017 21:34:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=H*RU:209.85.220.194, Hx-spam-relays-external:209.85.220.194, site X-HELO: mail-qk0-f194.google.com Received: from mail-qk0-f194.google.com (HELO mail-qk0-f194.google.com) (209.85.220.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Mar 2017 21:33:58 +0000 Received: by mail-qk0-f194.google.com with SMTP id j127so4352829qke.0 for ; Thu, 02 Mar 2017 13:33:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=zv9TU7MssVneaFWLdZKwp0G37iKf0ekn2b5Z+UH6Bsg=; b=O0ehZDkIJ3RutNszdPMlz90y2yFpB+RPcU0p5QzBTdKG9H5lIgJb9CMwZr1uk2GJK3 Phw6uX0D1XQWA8Q83S2hu81arWFipmhchq7Y+5DXLT8uO6kt79tWieysjP8zTkEgo06E ggu//n79GW7+kA9ZUosQU44B+dPen0JSpy8oRdQgwucxZw3hJEYWJjJIww9jA83l89+2 aEAGxoi0q8J03NUm3bfo7r9cOO0NIvSiCDz1kfS0/glB1fYHT5csarkvNqCekvsjmPs5 solfLGZahiou7O40Gay6M7hl/nDmDnlxtwqRrMFOVVpMoCSIiFrJsP2WO0KnWI4VWz71 zJPg== X-Gm-Message-State: AMke39mKEKTNQldk+Drxje6Di+VpLSVDGmVjzSirMM/BDGtirvO5ltvwYnMuhrPB3cYcuA== X-Received: by 10.55.76.138 with SMTP id z132mr8291375qka.128.1488490437217; Thu, 02 Mar 2017 13:33:57 -0800 (PST) Received: from [192.168.0.3] (75-166-126-106.hlrn.qwest.net. [75.166.126.106]) by smtp.gmail.com with ESMTPSA id 37sm6232918qto.43.2017.03.02.13.33.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 13:33:56 -0800 (PST) Subject: Re: [PATCH] free MPFR caches in gimple-ssa-sprintf.c (PR 79699) To: Richard Biener , Joseph Myers References: <60d46e1a-686b-9c27-4b48-7b658f8507fa@gmail.com> Cc: Gcc Patch List From: Martin Sebor Message-ID: <63968707-1824-0aa5-c03d-939cdb14aba5@gmail.com> Date: Thu, 02 Mar 2017 21:34:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------CD322E6248BFF8630F570729" X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00133.txt.bz2 This is a multi-part message in MIME format. --------------CD322E6248BFF8630F570729 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 818 On 03/02/2017 01:08 AM, Richard Biener wrote: > On Thu, Mar 2, 2017 at 2:01 AM, Joseph Myers wrote: >> On Wed, 1 Mar 2017, Martin Sebor wrote: >> >>> Joseph, since you commented on the bug, do you have a suggestion >>> for a different site for it or a guard? The only other call to >>> the function is in the Fortran FE and it's neither guarded nor >>> does it appear to ever be called. >> >> I don't think a guard is needed. Arguably it should be called from an >> atexit handler, but since we don't have such a handler calling it from the >> relevant pass seems reasonable (and I'm not sure what the right way to >> handle such freeing of memory in the JIT context is). > > IMHO we should call it from gcc::~context Thanks, that makes sense to me. The attached patch does that. Martin --------------CD322E6248BFF8630F570729 Content-Type: text/x-patch; name="gcc-79699.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-79699.diff" Content-length: 707 PR tree-optimization/79699 - small memory leak in MPFR gcc/ChangeLog: PR tree-optimization/79699 * context.c (context::~context): Free MPFR caches to avoid a memory leak on program exit. diff --git a/gcc/context.c b/gcc/context.c index a7ded9c..d2009b9 100644 --- a/gcc/context.c +++ b/gcc/context.c @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "context.h" #include "pass_manager.h" #include "dumpfile.h" +#include "mpfr.h" /* The singleton holder of global state: */ gcc::context *g; @@ -42,4 +43,7 @@ gcc::context::~context () { delete m_passes; delete m_dumps; + + /* Release MPFR caches to avoid Valgrind leak reports. */ + mpfr_free_cache (); } --------------CD322E6248BFF8630F570729--