I’m trying to figure out what’s happening here. Running the following example:
using DifferentialEquations, Plots function usode!(du,u,p,t) C1 = 1.63e-9 RS = 791.0 C2 = 3.3e-9 C0 = 0.3e-9 L1 = 1e-3 L2 = 82e-3 CM = 4e-12 LM = 8.0 RM = 7500.0 VC1, VC2, VC0, VCM, IL1, IL2, ILM, Vp = u fv, VAmag = p VA = VAmag*sinpi(2*Vp) du = 1/C1*IL1 du = -1/C2*IL1 du = 1/C0*(IL1-IL2-ILM) du = 1/CM*ILM du = 1/L1*(VA-VC1-VC0-VC2-IL1*RS) du = 1/L2*VC0 du = 1/LM*(VC0-VCM-ILM*RM) du = fv end mutable struct Controller f::Float64 end function(c::Controller)(integrator) integrator.p = c.f if c.f < 30000.0 c.f += 15.0 end #println(integrator.t) end function sim() p = [0.0, 100.0] cb1 = PeriodicCallback(Controller(27000.0),0.005) cbs = CallbackSet(cb1,) u0 = [0.0,0.0,0.0,0.0, 0.0,0.0,0.0, 0.0] tspan = [0.0, 1.1] prob = ODEProblem(usode!,u0,tspan,p) @time sol = solve(prob,Tsit5(), callback=cbs, reltol=1e-8, abstol=1e-8, maxiters=10_000_000) sol end sol = sim() sol=nothing sol=sim() sol=nothing sol=sim() sol=nothing sol=sim()
sim() call makes an object that nearly consumes my computer’s RAM. On the repeated executions, the memory gets released (garbage collected) and then we build it again.
After completion of the script, if I execute another
sol=nothing followed by
sol=sim() (either by doing Ctrl-Enter on the appropriate lines, or by typing the commands in at the REPL), the memory does not get released (and my computer crawls to a halt). I suspect something different happens in the Juno environment that prevents the previous
sol object from getting collected. Adding a
GC.gc() does not seem to help here.
Any thoughts as to what’s going on?