【内存优化】添加一些log
parent
31ad3358bc
commit
39afab6123
|
@ -1,5 +1,6 @@
|
|||
local SpriteLoaderPool = {}
|
||||
local SpriteLoader = {}
|
||||
local spLoaderIndex = 0
|
||||
|
||||
-- 调用此方法创建一个管理器
|
||||
function SpriteLoader.New()
|
||||
|
@ -8,8 +9,10 @@ function SpriteLoader.New()
|
|||
-- return table.remove(SpriteLoaderPool, 1)
|
||||
-- end
|
||||
-- 没有新建
|
||||
spLoaderIndex = spLoaderIndex + 1
|
||||
local o = {}
|
||||
o.SpriteList = {}
|
||||
o.id = spLoaderIndex
|
||||
SpriteLoader.__index = SpriteLoader
|
||||
setmetatable(o, SpriteLoader)
|
||||
return o
|
||||
|
@ -31,13 +34,20 @@ end
|
|||
|
||||
-- 根据界面加载的数量卸载相应数量的资源
|
||||
function SpriteLoader:UnLoadSprite()
|
||||
if not SpriteLoaderPool[self.id] then
|
||||
SpriteLoaderPool[self.id] = 0
|
||||
end
|
||||
SpriteLoaderPool[self.id] = SpriteLoaderPool[self.id] + 1
|
||||
if SpriteLoaderPool[self.id] > 1 then
|
||||
LogError("SpriteLoader Repeat UnLoad : ".. self.id..", count : "..SpriteLoaderPool[self.id])
|
||||
end
|
||||
for name, count in pairs(self.SpriteList) do
|
||||
LogWarn("lua 回收资源:name:"..name..", count:"..count)
|
||||
resMgr:UnLoadAsset(name, count)
|
||||
end
|
||||
self.SpriteList = {}
|
||||
-- 回收到对象池
|
||||
table.insert(SpriteLoaderPool, self)
|
||||
-- -- 回收到对象池
|
||||
-- table.insert(SpriteLoaderPool, self)
|
||||
end
|
||||
|
||||
-- 销毁loader
|
||||
|
|
|
@ -145,6 +145,7 @@ end
|
|||
|
||||
function this.Exit()
|
||||
this.spLoader:Destroy()
|
||||
_fogSpritesCache = nil
|
||||
_tileLivePool = nil
|
||||
_tileClearPool = nil
|
||||
ViewCamera = nil
|
||||
|
|
Loading…
Reference in New Issue