https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91537
Bug ID: 91537 Summary: Memory leak involving nested allocatable derived types Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: townsend at astro dot wisc.edu Target Milestone: --- Created attachment 46748 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46748&action=edit Leak demonstration program The attached test program demonstrates a memory leak on gfortran 8.3.0. Intriguingly, valgrind reports no leak; but the memory usage grows steadily over time, even though only ALLOCATABLE arrays are used. By the end of execution, 4GB is being used. To demonstrate the memory growth, I use the routine system_mem_usage, which looks at files inside /proc to find the current RSS. Of course, this only works on Linux -- for those on other platforms, you may have to comment out (or rework) the call. Typical output is as follows (from ./test_leak_new | tail -10): 91 3682816 92 3722680 93 3762808 94 3802672 95 3842800 96 3882664 97 3922792 98 3962656 99 4002784 100 4042648 The first number is the iteration number, the second is the RSS. So, 4GB by the end of execution, despite the fact that bp is explicitly deallocated at the end of each loop. The test program may seem a little contrived, but it's a cut-down version of production code (which shows the same valgrind-invisible leak behavior). cheers, Rich