Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GC-safe region around Highs_run #178

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
@@ -1812,7 +1812,14 @@ function MOI.optimize!(model::Optimizer)
_set_variable_primal_start(model)
ret = Highs_zeroAllClocks(model)
_check_ret(ret)
ret = Highs_run(model)
# if `Highs_run` implicitly uses memory or other resources owned by `model`, preserve it
GC.@preserve model begin
# allow Julia to GC while this thread is in `Highs_run`
gc_state = ccall(:jl_gc_safe_enter, Int8, ())
ret = Highs_run(model)
# leave GC-safe region, waiting for GC to complete if it's running
ccall(:jl_gc_safe_leave, Cvoid, (Int8,), gc_state)
end
_store_solution(model, ret)
# TODO(odow): resetting the bounds here invalidates previously stored
# solutions.