From 48d62e75015dc33718dd4b16b01f591680564bf1 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Sun, 29 Mar 2020 23:01:24 -0500 Subject: [PATCH] A few updates to address memory leaks. --- include/openmc/mesh.h | 2 +- include/openmc/settings.h | 2 +- src/finalize.cpp | 2 +- src/initialize.cpp | 2 +- src/mesh.cpp | 4 +--- src/settings.cpp | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index c0b1dbefcd..318fa3fe70 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -600,7 +600,7 @@ private: std::unique_ptr m_; //!< pointer to the libmesh mesh instance std::vector> point_locators_; //!< pointers to locators for each thread std::unique_ptr equation_systems_; //!< pointer to the equation systems of the mesh (for result output) - std::map variable_map_; //!< mappint of variable names (scores) to their numbers on the mesh + std::map variable_map_; //!< mapping of variable names (scores) to their numbers on the mesh libMesh::BoundingBox bbox_; //!< bounding box of the mesh libMesh::Sphere bsphere_; // LMI; #endif // Boolean flags diff --git a/src/finalize.cpp b/src/finalize.cpp index f42e3134af..084ed24b83 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -143,7 +143,7 @@ int openmc_finalize() #endif #ifdef LIBMESH - delete settings::LMI; +std::unique_ptr LMI; #endif return 0; diff --git a/src/initialize.cpp b/src/initialize.cpp index 3b1abfc9ae..e6ca245c05 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -73,7 +73,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm) #endif #ifdef LIBMESH - settings::LMI = new libMesh::LibMeshInit(argc, argv); + settings::LMI = std::make_unique(argc, argv); #endif diff --git a/src/mesh.cpp b/src/mesh.cpp index 375127bd8c..40bd5858c3 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -2195,8 +2195,7 @@ void LibMesh::initialize() { eq_system_name_ = "mesh_" + std::to_string(id_) + "_system"; - equation_systems_ = - std::unique_ptr(new libMesh::EquationSystems(*m_)); + equation_systems_ = std::make_unique(*m_); libMesh::ExplicitSystem& eq_sys = equation_systems_->add_system(eq_system_name_); @@ -2307,7 +2306,6 @@ void LibMesh::write(const std::string& filename) const { exo.write_discontinuous_exodusII(filename, *equation_systems_, &systems_out); } - void LibMesh::bins_crossed(const Particle* p, std::vector& bins, diff --git a/src/settings.cpp b/src/settings.cpp index 21ce932ad5..3326f0029a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -38,7 +38,7 @@ namespace openmc { namespace settings { #ifdef LIBMESH -libMesh::LibMeshInit* LMI; +std::unique_ptr LMI; #endif // Default values for boolean flags