Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Quick LUA GC/Memory question — Gideros Forum

Quick LUA GC/Memory question

amaximovamaximov Member
edited November 2013 in General questions
So I understand that Lua uses reference counts for objects to determine when to truly garbage collect objects with no references but I have a quick question regarding local variables.

Suppose I have this code:
local newX
 
local function changeX(x)
     local dx = math.random(0, 20)
     x = x + dx
     return x
end
 
newX = changeX(5)
My question is, will I have a memory leak if I run this function say 1000 times without niling "dx"?

I don't mind niling these variables each time, but I'm worried that unnecessarily niling variables might cause slight performance drops for similar functions that I might be calling 100+ times a frame.

Comments

Sign In or Register to comment.