## [RESOLVED] Memory leaks with tables ?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Party member
Posts: 102
Joined: Fri Aug 29, 2014 6:05 pm
Location: France
Contact:

### [RESOLVED] Memory leaks with tables ?

Hello !

I'm making a framework on the top of Love, and I've been doing some example when I saw the tween lagging after a few seconds. Adding some debug info to the drawing, I can see the FPS dropping when the memory is expending. The problem is the memory does not stop growing, at a point where I can have 1 FPS for a simple love.graphics.print .

You need to see the "example/scene_node.moon" file. Basically, it create a scene node and a tween (framework/scene_tree/tween.moon) and the FPS are dropping and the memory grows while the tween is processing. The memory extensive step of this process is the computation of the interpolated value (line 218) :

Code: Select all

v = @start_value + (@end_value - @start_value) * @.easing t

@reference.value = v
In the example the interpolated value is a vector (framework/scene_tree/transform.moon) which has the __add, __sub, __mul and __div meta-methods, which create a new instance of the Vector class. I don't really know if the leak come from here, and I don't know how to debug this and how to fix this problem.

Last edited by Linkpy on Sun Oct 16, 2016 11:02 am, edited 1 time in total.
Founder of NeoShadow Studio. Currently working on the project "Sirami".

raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

### Re: Memory leaks with tables ?

The only reason GC couldn't collect an object is if it's referenced somewhere. So I suppose this creates memory islands or never lets go of vectors or something? Try inspecting generated Lua code.

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

### Re: Memory leaks with tables ?

There are more reasons why GC wouldn't collect. Try calling collectgarbage("collect") manually in update() to see if that helps; if it doesn't, then there's probably a bug in your code as radiho has indicated.

Sorry, I can't read .moon files.

raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

### Re: Memory leaks with tables ?

Party member
Posts: 102
Joined: Fri Aug 29, 2014 6:05 pm
Location: France
Contact:

### Re: Memory leaks with tables ?

pgimeno wrote:There are more reasons why GC wouldn't collect. Try calling collectgarbage("collect") manually in update() to see if that helps; if it doesn't, then there's probably a bug in your code as radiho has indicated.

Sorry, I can't read .moon files.
I already done this, and with this I was able to see the memory grows only when the tween is updating the value. But the memory don't move when the tween is waiting. And when the tween finish its job the controller removes it, but the memory doesn't decrease (but doesn't increase).