J
J
Junior2020-03-21 16:22:58
Corona SDK
Junior, 2020-03-21 16:22:58

Why does an application on the corona SDK clog RAM?

Why does an application on the corona SDK clog RAM?
main.lua code:

function update(e)
  display.newRect(w/2, h/2, w, h):setFillColor(0,0,0,1);

  display.newText(os.date('*t').sec, w/2, h/2);
end;

Runtime:addEventListener( "enterFrame", update );

The code shows seconds, after 5 minutes of running this code, the RAM is clogged ...
How can I fix this problem, can I implement it somehow differently?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Lerg, 2020-03-21
@IT-Programmer

Corona does not work like love2d and other lower level engines.
display.newRect() is not about painting the framebuffer region with a certain color, it is about creating an object in memory that will draw itself every frame without the need for the update(enterFrame) function.
enterFrame is needed to update already created objects, and not to create new ones every frame. Therefore, the RAM is clogged.

local rect = display.newRect(w/2, h/2, w, h)
rect:setFillColor(0,0,0,1)

local label = display.newText('', w/2, h/2)
local function update(e)
  label.text = os.date('*t').sec
end

Runtime:addEventListener( "enterFrame", update );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question