Comments (5)
这个也安排一下,我会写一个新的示例,把我认为比较合适的解决方案提交。
from cocos_creator_framework.
如果A会instantate,说明肯定是有脚本的,必定继承UIView,然后可以在onDestory的时候调用自动释放。
from cocos_creator_framework.
还有个建议instantiate的node可以加一个标记
let node = cc.instantiate(prefab) node['__SELF'] = ture
然后在destory的时遍历所有节点有 __SELF 标记的调用一下 node.destory() 否则加载进uiview上的应该内存有问题
不过是我个人见解
from cocos_creator_framework.
from cocos_creator_framework.
今天花了一天的时间,仔细思考了如何在兼容效率、编写复杂度的情况下实现赋值、Prefab实例化的自动内存管理。具体可以看我新提交的example_res_keeper场景,代码位于ResKeeperExample.ts。
实例化使用ResUtil.instantiate( prefab ),比如实例化了100个对象,会自动在100个对象destroy之后释放资源,如果这个prefab没有被其它地方依赖或者use的话。需要注意的是prefab需要是通过resloader加载的Prefab。
ResKeeper是一个简单的轻量级方案,包括一个spriteframe希望赋值给多个对象,然后自动管理spriteframe的释放,都可以交给ResKeeper组件。
暂时先说这么多吧,最近还有几个资源管理的有用特性需要开发,相信会对大家有所帮助!新年快乐~
from cocos_creator_framework.
Related Issues (20)
- ResKeeper中autoRelease里判断的key值是url,但是ResLoader中_cacheItem保存的是reference HOT 1
- Resloader里的_cacheItem缓存了一个use,导致ResKeeper里执行autoReleaseRes时,无法将资源缓存加入autoRes中 HOT 1
- 请问数据层调用UI的正确姿势是什么样子的 HOT 6
- resLoader.getUrlByAsset方法不见了 HOT 2
- resLoader.getUrlByAsset方法不见了
- 原生平台内存飙升 HOT 7
- 很好的框架,为什么不继续进行更新呢?每半年 更新一版本都行啊 HOT 1
- 支持2.4.3吗? HOT 2
- NetNode.ts 的自动重连貌似有一句写错了的代码 HOT 6
- 宝爷的频繁更新什么时候能看到!!! HOT 20
- 宝爷你的UIManager为什么不写成单例呢 HOT 1
- 没有声音管理哦!
- 宝爷提一个,添加防触摸层 的 BUG HOT 1
- 宝爷新bug 用resload 加载 spine 无法释放内存 HOT 16
- 宝爷初心已忘了吗? HOT 1
- 啥时候更新到3.4版本? HOT 1
- 没有粘包处理逻辑么 HOT 2
- 请问下 这个在哪设置下websocket的Header呢? HOT 2
- 多语言本地化 HOT 2
- 3.x的一点疑问 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cocos_creator_framework.