## [SOLVED] Erratic slowing down/juddering

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
randomnovice
Citizen
Posts: 98
Joined: Sat May 09, 2015 9:15 pm

### [SOLVED] Erratic slowing down/juddering

Hi folks,

Could anyone help me figure out why this little beginning-of-a-game slows down cumulatively but erratically?

- To see the slowing down: try new game and then click the cross then tick with any side panel a few times. After about thirty seconds you'll see it slow to a crawl... then recover and resume at a decent pace for a bit??
- It also sometimes takes a few seconds to run the quit command, even bringing up the spinning coloured wheel (on a Macbook).
- I know it's a strange/silly game. It's for my little ones.
- I know it doesn't do much yet.
- You can turn off the annoying voice if you click the audio button top left.
(- If you're not hearing an annoying voice anyway, it will only be playing if you're connected to the Internet.)

As always, massively appreciative of the awesome & wise community here. Thanks!

EDIT: Solved it myself and learnt a bit on the way!

The offending problem was in the function drawbuttontext as I was creating new fonts every frame:

Code: Select all

local font = love.graphics.newFont("fonts/heading.ttf", height*0.6)

I scaled using the inbuilt printf instead of creating a new scaled font and that smoothed things out dramatically.

I can also force garbagecollect() to run in the update to keep things ultra smooth... good to know!
Attachments
First Day at Pre-School.love

pgimeno
Party member
Posts: 2211
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Erratic slowing down/juddering

I've tried taking a brief look, but the code is big. I've found nothing standing out.

randomnovice
Citizen
Posts: 98
Joined: Sat May 09, 2015 9:15 pm

### Re: [SOLVED] Erratic slowing down/juddering

Thanks for taking a look. I didn't know about the function...

Code: Select all

print(garbagecollect("count"))

...before trying to solve this one so that was a good learning curve. That showed up a sharp increase in work for the GC over time and I think it was mostly down to the function drawbuttontext because it created a local font to get rid of every single frame (also didn't know I really shouldn't do that!).

### Who is online

Users browsing this forum: Google [Bot] and 21 guests