From 96eb6b65cfbb51ab644f1ebe5186b452f1ed8e85 Mon Sep 17 00:00:00 2001 From: andrew-platt Date: Sun, 3 Dec 2023 11:34:10 -0700 Subject: [PATCH] ADI: probably memory leak in ADI_UpdateStates The ADI_UpdateStates routine makes a copy of the AD_Input, but never destroyed that data after usage. This could lead to memory continously getting allocated during a simulation with either ADI_C_Binding or the AD driver. --- modules/aerodyn/src/AeroDyn_Inflow.f90 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/aerodyn/src/AeroDyn_Inflow.f90 b/modules/aerodyn/src/AeroDyn_Inflow.f90 index e513c1085f..6dd7773665 100644 --- a/modules/aerodyn/src/AeroDyn_Inflow.f90 +++ b/modules/aerodyn/src/AeroDyn_Inflow.f90 @@ -228,10 +228,15 @@ subroutine ADI_UpdateStates( t, n, u, utimes, p, x, xd, z, OtherState, m, errSta ! Get state variables at next step: INPUT at step nt - 1, OUTPUT at step nt call AD_UpdateStates(t, n, u_AD(:), utimes(:), p%AD, x%AD, xd%AD, z%AD, OtherState%AD, m%AD, errStat2, errMsg2); if(Failed()) return + call CleanUp() + contains subroutine CleanUp() !call ADI_DestroyConstrState(z_guess, errStat2, errMsg2); if(Failed()) return + do it=1,size(utimes) + call AD_DestroyInput(u_AD(it), errStat2, errMsg2); if(Failed()) return + enddo end subroutine logical function Failed()