# Debugging computer crash during ODE solve

**URL:** <https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009>\
**Category:** Modelling & Simulations\
**Created:** [November 9, 2022, 10:21pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009 "2022-11-09T22:21:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 9, 2022, 10:21pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/1 "2022-11-09T22:21:08Z")

</div>

My desktop solves a set of ODEs without issue, but my laptop consistently bluescreens while solving. What is the best way to find the cause of this behavior?

Thanks!

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 10, 2022, 10:48am UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/2 "2022-11-10T10:48:12Z")

</div>

I can’t say I have ever seen this. Is it a specific ODE or all of them?

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 10, 2022, 2:51pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/3 "2022-11-10T14:51:47Z")

</div>

So far I’ve only seen it with one PDE, and it only happens when I use symbolic\_discretize to do a structural simplify and then generate a symbolic jacobian.

if I use:

```julia
prob = ModelingToolkit.discretize(pdesys,discretization);
sol = solve(prob, QNDF(), saveat=delta_t);

```

it solves just fine, but if instead I use:

```julia
ode_sys, tspan = symbolic_discretize(pdesys, discretization);
simp_sys = structural_simplify(ode_sys);
ode_prob = ODEProblem(simp_sys, nothing, tspan, jac=true, sparse=true);
solve(ode_prob, QNDF(), saveat=delta_t)

```

it bluescreens my laptop.

I’m very interested in doing the work to find the problem, but I am having a hard time figuring out how to do post-mortem on Julia after a hard crash.

My suspicion right now is that it might have something to do with this warning I get about Symbolics with my equation structure, but I haven’t been able to make it work at all with the new syntax.

```julia
Warning: The variable syntax (u[1:n])(..) is deprecated. Use (u(..))[1:n] instead.
│ The former creates an array of functions, while the latter creates an array valued function.
│ The deprecated syntax will cause an error in the next major release of Symbolics.
│ This change will facilitate better implementation of various features of Symbolics.

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 10, 2022, 3:40pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/4 "2022-11-10T15:40:00Z")

</div>

> [@johnb](#):
>
> `solve(ode_prob, QNDF(), saveat=delta_t)`

Try `solve(ode_prob, QNDF(autodiff=false), saveat=delta_t)`. I wonder if it’s just a giant expression so the autodiff is taking a bunch of memory (and thus the comple time is big too)

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 10, 2022, 4:29pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/5 "2022-11-10T16:29:25Z")

</div>

I just tried it and it still crashed with `autodiff=false`. Looking at memory usage on my laptop vs desktop, the laptop does fill my RAM both with and without disabling autodiff, but the desktop doesn’t go past a few gigabytes. I have 16 GB on my laptop and 32 on my desktop, so I wouldn’t have expected either to have problems.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 10, 2022, 6:39pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/6 "2022-11-10T18:39:43Z")

</div>

During run or compilation?

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 10, 2022, 6:54pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/7 "2022-11-10T18:54:20Z")

</div>

I’m sorry, I’m not sure how to check that.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 10, 2022, 9:20pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/8 "2022-11-10T21:20:31Z")

</div>

How big of a discretization?

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [November 10, 2022, 9:23pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/9 "2022-11-10T21:23:36Z")

</div>

If this is MethodOfLines related, I’d like to see your system if you can share.

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 10, 2022, 9:33pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/10 "2022-11-10T21:33:39Z")

</div>

The discretization creates a set of ODEs with 606 equations, and after structural\_simplify, I am left with 600 equations for a discretization along a single axis in space plus time.

I am using MethodOfLines, and I will check with my PI to see if I can share the code.

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [November 10, 2022, 9:37pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/11 "2022-11-10T21:37:36Z")

</div>

Can you try passing the kwargs through `MOLFiniteDifference` with `discretize`? Like `MOLFiniteDifference([x => dx], t, jac = true, sparse = true)`, that should be equivalent to what you are doing - `structural_simplify` is run automatically when you call `discretize`.

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [November 14, 2022, 5:01pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/12 "2022-11-14T17:01:47Z")

</div>

Code has been shared privately and I have run a brief analysis of memory usage. Here is an excerpt of the code, showing the discretization and solves:

```julia
# Method of lines discretization
discretization = MOLFiniteDifference([x=>delta_x],t; approx_order=order)
discretization2 = MOLFiniteDifference([x=>delta_x],t; approx_order=order, jac = true, sparse = true)

