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