I rewrote my code to not use a `Symbolics`

`@reaction_network`

, similar to your implementation, but I do see the increase in memory allocations still (albeit a bit less)…

#
Code

(I didn’t want to hide your discussion in my long functions, so here’s a fold:

##
See code details here

```
function catalystplasmiddirect(;T = 100.0)
function rate(η,X,Y,K)
return η*(1-(X+Y)/K)
end
r1(u,p,t) = rate(p[1],u[1],u[2],p[2])*u[1]
r2(u,p,t) = rate(p[1],u[2],u[1],p[2])*u[2]
r3(u,p,t) = p[3]*u[1]
r4(u,p,t) = p[3]*u[2]
r5(u,p,t) = p[4]*u[1]*u[2]
r6(u,p,t) = p[5]*u[2]
aff1!(integrator) = integrator.u[1] += 1
aff2!(integrator) = integrator.u[2] += 1
aff3!(integrator) = integrator.u[1] -= 1
aff4!(integrator) = integrator.u[2] -= 1
function aff5!(integrator)
integrator.u[1] -= 1
integrator.u[2] += 1
end
function aff6!(integrator)
integrator.u[1] += 1
integrator.u[2] -= 1
end
# η K μ γ ρ
p = (1.0, 1e4, 0.1, 1e-4, 0.01)
u0 = [1000,10]
tspan = (0.0, T)
dprob = DiscreteProblem(u0, tspan, p)
jprob = JumpProblem(
dprob, Direct(),
ConstantRateJump(r1,aff1!), ConstantRateJump(r2,aff2!), ConstantRateJump(r3,aff3!),
ConstantRateJump(r4,aff4!), ConstantRateJump(r5,aff5!), ConstantRateJump(r6,aff6!);
save_positions=(false,false)
)
return jprob
end
```

And the benchmarks:

```
julia> long_prob = catalystplasmiddirect(T=1e5)
JumpProblem with problem DiscreteProblem with aggregator Direct
Number of jumps with discrete aggregation: 6
Number of jumps with continuous aggregation: 0
Number of mass action jumps: 0
julia> long_sol = solve(long_prob, stepper)
retcode: Success
Interpolation: Piecewise constant interpolation
t: 2-element Vector{Float64}:
0.0
100000.0
u: 2-element Vector{Vector{Int64}}:
[1000, 10]
[98, 8850]
julia> @btime solve($long_prob, $stepper)
11.082 s (195816952 allocations: 2.92 GiB)
retcode: Success
Interpolation: Piecewise constant interpolation
t: 2-element Vector{Float64}:
0.0
100000.0
u: 2-element Vector{Vector{Int64}}:
[1000, 10]
[96, 8951]
julia> short_prob = catalystplasmiddirect(T=1e2)
JumpProblem with problem DiscreteProblem with aggregator Direct
Number of jumps with discrete aggregation: 6
Number of jumps with continuous aggregation: 0
Number of mass action jumps: 0
julia> short_sol = solve(short_prob, stepper)
retcode: Success
Interpolation: Piecewise constant interpolation
t: 2-element Vector{Float64}:
0.0
100.0
u: 2-element Vector{Vector{Int64}}:
[1000, 10]
[92, 8892]
julia> @btime solve($short_prob, $stepper)
10.677 ms (204394 allocations: 3.12 MiB)
retcode: Success
Interpolation: Piecewise constant interpolation
t: 2-element Vector{Float64}:
0.0
100.0
u: 2-element Vector{Vector{Int64}}:
[1000, 10]
[118, 8933]
```