It seems to to have a memory leak when iterating though table and setting is values.
When I take out the table I get no memory leak, and my ram don't shoot up using 32 GB the
"the max of my computer " forcing a memory purge.
This is my main code.
Code: Select all
function love.load()
coco = {}
for i = 1, 100000 do
coco[i] = 0
end
thread = love.thread.newThread("thread.lua")
channel = love.thread.getChannel("test")
thread:start(coco)
i = {}
i[1]='thread 1 is work'
thread2 = love.thread.newThread("thread2.lua")
channel2 = love.thread.newChannel("test2")
thread2:start(coco)
i2 = {}
i2[1]='thread 2 is work'
thread3 = love.thread.newThread("thread3.lua")
channel3 = love.thread.newChannel("test3")
thread3:start(coco)
i3 = {}
i3[1]='thread 3 is work'
thread4 = love.thread.newThread("thread4.lua")
channel4 = love.thread.newChannel("test4")
thread4:start(coco)
i4 = {}
i4[1]='thread 4 is work'
thread5 = love.thread.newThread("thread5.lua")
channel5 = love.thread.getChannel("test5")
thread5:start(coco)
i5 = {}
i5[1]='thread 5 is work'
thread6 = love.thread.newThread("thread6.lua")
channel6 = love.thread.getChannel("test6")
thread6:start(coco)
i6 = {}
i6[1]='thread 6 is work'
thread7 = love.thread.newThread("thread7.lua")
channel7 = love.thread.getChannel("test7")
thread7:start(coco)
i7 = {}
i7[1]='thread 7 is work'
thread8 = love.thread.newThread("thread8.lua")
channel8 = love.thread.getChannel("test8")
thread8:start(coco)
i8 = {}
i8[1]='thread 8 is work'
thread9 = love.thread.newThread("thread9.lua")
channel9 = love.thread.getChannel("test9")
thread9:start(coco)
i9 = {}
i9[1]='thread 9 is work'
end
function love.update(dt)
v = channel:pop()
if v then
i[1]=#v
end
v2 = channel2:pop()
if v2 then
i2[1]=v2
end
v3 = channel3:pop()
if v3 then
i3[1]=v3
end
v4 = channel4:pop()
if v4 then
i4[1]=v4
end
v5 = channel5:pop()
if v5 then
i5[1]=#v5
end
v6 = channel6:pop()
if v6 then
i6[1]=#v6
end
v7 = channel7:pop()
if v7 then
i7[1]=#v7
end
v8 = channel8:pop()
if v8 then
i8[1]=#v8
end
v9 = channel9:pop()
if v9 then
i9[1]=#v9
end
if thread:isRunning() == false then
thread:start(coco)
end
if thread2:isRunning() == false then
thread2:start(coco)
end
if thread3:isRunning() == false then
thread3:start(coco)
end
if thread4:isRunning() == false then
thread4:start(coco)
end
if thread5:isRunning() == false then
thread5:start(coco)
end
if thread6:isRunning() == false then
thread6:start(coco)
end
if thread7:isRunning() == false then
thread7:start(coco)
end
if thread8:isRunning() == false then
thread8:start(coco)
end
if thread9:isRunning() == false then
thread9:start(coco)
end
end
function love.draw()
love.graphics.print(_VERSION, 300, 10)
love.graphics.printf( love.timer.getFPS(), 650, 10, 500, "left")
end
All my thread files look like this.
I know I could have looped though the the with a for loop.
Code: Select all
c = love.thread.getChannel("test")
var = 0
local coco = {}
local dd =10
for i=1, 100000 do
var = var+1
coco[i] = i -- comment this out to see the difference.
end
c:push(coco)