Frame-Heavy Gifs


#1

I am trying to create a gif with 100 frames, which I assume shouldn’t be a problem if I code it correctly. However, the following code slows to a crawl, and seems to cause a memory leak.

using Plots
using ProgressMeter


u = rand(100,100)
hmap = heatmap(zeros(size(u)), clim=(0,1))


p = Progress(1000, 1)

anim = Animation()

for i=1:1000
    u = rand(100,100)
    heatmap!(hmap[1],u)
    if mod(i,10) == 0
        frame(anim)
    end
    next!(p)
end

gif(anim, "/tmp/anim_fps30.gif", fps=30)

Have I made a critical error in my coding? Is there a way to get frames for the animation without holding them all in memory? Thanks.