println("Time for discretization:")
@time prob = ModelingToolkit.discretize(pdesys,discretization);
@time prob2 = ModelingToolkit.discretize(pdesys,discretization2);

println("Time for solving:")

@time sol = solve(prob, QNDF(), saveat=delta_t, reltol=1e-8, abstol=1e-8);

println("new method")
@time sol2 = solve(prob2, QNDF(), saveat=delta_t, reltol = 1e-8, abstol = 1e-8) # Massive Allocation

```

I have verified that the above construction of `prob2` is indistinguishable from the other method of problem construction @johnb detailed previously.  
Memory usage is remaining sensible (under 5GiB) until the solve of the “new method” shown here (bear in mind a solve without `jac=true, sparse=true` has been run previously), where memory shoots up to 37.5GiB, apparently during compile. This occurs with or without `autodiff=false`. I suspect this high memory usage is causing the crash, and my intuition tells me that this is occurring during compilation of the jacobian. I would be interested to know what @ChrisRackauckas thinks.  
After the solves, RSS drops to 36.9GiB, but a look at the size of all variables seen in the snippet shows them all to be on the order of a few tens of MB each, so I don’t know to what this memory is allocated.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [November 14, 2022, 5:28pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/13 "2022-11-14T17:28:45Z")

</div>

> [@xtalax](#):
>
> After the solves, RSS drops to 36.9GiB, but a look at the size of all variables seen in the snippet shows them all to be on the order of a few tens of MB each, so I don’t know to what this memory is allocated.

This may be memory fragmentation, and related to similar results I had when reading very large CSV files from the census:

> [@Determining size of DataFrame for memory management](https://discourse.julialang.org/t/determining-size-of-dataframe-for-memory-management/85277/34):
>
> If what you want to do is well known, then subselecting columns makes sense. If you start out wanting to explore what’s in the dataset… sometimes you just want to see what’s in there. But yeah, point taken!

With this issue filed:

> <https://github.com/JuliaLang/julia/issues/42566>
>
> This problem was \[originally reported in the helpdesk Slack\](https://julialang.s…lack.com/archives/C6A044SQH/p1633704159387700) against DataFrames, but I believe I have replicated it just using vectors of vectors.
> 
> OP was using Julia 1.5.0 with DataFrame 1.2.2 on Linux
> I used Julia 1.6.2 on WSL2 Ubuntu
> 
> Just using vectors, everything behaves as expected and julia's allocated memory does not increase:
> \`\`\`julia
> function inner\_df(Nrow,Ncol) # Create small dataframe
> rand(Nrow\*Ncol)
> end
> 
> function outer\_df(N) #Stack small dataframes
> Nrow=76
> Ncol=21
> df = Vector{Float64}(undef,0)
> for i = 1:N
> append!(df,inner\_df(Nrow,Ncol))
> end
> return df
> end
> 
> function iterated(Niter) # Create a large DataFrame many times.
> for i =1:Niter
> println(i)
> @time pan = outer\_df(1000\*10\*10)
> end
> nothing
> end
> 
> 
> \# (code and top lines after the code)
> iterated(1)
> GC.gc()
> \# 12142 user 20 0 1892304 215296 64744 S 0.0 1.3 0:19.41 julia
> iterated(10)
> GC.gc()
> \# 12142 user 20 0 1892416 226740 65412 S 0.0 1.4 1:51.96 julia
> iterated(10)
> GC.gc()
> \# 12142 user 20 0 1892416 227000 65416 S 0.0 1.4 3:25.04 julia
> iterated(20)
> GC.gc()
> \# 12142 user 20 0 1892416 227104 65416 S 0.0 1.4 6:32.83 julia
> \`\`\`
> 
> Using vectors of vectors, there seems to be a memory leak:
> \`\`\`julia
> function inner\_df(Nrow,Ncol) # Create small dataframe
> \[rand(Nrow) for i in 1:Ncol\]
> end
> 
> function outer\_df(N) #Stack small dataframes
> Nrow=76
> Ncol=21
> df=\[Vector{Float64}(undef, 0) for i in 1:Ncol\]
> for i = 1:N
> df2 = inner\_df(Nrow,Ncol)
> for j in 1:Ncol
> append!(df\[j\],df2\[j\])
> end
> end
> return df
> end
> 
> function iterated(Niter) # Create a large DataFrame many times.
> for i =1:Niter
> println(i)
> @time pan = outer\_df(1000\*10\*10)
> end
> nothing
> end
> 
> 
> \# (code and top lines after code)
> iterated(1)
> GC.gc()
> \# 9204 user 20 0 2275056 216848 64844 S 0.0 1.3 0:15.61 julia
> iterated(10)
> GC.gc()
> \# 9204 user 20 0 3339728 952280 64844 S 0.0 5.7 1:06.03 julia
> iterated(10)
> GC.gc()
> \# 9204 user 20 0 3339728 952876 64844 S 0.0 5.7 1:55.75 julia
> iterated(20)
> GC.gc()
> \# 9204 user 20 0 3343824 953112 64964 S 0.0 5.7 3:31.63 julia
> \`\`\`
> 
> Please feel free to close if this is a vagary of Linux memory management.

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 14, 2022, 8:25pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/14 "2022-11-14T20:25:42Z")

</div>

If I’m reading that issue right, it sounds like that was a Linux and maybe macOS issue. Both of my machines are on Windows, but I’m not sure how Windows deals with memory allocations.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 15, 2022, 8:39am UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/15 "2022-11-15T08:39:05Z")

</div>

> [@xtalax](#):
>
> This occurs with or without `autodiff=false`.

Yes, that is completely unused when analytical Jacobians are given.

> [@xtalax](#):
>
> I suspect this high memory usage is causing the crash, and my intuition tells me that this is occurring during compilation of the jacobian

Yes, and we knew this could happen. We need to do the Jacobian codegen in a different way.

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 15, 2022, 5:01pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/16 "2022-11-15T17:01:58Z")

</div>

Is this related to these issues in Symbolics.jl?

[compile time sparse derivatives · Issue #788 · JuliaSymbolics/Symbolics.jl · GitHub](https://github.com/JuliaSymbolics/Symbolics.jl/issues/788)

> <https://github.com/JuliaSymbolics/Symbolics.jl/issues/606>
>
> Hi everyone, 
> 
> I am trying to generate a symbolic Jacobian function for solvin…g the Cahn-Hilliard PDE in time and two spatial dimensions. For small systems (for example Nx=Ny=21), it works great. For larger systems (Nx=Ny=101), the code crashes when running the Jacobian function (I am pretty sure due to memory requirements during compilation). Is there any way to get around this? Code is below:
> \`\`\`julia
> Δx = 0.01
> Δy = 0.01
> Nx = length(collect(0:Δx:1))
> Ny = length(collect(0:Δy:1))
> κ = 0.002
> limit(a, N) = a == N+1 ? N-1 : a == 0 ? 2 : a
> 
> function CH\_loop2D(du,up,p,t)
> u = reshape(up,(Nx,Ny))
> dut = copy(u)
> D = p\[1\]
> j\_func = function (i, j)
> ip1x, im1x, ip1y, im1y = limit(i+1, Nx), limit(i-1, Nx), limit(j+1, Ny), limit(j-1, Ny)
> return log(max(1e-10,u\[i,j\]/(1-u\[i,j\]))) + 3.0\*(1-2.0\*u\[i,j\]) - κ\*(u\[i,ip1y\]+u\[ip1x,j\]-4.0\*u\[i,j\]+u\[im1x,j\]+u\[i,im1y\])/(Δx\*Δy)
> end
>     
> for i in 1:Nx
> for j in 1:Ny
> ip1,im1,jp1,jm1 = limit(i+1,Nx), limit(i-1,Nx), limit(j+1,Ny), limit(j-1,Ny)
>             
> mu\_ij = j\_func(i,j)
> mu\_im1j = j\_func(im1,j)
> mu\_ip1j = j\_func(ip1,j)
> mu\_ijm1 = j\_func(i,jm1)
> mu\_ijp1 = j\_func(i,jp1)
>             
> dut\[i,j\] = D\*(((u\[ip1,j\]-u\[im1,j\])/(2.0\*Δx))\*((mu\_ip1j-mu\_im1j)/(2.0\*Δx)) + ((u\[i,jp1\]-u\[i,jm1\])/(2.0\*Δy))\*((mu\_ijp1-mu\_ijm1)/(2.0\*Δy)) + u\[i,j\]\*(mu\_ip1j+mu\_ijp1-4.0mu\_ij+mu\_im1j+mu\_ijm1)/(Δx\*Δy))
>         
> end
> end
> du .= dut\[:\]
> return nothing
> 
> end
> 
> p = \[0.1\]
> tspan = (0.0,0.1)
> u0 = 0.5 .+ 0.1.\*rand(Nx\*Ny)
> 
> @variables u\_sym\[1:length(u0)\] p\_sym\[1:length(p)\] t\_sym
> u\_sym = collect(u\_sym)
> p\_sym = collect(p\_sym)
> du\_sym = similar(u\_sym)
> CH\_loop2D(du\_sym,u\_sym,p\_sym,t\_sym)
> 
> J\_sym = Symbolics.sparsejacobian(du\_sym, u\_sym)
> 
> f! = eval(build\_function(du\_sym, u\_sym, p\_sym, t\_sym)\[2\])
> J! = eval(build\_function(J\_sym, u\_sym, p\_sym, t\_sym)\[2\])
> 
> j = Symbolics.value(substitute(J\_sym, (Dict(u\_sym=\>rand(length(u\_sym))))))
> 
> ut = rand(length(u0))
> t = 0.0
> p = \[0.5\]
> @time J!(j,ut,p,t)
> \`\`\`
> 
> The kernel crashes so I don't get an error message.
> 
> My package versions are:
> \`\`\`julia
> Status \`~/.julia/environments/v1.7/Project.toml\`
> \[6e4b80f9\] BenchmarkTools v1.3.1
> \[13f3f980\] CairoMakie v0.8.3
> \[41bf760c\] DiffEqSensitivity v6.74.0
> \[0c46a032\] DifferentialEquations v7.1.0
> \[7073ff75\] IJulia v1.23.3
> \[c3572dad\] Sundials v4.9.4
> \[0c5d862f\] Symbolics v4.5.1
> \[37e2e46d\] LinearAlgebra
> \`\`\`

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 15, 2022, 5:09pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/17 "2022-11-15T17:09:33Z")

</div>

Yup same issue.

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 15, 2022, 11:54pm UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/18 "2022-11-15T23:54:20Z")

</div>

Found an older issue that seems related as well. I guess this has been a known issue for a while, but I’m having trouble finding any breadcrumbs for a workaround. Am I missing something, or is this just a limitation for some systems?

> <https://github.com/JuliaSymbolics/Symbolics.jl/issues/326>
>
> Some benchmarks for Symbolics.jacobian\_sparsity demonstrating that speed can be …marginal (and ~40x slower than SparsityTracing https://github.com/PALEOmodel/SparsityTracing.jl which is a minimalist tracing approach). Simplified example here with 50000 state variables takes ~20s with Symbolics - actual code is 10x this or more.
> 
> \`\`\`julia
> import SparsityTracing # formerly ADelemtree
> import Symbolics
> using BenchmarkTools
> 
> \# define a random chemical reaction network with nreactions among nspecies in each of ncells
> ncells = 1000
> nspecies = 50
> nreactions = 200
> 
> r1idx = rand(1:nspecies, nreactions); # reactant 1 species
> r2idx = rand(1:nspecies, nreactions); # reactant 2 species
> pidx = rand(1:nspecies, nreactions); # product species
> 
> p = (ncells, nspecies, r1idx, r2idx, pidx);
> 
> \# time derivative of species concentrations for idealized reaction network 
> function react!(du\_vec, u\_vec, p)
> ncells, nspecies, r1idx, r2idx, pidx = p
> u = reshape(u\_vec, nspecies, ncells)
> du = reshape(du\_vec, nspecies, ncells)
> du .= 0.0
> for i in 1:ncells
> for (r1i, r2i, pi) in zip(r1idx, r2idx, pidx)
> rate = u\[r1i, i\]\*u\[r2i, i\]
> du\[r1i, i\] -= 0.1234\*rate # implausible stoichiometries for test purposes
> du\[r2i, i\] -= 0.2345\*rate
> du\[pi, i\] += 0.3456\*rate
> end
> end
>     
> return nothing
> end
> 
> u = ones(nspecies\*ncells);
> du = zeros(nspecies\*ncells);
> 
> println("benchmark function call:")
> @time react!(du, u, p)
> @time react!(du, u, p)
> @time react!(du, u, p)
> \`\`\`
> 
> benchmark function call:
> 0.070629 seconds (240.95 k allocations: 14.479 MiB, 98.67% compilation time)
> 0.000889 seconds (4 allocations: 192 bytes)
> 0.000905 seconds (4 allocations: 192 bytes)
> 
> 
> \`\`\`julia
> println("benchmark SparsityTracing")
> u\_ad = SparsityTracing.create\_advec(u);
> du\_ad = similar(u\_ad);
> println(" function call:")
> @time react!(du\_ad, u\_ad, p)
> @time react!(du\_ad, u\_ad, p)
> @time react!(du\_ad, u\_ad, p)
> println(" jacobian:")
> @time Jst = SparsityTracing.jacobian(du\_ad, length(u\_ad));
> @time Jst = SparsityTracing.jacobian(du\_ad, length(u\_ad));
> @time Jst = SparsityTracing.jacobian(du\_ad, length(u\_ad));
> \`\`\`
> 
> benchmark SparsityTracing
> function call:
> 0.381003 seconds (2.55 M allocations: 88.460 MiB, 16.16% gc time, 35.22% compilation time)
> 0.204951 seconds (2.40 M allocations: 79.346 MiB, 11.08% gc time)
> 0.223499 seconds (2.40 M allocations: 79.346 MiB, 17.41% gc time)
> jacobian:
> 1.391276 seconds (4.15 M allocations: 300.907 MiB, 34.48% gc time, 56.99% compilation time)
> 0.252109 seconds (2.85 M allocations: 226.638 MiB, 9.84% gc time)
> 0.258635 seconds (2.85 M allocations: 226.638 MiB, 16.48% gc time)
> 
> 
> \`\`\`julia
> println("benchmark Symbolics")
> Symbolics.@variables u\_sym\[1:length(u)\];
> u\_sym\_s = Symbolics.scalarize(u\_sym);
> du\_sym\_s = similar(u\_sym\_s);
> println(" function call:")
> @time react!(du\_sym\_s, u\_sym\_s, p)
> @time react!(du\_sym\_s, u\_sym\_s, p)
> @time react!(du\_sym\_s, u\_sym\_s, p)
> println(" jacobian\_sparsity:")
> @time Jsym = Float64.(Symbolics.jacobian\_sparsity(du\_sym\_s, u\_sym\_s));
> @time Jsym = Float64.(Symbolics.jacobian\_sparsity(du\_sym\_s, u\_sym\_s));
> @time Jsym = Float64.(Symbolics.jacobian\_sparsity(du\_sym\_s, u\_sym\_s));
> \`\`\`
> 
> benchmark Symbolics
> function call:
> 10.942955 seconds (62.87 M allocations: 2.829 GiB, 22.33% gc time, 12.15% compilation time)
> 9.523435 seconds (59.88 M allocations: 2.661 GiB, 22.74% gc time)
> 9.695355 seconds (59.88 M allocations: 2.661 GiB, 22.44% gc time)
> jacobian\_sparsity:
> 35.813055 seconds (234.05 M allocations: 8.488 GiB, 12.64% gc time, 8.15% compilation time)
> 13.600838 seconds (88.15 M allocations: 3.666 GiB, 8.12% gc time)
> 13.384328 seconds (88.15 M allocations: 3.666 GiB, 6.25% gc time)
> 
> 
> \`\`\`julia
> \# check 
> Jst.nzval .= 1.0
> println("Jacobians equal: ", Jst == Jsym)
> \`\`\`
> 
> Jacobians equal: true
> 
> 
> 
> ┆Issue is synchronized with this \[Trello card\](https://trello.com/c/ff3OtEJ5) by \[Unito\](https://www.unito.io)

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [November 16, 2022, 12:12am UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/19 "2022-11-16T00:12:41Z")

</div>

John - This seems to be a limitation of the jacobian code generation, when that jacobian code is being generated from certain types of PDE code. This is likely a structural thing with the way jacobian code generation is implemented at the moment, so the implementation will need to be fixed first. This sort of code generation is a relatively new approach , so people are still trying to iron the problems out - but rest assured that this is being looked at, and that more attention is on it now.

Is there any way that in the meantime that you could approach your problem without automatic jacobian generation, or more memory? Or is this a hard limitation?

---

<div class="post-metadata">

**Author:** ![johnb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnb/32/44115_2.png) [@johnb](https://discourse.julialang.org/u/johnb)\
**Post date:** [November 16, 2022, 12:25am UTC](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009/20 "2022-11-16T00:25:42Z")

</div>

I apologize, I didn’t intend to sound like I was trying to push too hard for a quick fix! I can definitely use more traditional strategies to solve my problem, and it’ll give me more breaks anyway. 🙂

Thank you for your help in troubleshooting, and for the insight into how the packages work together.

[Next page](https://discourse.julialang.org/t/debugging-computer-crash-during-ode-solve/90009.md?page=2)
