# Optim.jl and runtime dispatch detected errors

**URL:** https://discourse.julialang.org/t/optim-jl-and-runtime-dispatch-detected-errors/125981
**Category:** Optimization (Mathematical)
**Created:** [February 17, 2025, 10:54am UTC](https://discourse.julialang.org/t/optim-jl-and-runtime-dispatch-detected-errors/125981 "2025-02-17T10:54:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Miroboru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miroboru/32/47659_2.png) [@Miroboru](https://discourse.julialang.org/u/Miroboru)
#### Post date: [February 17, 2025, 10:54am UTC](https://discourse.julialang.org/t/optim-jl-and-runtime-dispatch-detected-errors/125981/1 "2025-02-17T10:54:38Z")

</div>

I have a piece of simulation software that makes millions of calls to Optim.optimize during runs. I seemingly have a lot of allocations, so I use JET and tested my code with @report\_opt. The result was a large number of “runtime dispatch detected errors”. To verify that everything was ok I then ran the small toy problem from the Optim.jl tutorial:

```julia
using JET
using Optim
f(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
x0 = [0.0, 0.0]
@report_opt optimize(f, x0)

```

The result is 71 possible errors found. Is this to be expected, or are there optimizations I am not aware of?

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [February 17, 2025, 6:36pm UTC](https://discourse.julialang.org/t/optim-jl-and-runtime-dispatch-detected-errors/125981/2 "2025-02-17T18:36:23Z")

</div>

Runtime dispatch is expected with Optim.

If you make a post with your real problem, people may have suggestions for how to improve it, or reduce the number of allocations.
