Memory optimization of resource management

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/shirln/article/details/98210001

Recommended reading:

Note: The following article is for egret to write, other engines can refer to ideas, realize there may be differences

Our side of the plurality of sub-scenes, for example, we log in the scenario of resources, it is another separate a json configuration, when we switch scenes will be based on the resources RES.destory corresponding configuration url

For example, the main scene of the game, the game is we cut the map, there is a map object which we will map the resources at the time of entering the game, whenever switch scenes to cut the map, we will retrieve the map objects to destroy Map loads a new map

  1. Models, special effects resources. (Loading destroyed management, into the counter. Timing detection, if the resource destroyed more than five minutes, it is determined that the recoverable resources)
    2. Map of resources (primarily scene picture). (During movement of the scene, using the current images will have put up a map stored in, (1 minute tentative detection time) timing detection, removal other than players outside resource map range 2 9-grid lattice )
    3.UI picture, icon resource. (Picture resource management, interface opened, the approach will sign up, count + interface when closed, will enter the destruction of logic, counting -1, timing detection, the current count of the picture using the picture of resource 0, but now this place still have a problem: the main place in the Render list)

My method is relatively simple and crude, added directly to the stage when get hold of marks, not removed on the stage, directly read the RES in the buffer pool, the filter is not on the stage, other fully get rid of
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
highly versatile resource, adding public Atlas, strong independence UI, you can put your own modules.
For example, it is common atlas, we will be divided into relatively fine point. For example, it is common atlas, we will be divided into relatively fine point.
Here Insert Picture Description
Here Insert Picture Description
His approach is, in addition to adding the reference count, also add a timestamp of the last referenced, each time testing process see reference counting, but also see time interval, if the most recent reference period of time, then too close, nor release
the general public of the picture, we should have a reference to the recent time stamp, so it should not be released.

In addition there is a great God to do more powerful place:
object pooling technique in the basic game :( All objects are objects to be created by the pool but not limited to: text, images, various objects), basically the bottom of laya Code, have carried out relevant changes

Guess you like

Origin blog.csdn.net/shirln/article/details/98210001