61
Support / How does the Virtualizer work?
« on: September 04, 2012, 07:16:06 am »
I want to use the Virtualizer class of jPCT-AE to resolve OOM, and i have read the doc, but i want to know a little more, thanks.
The process of my app is like this:
Load all models(.ser and .bones) ->
entry Scene1 -> Load all textures which are used in scene1 only -> some logic\event\draw ->
switch to Scene2 -> removeAndUnload all textures(Config.unloadImmediately = true) ->
entry Scene2 -> Load all textures which are used in scene2 only -> repeat like scene1 ... ...
-> switch to SceneN ... ...
And the OOM usually happened in the stage of "entry new scene -> load textures", my question:
1, Does the process of loading texture need more memory(peak) than the texture itself? For example: new Texture("1024X1024.jpg"), the texture will consume 1024x1024x4 bytes of memory finally, but does the process of "new Texture(like io、decode-jpg and so on)" need more memory than 4MB?
2, Does TextureManager.removeAndUnload () guarantee freeing memory immediately ?
3, Does the follow memory-route right?
new Texture(1024X1024) -> 4MB
set Virtualizer -> set context -> virtualize the texture -> swap the texture from vm to disk(flash) -> 0MB
Frambuffer.draw() -> upload the texture to GPU -> I don't know what happen with the virtualized-texture in this stage, help please.
removeAndUnload the virtualized-texture -> what happened?
Does the virtualized-texture need be swapped back(from disk to vm) in any situation? When? Does the process of virtualizing need more memory(peak) than the texture itself? How much time does the process of virtualizing consume typically?
4, Seems there are enough memory in every scene of my app(all of them can run fine alone), but OOM happened in the scene switching, any suggestions? Many thanks! I have reduced my texture to two jpg(512X512) per scene, and it's hard to reduce more. And i also enabled Texture.4bpp, disabled Texture.Mipmapping.
The process of my app is like this:
Load all models(.ser and .bones) ->
entry Scene1 -> Load all textures which are used in scene1 only -> some logic\event\draw ->
switch to Scene2 -> removeAndUnload all textures(Config.unloadImmediately = true) ->
entry Scene2 -> Load all textures which are used in scene2 only -> repeat like scene1 ... ...
-> switch to SceneN ... ...
And the OOM usually happened in the stage of "entry new scene -> load textures", my question:
1, Does the process of loading texture need more memory(peak) than the texture itself? For example: new Texture("1024X1024.jpg"), the texture will consume 1024x1024x4 bytes of memory finally, but does the process of "new Texture(like io、decode-jpg and so on)" need more memory than 4MB?
2, Does TextureManager.removeAndUnload () guarantee freeing memory immediately ?
3, Does the follow memory-route right?
new Texture(1024X1024) -> 4MB
set Virtualizer -> set context -> virtualize the texture -> swap the texture from vm to disk(flash) -> 0MB
Frambuffer.draw() -> upload the texture to GPU -> I don't know what happen with the virtualized-texture in this stage, help please.
removeAndUnload the virtualized-texture -> what happened?
Does the virtualized-texture need be swapped back(from disk to vm) in any situation? When? Does the process of virtualizing need more memory(peak) than the texture itself? How much time does the process of virtualizing consume typically?
4, Seems there are enough memory in every scene of my app(all of them can run fine alone), but OOM happened in the scene switching, any suggestions? Many thanks! I have reduced my texture to two jpg(512X512) per scene, and it's hard to reduce more. And i also enabled Texture.4bpp, disabled Texture.Mipmapping.