Skip to content

Commit

Permalink
Add custom deserialize method for UmfpackLU to avoid memory leak
Browse files Browse the repository at this point in the history
Fixes #15450
  • Loading branch information
andreasnoack committed Dec 17, 2018
1 parent 8b35e84 commit c3b5b2e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions stdlib/SuiteSparse/src/umfpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import LinearAlgebra: Factorization, det, lu, ldiv!
using SparseArrays
import SparseArrays: nnz

import Serialization: AbstractSerializer, deserialize

import ..increment, ..increment!, ..decrement, ..decrement!

include("umfpack_h.jl")
Expand Down Expand Up @@ -192,6 +194,22 @@ function show(io::IO, F::UmfpackLU)
F.numeric != C_NULL && print(io, '\n', F.numeric)
end

function deserialize(s::AbstractSerializer, t::Type{UmfpackLU{Tv,Ti}}) where {Tv,Ti}
symbolic = deserialize(s)
numeric = deserialize(s)
m = deserialize(s)
n = deserialize(s)
colptr = deserialize(s)
rowval = deserialize(s)
nzval = deserialize(s)
status = deserialize(s)
obj = UmfpackLU{Tv,Ti}(symbolic, numeric, m, n, colptr, rowval, nzval, status)

finalizer(umfpack_free_symbolic, obj)

return obj
end

## Wrappers for UMFPACK functions

# generate the name of the C function according to the value and integer types
Expand Down

0 comments on commit c3b5b2e

Please sign in to comment.