Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做一个手机应用程序,里面有很多图片我的问题是如何动态打开图片并从内存中删除?
我测试了这个:
a = Texture.new("a.jpg") print(Application:getTextureMemoryUsage()) -- write x a = nil print(Application:getTextureMemoryUsage()) -- write x again
感谢帮助。
问题是没有立即收集垃圾,这就是为什么没有立即释放内存的原因。您可以尝试调用collectgarbage()几次来强制它:
collectgarbage()
print(math.floor(collectgarbage("count"))) collectgarbage() collectgarbage() collectgarbage() print(math.floor(collectgarbage("count")))