This is the mail archive of the
mailing list for the GCC project.
[patch, libfortran] PR40508 Memory Leak
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 21 Jun 2009 13:06:38 -0700
- Subject: [patch, libfortran] PR40508 Memory Leak
First to explain the problem. Internal units have a gfc_unit structure that is
allocated in memory at the beginning of an IO statement (read/write) and freed
at the end. This means that there is no unit structure retained from one
statement to the next and therefore saving format data pointed to in that
structure is moot.
The problem begins with bothering to save the format to begin with and ends with
not freeing it within free_internal_unit. This means that the following patch
is actually the best way to go for now.
This hints at a further optimization we could do. Why allocate an internal unit
structure every time we do an I/O? There may be a way to reuse an internal unit
structure for repeated units. I will save that for a later date.
I also have a confession to make. In format.c you will see where I added a bool
save_format flag. This was the start of disabling saving formats for specific
cases that could be troublesome, internal units being one of those. I failed to
finish that part of the patch when I submitted it before. Regardless, I am
working on these related items as part of the CP2K bug we found. When I get
that all tested, I will submit a full patch.
In the meantime, OK to commit the following to trunk in the interim?
Regression tested on x86-64-linux-gnu.
2009-06-21 Jerry DeLisle <email@example.com>
* io/format.c: Don't save parsed format data for internal units.
--- format.c (revision 148448)
+++ format.c (working copy)
@@ -1218,7 +1218,8 @@ parse_format (st_parameter_dt *dtp)
- save_parsed_format (dtp);
+ if (!is_internal_unit (dtp))
+ save_parsed_format (dtp);