It seems that there is something wrong in the reference counting for namespaces, especially (only?) for the formal_ns of procedures. This was noticed when working on PR 40877 (memory leaks with gfc_charlen). E.g. in bounds_check_strlen_8.f90, the formal_ns of 'F1' is never freed up.
Reduced example: FUNCTION F1(a,b,c,d) RESULT(RES) CHARACTER(LEN=80), OPTIONAL :: a,b,c,d LOGICAL :: res END FUNCTION F1 When compiling this, gfc_free_namespace is called just once for the formal_ns of 'F1', but ns->refs is 3, so it is never freed. -- Summary: memory leaks with gfc_namespace Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: janus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41093