# Makie memory leak?

**URL:** https://discourse.julialang.org/t/makie-memory-leak/52362
**Category:** Specific Domains
**Tags:** plotting
**Created:** [December 25, 2020, 8:27am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362 "2020-12-25T08:27:58Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 25, 2020, 8:27am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/1 "2020-12-25T08:27:58Z")

</div>

Hi,

I do not understand why the following MWE consumes more an more memory until crash:

```julia
 using GLMakie,AbstractPlotting,ImageCore
function leak(img,i)
    fn=string(i)*".png"
    scene = AbstractPlotting.image(rotr90(img), show_axis = false);
    AbstractPlotting.save(fn, scene; resolution = (1920,1088), px_per_unit = 72)
    nothing
end

function nleak(nf)
    nx,ny=1920,1088

    for i=1:nf
        img = rand(RGB{N0f8}, nx, ny)
        leak(img,i)
        @info "Size of AbstractPlotting: $(Base.format_bytes(Base.summarysize(AbstractPlotting)))"
        GC.gc(true)
    end
end
nleak(200)

```

Any hints ?

---

<div class="post-metadata">

### Author: ![maxfreu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxfreu/32/17468_2.png) [@maxfreu](https://discourse.julialang.org/u/maxfreu)
#### Post date: [December 25, 2020, 8:31am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/2 "2020-12-25T08:31:14Z")

</div>

Maybe you plot many images into the same scene. I dont remember its behaviour…

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 25, 2020, 8:41am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/3 "2020-12-25T08:41:05Z")

</div>

I don’t know. The calling `nleak` function does not create any Makie related object. Hence I would assume that every Makie objects should be destroyed (or ready for GC) at the `leak` function exit…

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [December 25, 2020, 9:18am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/4 "2020-12-25T09:18:28Z")

</div>

What version are you on? Can you try with latest AbstractPlotting /GLMakie? Something similar was supposed to be fixed recently

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 25, 2020, 9:27am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/5 "2020-12-25T09:27:43Z")

</div>

Hi, I think that my system is up to date:

```julia
Status `~/Projects/video_grid.jl/MWE/Project.toml`
  [537997a7] AbstractPlotting v0.14.3
  [3da002f7] ColorTypes v0.10.9
  [5ae59095] Colors v0.12.5
  [e9467ef8] GLMakie v0.1.21

```

```julia
julia> versioninfo()
Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = "/snap/code/52/usr/share/code/code"
  JULIA_NUM_THREADS = 

```

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 25, 2020, 9:42am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/6 "2020-12-25T09:42:29Z")

</div>

I also try to use the master version with the same outcome:

```julia
(MWE) pkg> status
Status `~/Projects/video_grid.jl/MWE/Project.toml`
  [537997a7] AbstractPlotting v0.14.3 `https://github.com/JuliaPlots/AbstractPlotting.jl#master`
  [e9467ef8] GLMakie v0.1.21 `https://github.com/JuliaPlots/GLMakie.jl#master`

```

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [December 25, 2020, 10:33am UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/7 "2020-12-25T10:33:02Z")

</div>

Could you please file an issue at Makie.jl with this MWE then? So far these things have been caused by lingering observable connections, and they tend to be hard to catch

---

<div class="post-metadata">

### Author: ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)
#### Post date: [December 25, 2020, 1:01pm UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/8 "2020-12-25T13:01:29Z")

</div>

Just a wild guess, sorry if it is misleading, but can it be related to [https://github.com/JuliaLang/julia/issues/14495](https://github.com/JuliaLang/julia/issues/14495)?

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [December 25, 2020, 2:07pm UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/9 "2020-12-25T14:07:41Z")

</div>

Yeah Makie had a couple of problems lately, which is why I created [https://github.com/SimonDanisch/MemoryHunter.jl](https://github.com/SimonDanisch/MemoryHunter.jl)… I’ll take a look at your mwe once I have time!

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 25, 2020, 2:49pm UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/10 "2020-12-25T14:49:20Z")

</div>

OK thank you for your answer… and good luck with the investigation !  
I was not sure since the memory leak issues I have found on github were closed.  
Should I post a new issue ?

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 25, 2020, 5:25pm UTC](https://discourse.julialang.org/t/makie-memory-leak/52362/11 "2020-12-25T17:25:31Z")

</div>

The issue is here  
[https://github.com/JuliaPlots/Makie.jl/issues/795#issue-774762968](https://github.com/JuliaPlots/Makie.jl/issues/795#issue-774762968)

BTW, is it possible (useful) to plot `CuArray`s with Makie ?
