Closed stari4ek closed 9 years ago
Yes, definitely. You can change the behavior whatever you want because it is open source.
Sorry, no offense here.
Just wanted to hear thoughts of author about current approach and probably to get more flexible solution in upstream.
Thank You.
I don't understand the point. You wanted to keep textures on memory? why don't you keep LWF instance or LWF data on memory?
The idea of cache is to save result of expensive work and re-use it when it will be needed once again. This is not about owning objects. Values stored in any cache always live longer than it's users.
If You look through whole cocos2dx project you will see, that there is no any manual cache draining used, except FPS counter.
Keeping all LWF objects will lock textures in cache and if memory warning will happened - they can't be released and app won't survive. It's very different from approach, when textures are kept in cache for case when they will be needed once again, but if app is out of memory - they can be easily released.
From cocos2dx srcs:
/** Purges the dictionary of loaded textures.
* Call this method if you receive the "Memory Warning".
* In the short term: it will free some resources preventing your app from being killed.
* In the medium term: it will allocate more resources.
* In the long term: it will be the same.
*/
void removeAllTextures();
Very detailed explanation: http://stackoverflow.com/questions/15704367/cocos2d-2-0-when-is-good-practice-to-purge-caches
Thank You,
I know the behavior and still I don't understand your point at all. You can rewrite the code in order to get the behavior what you want.
Thank you. I will create PR, probably it will show the idea much better.
Thank you. But no need to create PR.
Code:
Every time we load LWF file which was loaded before - we will load (decode png, apply alpha processing) same images again. Some ideas:
I can imagine that in some rare situations, we'd prefer to have as much free memory a possible before new LWF is loaded, especially if it uses a lot of huge textures, but it's rare situation.
Some statistics (TextureCache::addImage) as example. We have "pause" screen as separated LWF. First and second screen opening With cache drain: 300ms/291ms Without: 302ms/2ms
Can we have it configurable at least?