# Why does Julia have around 200MB of memory overhead, even for small programs?

**URL:** https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071
**Category:** Performance
**Created:** [November 6, 2021, 10:50pm UTC](https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071 "2021-11-06T22:50:19Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![akriegman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/akriegman/32/30573_2.png) [@akriegman](https://discourse.julialang.org/u/akriegman)
#### Post date: [November 6, 2021, 10:50pm UTC](https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071/1 "2021-11-06T22:50:19Z")

</div>

I was looking at Julia’s performance in the [Computer Language Benchmarks Game](https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/pidigits-gz.html). Julia does pretty well in terms of speed, but I was noticing that Julia has a memory footprint of around 200MB for every benchmark, even ones where other languages are only using around 3MB. For example see the pi digits benchmark linked above. I found [this discourse.julialang.org thread from 2017](https://discourse.julialang.org/t/julia-memory-overhead/1861) discussing the issue, but I can’t tell if there’s been any updates since then.

So does anyone know the reason behind this overhead? If it’s due to the JIT (just an inexperienced guess from me), is the memory freed before the program starts? Are there any plans to fix this problem?

---

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [November 6, 2021, 11:11pm UTC](https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071/2 "2021-11-06T23:11:36Z")

</div>

It’s the JIT compiler and entire runtime and garbage collector.

---

<div class="post-metadata">

### Author: ![sashmit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sashmit/32/18791_2.png) [@sashmit](https://discourse.julialang.org/u/sashmit)
#### Post date: [November 6, 2021, 11:47pm UTC](https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071/3 "2021-11-06T23:47:32Z")

</div>

The ability to separate the runtime and the compiler appears to be coming soon:  
[https://github.com/JuliaLang/julia/pull/41936](https://github.com/JuliaLang/julia/pull/41936)

To me, this is huge news, since it increases the places it is plausible to use Julia.

---

<div class="post-metadata">

### Author: ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)
#### Post date: [November 7, 2021, 1:31am UTC](https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071/4 "2021-11-07T01:31:27Z")

</div>

About 100MB is due to the sysimage; on Linux, if you check `/proc/$(getpid())/smaps`, you’ll see that the sysimage (`sys.so`) gets mapped in and has a resident size of 100MB (although not all of it is “dirty”, so some is potentially shared with other processes?).

The PR linked above will help somewhat, by removing the LLVM dependency and the codegen portion of `libjulia` , but there will still always be that extra 100MB.

---

<div class="post-metadata">

### Author: ![Akatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/akatz/32/15164_2.png) [@Akatz](https://discourse.julialang.org/u/Akatz)
#### Post date: [November 7, 2021, 8:20pm UTC](https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071/5 "2021-11-07T20:20:28Z")

</div>

Treeshaking could reduce the sysimage size though, right?

---

<div class="post-metadata">

### Author: ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)
#### Post date: [November 7, 2021, 9:03pm UTC](https://discourse.julialang.org/t/why-does-julia-have-around-200mb-of-memory-overhead-even-for-small-programs/71071/6 "2021-11-07T21:03:49Z")

</div>

Yes, but treeshaking is also not trivial to do (correctly), given that it requires knowing all functions and data which could be accessed by a program (which isn’t always obvious or bounded in a dynamic language like Julia).

If you do it statically, you can end up marking everything as live (which means nothing is stripped), and if you do it dynamically (such as by using coverage information or a tracing debugger/profiler), you need to make sure your precompilation script covers everything that you’ll want end users to have access to.
