The method ldiv! has very large allocations happening for sparse LU factorizations. See the example below:
using SparseArrays
using LinearAlgebra
N = 1000
A = sparse(I, N, N) + sprand(N, N, .01)
fact = lu(A)
b = rand(N)
x = zeros(N)
@time ldiv!(x, fact, b)
#Convert to a full matrix and recompute the factorization
A = Matrix(A)
fact = lu(A)
@time ldiv!(x, fact, b);
A characteristic test runs gives
0.001000 seconds (2 allocations: 46.906 KiB)
0.000669 seconds (2 allocations: 96 bytes)
The case of the sparse LU decomposition causes a large amount of memory allocation in ldiv! when I would expect it to no different from the case of a dense matrix.
This is on Julia Version 1.6.1.