Free memory from direct_iteration and direct_output by bmunguia · Pull Request #929 · su2code/SU2

The output isn't leak-free otherwise. Those were just a couple of the bigger ones that were easy to track down. I think the rest are mainly CoDi/MeDi-related leaks, though. Keep in mind I ran this on feature_adap_sst (the line numbers below are for this branch though) so some of these might be resolved:

  • A leak in C2DContainers that Pedro already fixed in WIP Feature hybrid parallel and SIMD #895 so I was gonna leave it alone
  • Probably the largest remaining leak is from the calls to AD::StartExtFunc(), AD::SetExtFuncIn(), and AD::SetExtFuncOut() in CSysSolve.cpp during DirectRun(). These are all related to CoDi's ExternalFunctionHelper
  • Line 537 in adt_structure.cpp (CADTElemClass::CADTElemClass()). This seems to be related to various functions in MeDi including createLinearIndexCounts(), AMPI_Allgatherv() (might be a false positive), and ADToolImplCommon()
SU2_MPI::Allgatherv(val_coor.data(), sizeLocal, MPI_DOUBLE, coorPoints.data(),
                        recvCounts.data(), displs.data(), MPI_DOUBLE, MPI_COMM_WORLD);
  • Line 715 in CGeometry.cpp (CGeometry::PostP2PSends()). This is only called when val_reverse is false, which is duringSetDependencies() and DirectRun(). These all seem to be related to ADToolImplCommon()
SU2_MPI::Isend(&(bufD_P2PSend[offset]), count, MPI_DOUBLE,
                       dest, tag, MPI_COMM_WORLD, &(req_P2PSend[iMessage]));

I've attached the valgrind log from one of the cores below, in case anyone really wants to parse it
vg.txt