Skip to content

Commit

Permalink
add free to fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
baperry2 committed Feb 12, 2025
1 parent 574b74e commit 3a45c2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Exec/RegTests/HITDecay/pelelmex_prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,14 @@ PeleLM::readProbParm() // NOLINT(readability-make-member-function-const)
amrex::Gpu::hostToDevice, winput.begin(), winput.end(),
PeleLM::prob_parm->d_winput);
}

void
PeleLM::freeProbParm()
{
amrex::Print() << "Freeing prob parm" << std::endl;
amrex::The_Arena()->free(PeleLM::prob_parm->d_xarray);
amrex::The_Arena()->free(PeleLM::prob_parm->d_xdiff);
amrex::The_Arena()->free(PeleLM::prob_parm->d_uinput);
amrex::The_Arena()->free(PeleLM::prob_parm->d_vinput);
amrex::The_Arena()->free(PeleLM::prob_parm->d_winput);
}
2 changes: 2 additions & 0 deletions Exec/RegTests/HITDecay/pelelmex_prob_parm.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <AMReX_REAL.H>
#include <AMReX_GpuMemory.H>

#define PELE_PROB_PARM_NEEDS_FREEING

using namespace amrex::literals;

struct ProbParm
Expand Down
1 change: 1 addition & 0 deletions Source/PeleLMeX.H
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public:

// ReadProblemParameters
void readProbParm();
void freeProbParm();

// ReadGridFile
void
Expand Down
4 changes: 3 additions & 1 deletion Source/PeleLMeX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ PeleLM::~PeleLM()

closeTempFile();
typical_values.clear();

#ifdef PELE_PROB_PARM_NEEDS_FREEING
freeProbParm();
#endif
delete prob_parm;
The_Arena()->free(prob_parm_d);
m_initial_ba.clear();
Expand Down

0 comments on commit 3a45c2d

Please sign in to comment.