http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47637
Summary: Memory leak involving derived types w/ allocatable components Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: towns...@astro.wisc.edu Created attachment 23271 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23271 Source code plus makefile The attached test-case code (Makefile included) compiles fine with gfortran 4.6 on Mac OSX 10.6. However, when I run the code I get a significant memory leak. Valgrind reports: ==84427== LEAK SUMMARY: ==84427== definitely lost: 38,496,000 bytes in 4,000 blocks ==84427== indirectly lost: 0 bytes in 0 blocks ==84427== possibly lost: 0 bytes in 0 blocks ==84427== still reachable: 88 bytes in 1 blocks ==84427== suppressed: 0 bytes in 0 blocks ==84427== Rerun with --leak-check=full to see details of leaked memory The leaks are occurring with the st_l and st_r derived types in the evolve() subroutine in hydro_evolve.f90; it seems that the allocatable components of these variables are not being automatically deallocated when the recon() subroutine is called, even though the corresponding dummy arguments in recon() are declared as INTENT(out).. If I uncomment the deallocate statements in evolve(), so that I do the deallocation 'by hand', then the memory leak is fixed. So, a workaround is possible, but this seems to be quite a fundamental bug.