Closed meepen closed 4 years ago
https://github.com/meepen/MySQLOO/commit/59a64e81120e62303f6d5a97557060c594cbc1b9
I fixed it here, not sure if right approach. Feel free to use.
I am 95% sure this would leak memory, the reason I have a lua table to store the queries is exactly because tables us proper GC, while storing a reference does not.
Try running loads of transactions with callbacks that all reference all of the queries and the transaction itself (so that the closures keep references to them), and check mysqloo.objectCount() to see if anything leaks.
yeah it definitely does leak
actually both main and mine leak at same rate lol
I did this test on my current version and it went back down from 50k objects to ~11 or something
local finished = 0;
local time = SysTime()
local query1 = db:prepare("SELECT ?")
local query2 = db:prepare("SELECT ?, 1")
local totalAmount = 50000
for i = 1, totalAmount do
local transaction = db:createTransaction()
query1:setNumber(1, math.random(1, 1000))
query2:setNumber(1, math.random(1, 1000))
transaction:addQuery(query1)
transaction:addQuery(query2)
function transaction:onSuccess()
finished = finished + 1
if (finished == totalAmount) then
print("Done:", SysTime() - time, query1, query2, transaction)
collectgarbage("collect")
end
end
transaction:start()
end
Fixed in master
It uses the last dataset given to the PrepareStatement