# Heroku – Memory quota vastly exceeded

**URL:** <https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562>\
**Category:** Performance\
**Tags:** question, cloud-computing, dash\
**Created:** [October 28, 2021, 3:18pm UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562 "2021-10-28T15:18:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cepel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cepel/32/30275_2.png) [@cepel](https://discourse.julialang.org/u/cepel)\
**Post date:** [October 28, 2021, 3:18pm UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/1 "2021-10-28T15:18:01Z")

</div>

Hey there, I developed a [Julia application](https://discourse.julialang.org/t/object-detection-with-yolov3-and-plotlyjs/70540) using Dash and ObjectDetector, and deployed on Heroku. But I am having “R15 - Memory quota vastly exceeded” error.

 ![heroku_memory](https://global.discourse-cdn.com/julialang/original/3X/1/7/17028d6dc0c399cba4a77fa221e5e70cf8318d65.png)

I checked the memory usage on my local computer and the application (running in command line) uses about 1200MB~1600MB. Heroku dynos are quite expensive, for example (2.5GB memory) $250 dyno per month.

I just want to know something:

- Is 1200MB~1600MB normal for such application? I didn’t compare but never faced with a memory problem while working in Python.
- Is there a way to reduce memory usage? I tried PackaceCompiler but resulted almost no changes.

That’s all, thank you! 🙂

P.S. If you wonder, [**click here**](https://github.com/tolgahancepel/dash-julia-applications/blob/main/objectdetector-yolo/app.jl) for the code.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [October 28, 2021, 3:19pm UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/2 "2021-10-28T15:19:43Z")

</div>

It might be worth profiling your code to see where the memory usage is coming from.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 28, 2021, 3:24pm UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/3 "2021-10-28T15:24:05Z")

</div>

I have also tried to make very minimal Julia applications and in my experience there isn’t really a way to get away with \<1GB of RAM. I even tried creating custom sysimages without unused standard libraries and such.

---

<div class="post-metadata">

**Author:** ![cepel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cepel/32/30275_2.png) [@cepel](https://discourse.julialang.org/u/cepel)\
**Post date:** [October 28, 2021, 3:33pm UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/4 "2021-10-28T15:33:10Z")

</div>

Exactly. Even the application is low-code and simple, uses more than 500MB. I also saw similar comments about memory usage, so it seems normal for the app. Sysimages reduced running time but not memory usage, unfortunately. Thank you @fredrikekre

---

<div class="post-metadata">

**Author:** ![valeroc](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@valeroc](https://discourse.julialang.org/u/valeroc)\
**Post date:** [October 29, 2021, 2:48am UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/5 "2021-10-29T02:48:01Z")

</div>

I have also noticed the high memory usage of some simple julia apps. Maybe it’s worth investing on a small server!

---

<div class="post-metadata">

**Author:** ![waralex](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/waralex/32/13415_2.png) [@waralex](https://discourse.julialang.org/u/waralex)\
**Post date:** [October 29, 2021, 8:11am UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/6 "2021-10-29T08:11:57Z")

</div>

To be honest, I’ve never profiled Dash for memory usage. I will do this in the near future ,if I find unjustified excessive memory usage, I will fix it… But most likely the memory is used during JIT compilation. It is possible that using JSON 3 instead of JSON2 in Dash, which I plan to release next week, will slightly improve the situation.

Thank you very much for pointing out the problem. I will try to come up with ways to solve it, but it is with the use of memory that I am not sure that a good solution exists.

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [October 29, 2021, 8:31am UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/7 "2021-10-29T08:31:13Z")

</div>

I have a [fly.io](http://fly.io) server running with Makie.jl and HypothesisTests.jl on a steady 750 MB memory usage. It wasn’t easy to set up though. The trick seemed to be that everything ( **edit** : most things) should be precompiled and included inside the Docker so that the production image doesn’t have to load other things. For example, I also had to explicitly load `MKL_jll` to include the `MKL` binary. Without doing that, memory went to 1.6 GB. The Docker is based on Ubuntu. A docker based on Nix needed the same amount of memory. Alpine was an enormous hassle to get working with Makie, so I gave up on that.

---

<div class="post-metadata">

**Author:** ![waralex](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/waralex/32/13415_2.png) [@waralex](https://discourse.julialang.org/u/waralex)\
**Post date:** [October 29, 2021, 9:27am UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/8 "2021-10-29T09:27:07Z")

</div>

> [@rikh](#):
>
> The trick seemed to be that everything should be precompiled

Unfortunately, it will not be possible to precompile everything in Dash, because in callbacks the types of arguments depend on the json that comes from the front end. Perhaps this will improve with the transition to JSON3, which is more stable in terms of parsing result types.

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [October 29, 2021, 10:05am UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/9 "2021-10-29T10:05:00Z")

</div>

No sorry, I mistyped. I meant that a lot should be precompiled, but maybe it only matters for startup time and not memory usage anyway

---

<div class="post-metadata">

**Author:** ![waralex](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/waralex/32/13415_2.png) [@waralex](https://discourse.julialang.org/u/waralex)\
**Post date:** [October 29, 2021, 10:12am UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/10 "2021-10-29T10:12:52Z")

</div>

> [@rikh](#):
>
> but maybe it only matters for startup time and not memory usage anyway

No, you are absolutely right - JIT compilation requires a significant amount of memory

```julia
julia> using DataFrames

julia> @time a = DataFrame(a = randn(1000), b = randn(1000));
  0.096489 seconds (228.65 k allocations: 13.744 MiB, 99.53% compilation time)

julia> @time a = DataFrame(a = randn(1000), b = randn(1000));
  0.000044 seconds (30 allocations: 33.656 KiB)

```

---

<div class="post-metadata">

**Author:** ![cepel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cepel/32/30275_2.png) [@cepel](https://discourse.julialang.org/u/cepel)\
**Post date:** [October 29, 2021, 9:06pm UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562/11 "2021-10-29T21:06:17Z")

</div>

Thank you everyone for the kind answers! I asked 2 questions and got the answers in general. Dash has a great potential for web analytics apps in Julia, so I hope the performance will be better in the long-term.
