Thank you semlar for your answer.
I modified the code like this:
Code:
local itemFrames = {}
for i=1, 5 do
local frame = _G.CreateFrame("Frame", "ItemFrame"..i, mainFrame)
frame:SetSize(20, 20)
frame:SetPoint("LEFT", (5+16)* (i-1), 0)
frame.texture = frame:CreateTexture()
frame.texture:SetAllPoints(frame)
itemFrames[i] = frame
end
In my method I removed ClearAllPoints, you were right about it, and now I only set the texture using the reference.
Code:
function loadItems(itemsIds) then
-- clear frames
for i, frame in ipairs(itemFrames) then
itemFrame:Hide()
end
for i, itemId in ipairs(itemsIds) do
local _, _, _, _, _, _, _, _, _, itemTexture, _ = GetItemInfo(itemId)
if itemTexture and i <= 5 then
print("In the loop")
itemFrames[i]:texture:SetTexture(itemTexture)
itemFrames[i]:Show()
else break
end
end
end
Breaking the loop with itemTexture nil is the idea, that's correct.
With this change I keep having the random behaviour, some times it renders the icons and other times it doesn't, however I can see in the chat the log "In the loop" as many times as items I have.
At least now the memory is not increasing like crazy, however... after some tests wow client crash with the next message: