From: Martin Sebor <msebor@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>,
Joseph Myers <joseph@codesourcery.com>
Cc: Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] free MPFR caches in gimple-ssa-sprintf.c (PR 79699)
Date: Thu, 02 Mar 2017 21:34:00 -0000 [thread overview]
Message-ID: <63968707-1824-0aa5-c03d-939cdb14aba5@gmail.com> (raw)
In-Reply-To: <CAFiYyc0CeP8wrqf0TJ00MYK6EtKdBKdBiBUA1bSKyy_yiJMkNw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
On 03/02/2017 01:08 AM, Richard Biener wrote:
> On Thu, Mar 2, 2017 at 2:01 AM, Joseph Myers <joseph@codesourcery.com> 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
[-- Attachment #2: gcc-79699.diff --]
[-- Type: text/x-patch, Size: 707 bytes --]
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 ();
}
next prev parent reply other threads:[~2017-03-02 21:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-01 23:32 Martin Sebor
2017-03-02 1:01 ` Joseph Myers
2017-03-02 8:08 ` Richard Biener
2017-03-02 21:34 ` Martin Sebor [this message]
2017-03-02 21:40 ` Andrew Pinski
2017-03-02 21:56 ` Martin Sebor
2017-03-03 11:02 ` Richard Biener
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=63968707-1824-0aa5-c03d-939cdb14aba5@gmail.com \
--to=msebor@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=richard.guenther@gmail.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).