Memory leak using spmCheckAndCorrect in Fortran
When calling spmCheckAndCorrect, an spm instance is not freed.
I can see the memory leak using valgrind on the example flaplacian.
call spmCheckAndCorrect( spm, spm2 ) if (.not. c_associated(c_loc(spm), c_loc(spm2))) then deallocate(rowptr) deallocate(colptr) deallocate(values) spm%rowptr = c_null_ptr spm%colptr = c_null_ptr spm%values = c_null_ptr call spmExit( spm ) spm = spm2 end if
==16403== 96 bytes in 1 blocks are definitely lost in loss record 189 of 231 ==16403== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==16403== by 0x612022A: spmCopy (spm.c:762) ==16403== by 0x6120A4D: spmCheckAndCorrect (spm.c:687) ==16403== by 0x516E018: __spmf_MOD_spmcheckandcorrect (spmf.f90:558) ==16403== by 0x401C38: MAIN__ (flaplacian.f90:119) ==16403== by 0x40172C: main (flaplacian.f90:15)
I have the same memory leak with MaPHyS.
For some reason it is not the case with fsimple and fstep-by-step, but things are allocated differently so I cannot figure out why the memory leak does not occur there.