Patchwork [fortran,committed] Release mpfr caches.

login
register
mail settings
Submitter Mikael Morin
Date July 11, 2010, 12:18 p.m.
Message ID <4C39B6A9.8020302@sfr.fr>
Download mbox | patch
Permalink /patch/58521/
State New
Headers show

Comments

Mikael Morin - July 11, 2010, 12:18 p.m.
This fixes a unreleased memory problem present on any testcase as 
reported by valgrind:

==9351== 32 bytes in 1 blocks are possibly lost in loss record 23 of 286
==9351==    at 0x25A67B: malloc (in 
/usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==9351==    by 0x20F03B8: __gmp_default_allocate (in 
/usr/local/lib/libgmp.so.10)
==9351==    by 0x1FBF6C5: mpfr_init2 (in /usr/local/lib/libmpfr.so.4)
==9351==    by 0x1FCA2BF: mpfr_cache (in /usr/local/lib/libmpfr.so.4)
==9351==    by 0x1FA6C58: mpfr_log (in /usr/local/lib/libmpfr.so.4)
==9351==    by 0x1FBE43F: mpfr_log10 (in /usr/local/lib/libmpfr.so.4)
==9351==    by 0x48EE23: gfc_arith_init_1 (arith.c:168)
==9351==    by 0x4F379D: gfc_init_1 (misc.c:260)
==9351==    by 0x548854: gfc_init (f95-lang.c:267)
==9351==    by 0xA01CC1: lang_dependent_init (toplev.c:2215)
==9351==    by 0xA01EDA: do_compile (toplev.c:2339)
==9351==    by 0xA01FAA: toplev_main (toplev.c:2381)
Steve Kargl - July 11, 2010, 3:37 p.m.
On Sun, Jul 11, 2010 at 02:18:49PM +0200, Mikael Morin wrote:

> Index: ChangeLog
> ===================================================================
> --- ChangeLog	(revision 162057)
> +++ ChangeLog	(revision 162058)
> @@ -1,3 +1,7 @@
> +2010-07-11  Mikael Morin  <mikael@gcc.gnu.org>
> +
> +	* arith.c (gfc_arith_done_1): Release mpfr internal caches.
> +

If you haven't committed the patche, then please do so.

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 162057)
+++ ChangeLog	(revision 162058)
@@ -1,3 +1,7 @@ 
+2010-07-11  Mikael Morin  <mikael@gcc.gnu.org>
+
+	* arith.c (gfc_arith_done_1): Release mpfr internal caches.
+
 2010-07-11  Janus Weil  <janus@gcc.gnu.org>
 
 	PR fortran/44869
Index: arith.c
===================================================================
--- arith.c	(revision 162057)
+++ arith.c	(revision 162058)
@@ -260,6 +260,8 @@  gfc_arith_done_1 (void)
 
   for (rp = gfc_real_kinds; rp->kind; rp++)
     mpfr_clears (rp->epsilon, rp->huge, rp->tiny, rp->subnormal, NULL);
+
+  mpfr_free_cache ();
 }