Closed mpf closed 4 years ago
Unless Julia changed recently, the [:]
at the end should make a
julia-managed copy of the array created by unsafe_wrap
.
On Mon, Jan 13, 2020, 06:16 Michael Friedlander notifications@github.com wrote:
The MOI.optimize! function extracts the solution variables from the ECOS problem structure using unsafe_wrap, eg, on this line https://github.com/JuliaOpt/ECOS.jl/blob/c59788be8a89922f5a420858042b1329b84451a8/src/MOI_wrapper.jl#L269 ,
primal = unsafe_wrap(Array, ecos_prob.x, n)[:]
Perhaps I misunderstand the implications of unsafe_wrap, but couldn't the subsequent call to cleanup, which calls free on the corresponding memory location, cause a problem?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JuliaOpt/ECOS.jl/issues/95?email_source=notifications&email_token=AANHIM2VF3L3DDXKA53YKVLQ5P2JTA5CNFSM4KF4RPOKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IFUUTZA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANHIM42DC7RKZCJCRQCX7DQ5P2JTANCNFSM4KF4RPOA .
Thanks for explaining, @mlubin! Yes, that makes sense.
The
MOI.optimize!
function extracts the solution variables from the ECOS problem structure usingunsafe_wrap
, eg, on this line,Perhaps I misunderstand the implications of
unsafe_wrap
, but couldn't the subsequent call tocleanup
, which callsfree
on the corresponding memory location, cause a problem?