I write images slide on android 3.0 by Acer ICONIA Tab A500. The total images are over 100. Loading all images in initializing will don’t work. So new Image when it will be slide.
But I slide one by one about the 44th or 45th image, the whole images after 45th can’t be displayed, But the apk is alive and it prev slide OK . The source code is blow:
**local images = {} – the index will be set as nil when it don’t be used
local imageFiles = {} – ready all image file name
local MaxImageSize=30 – The same result use 10, 20
local MaxCollectSize = 20
local imagePoolIndex = 1
local imagePool = {}
local function genImageFromPool(i)
if not i or i==0 then return end
if not images[i] then
images[i] = display.newImage(imageFiles[i])
if imagePoolIndex == MaxImageSize+1 then
–[[ Using collectgarbage seems no effect!
for j=1, MaxCollectSize do
images[imagePool[j]] = nil
imagePool[j] = 0
end
collectgarbage(“collect”)
print (“collect finish!!”)
–]]
imagePoolIndex = 1
end
if imagePool[imagePoolIndex] and imagePool[imagePoolIndex] > 0 then
images[imagePool[imagePoolIndex]] = nil – release image
end
imagePool[imagePoolIndex] = i
imagePoolIndex = imagePoolIndex + 1
end
end**
Is there better way to free un-used images and slide one by one to all images? Thanks for help. [import]uid: 51300 topic_id: 9927 reply_id: 309927[/import]