Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resources.preload以后产生的cache内存优化 #18221

Open
Changdw opened this issue Jan 21, 2025 · 0 comments
Open

resources.preload以后产生的cache内存优化 #18221

Changdw opened this issue Jan 21, 2025 · 0 comments
Assignees
Labels
Module: AssetSystem Optimization Enhancement in performance, usability, stability etc

Comments

@Changdw
Copy link

Changdw commented Jan 21, 2025

https://forum.cocos.org/t/topic/164980

严格来说,preload也占用内存,而且还不小。
如果看到cocos源码的话,会发现shared.ts 里面有2个cache,files和parsed。在preload的时候,走的fetch 的pipeline,会把下载结果和解析结果加入这2个cache,保存住让内存上涨,但是没有删除(或者删除不彻底)。你们在预加载的时候,打印这2个cache的count就看到了。
对,preload也会去做解析,是获取资源依赖(getDepends)的时候进行parsed。如果不解析,怎么能从json里面获取依赖的资源引用呢?
这2个cache的删除是在load的时候删除的(也会删除不彻底),我是用各种修改才让这2个cache清理的稍微干净一点。

顺带贴一下我一部分修改的图,这个可以解决预加载中parsed的cache堆积的问题。目前用着还行但没充分测试。
parsed堆积的还挺大的,特别是一些骨骼动画的数据。

在fetch的时候,由于调用了getDepends而加载的依赖,没有走load的流程卸载掉。导致的问题。

@Changdw Changdw added Module: AssetSystem Optimization Enhancement in performance, usability, stability etc labels Jan 21, 2025
@Changdw Changdw self-assigned this Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: AssetSystem Optimization Enhancement in performance, usability, stability etc
Projects
None yet
Development

No branches or pull requests

1 participant