From 47a17c0c19a3e766962ba3073187a5c4139ca2cf Mon Sep 17 00:00:00 2001 From: jjospina Date: Thu, 1 Aug 2024 14:31:14 -0600 Subject: [PATCH] FIX: issue of not being able to remove processes due to getting stuck whe calling remote_do function --- src/core/base.jl | 3 +++ src/core/multiprocessing.jl | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/core/base.jl b/src/core/base.jl index 6a1e855..452715c 100755 --- a/src/core/base.jl +++ b/src/core/base.jl @@ -853,6 +853,9 @@ function solve_model( # Force call Garbage collector to reduce RAM usage GC.gc() + # Remove Processes + Distributed.rmprocs(Distributed.workers()) + elseif (typeof(optimizer) == _SDO.MultiThreadOptimizer) # Instantiate the Decomposition PowerModelsITD object. diff --git a/src/core/multiprocessing.jl b/src/core/multiprocessing.jl index baca901..c31e0bf 100644 --- a/src/core/multiprocessing.jl +++ b/src/core/multiprocessing.jl @@ -25,6 +25,8 @@ function optimize_subproblem_multiprocessing( export_models::Bool=false ) + @info "Enter optimize_subproblem_multiprocessing() function" + # Instantiate the PMD model subproblem_instantiated = _IM.instantiate_model(data, type, @@ -84,6 +86,13 @@ function optimize_subproblem_multiprocessing( close(mp_string_rc) close(sp_string_rc) + # Clear references to help the garbage collector + subproblem_instantiated = nothing + subprob_linking_vars_vector = nothing + result = nothing + result_json = nothing + data = nothing + # Clean everything before leaving process GC.gc()