Skip to content

Commit

Permalink
FIX: issue of not being able to remove processes due to getting stuck…
Browse files Browse the repository at this point in the history
… whe calling remote_do function
  • Loading branch information
juanjospina committed Aug 1, 2024
1 parent 5743b10 commit 47a17c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions src/core/multiprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 47a17c0

Please sign in to comment.