Texture Memory Used: 700.00 Mb

Hi,

My apk is 70mo. And when I load image I have 700 mb of texture memory.

My image are most of them on 8bits.

Someone have a solution (with plugin or something like this?)

Thanks

Hi.

Do you have a good idea of how that memory is distributed? Is everything on screen at once, either regularly or in worst case scenarios? Is much of it static? Would it matter to have comparable amounts of memory sitting around in RAM? (These are situations where I can see some opportunities for plugins to help.)

It might be worth putting in a feature request for compressed texture support, which I didn’t see listed (there is this, though). I suspect this is already implemented in part, for masks (their peculiar size requirement sounds like S3TC blocking), but was a hassle to do more completely. Just a guess, of course.  :) In any case, it would basically have to be built into Corona.

Possibly relevant info:

There are some open-source libraries for this, e.g. in gli (the loaders for DDS, KMG, KTX), mojodds, and (somewhere, not sure exactly where) in NVIDIA’s tools, for loading files, as well as on-the-fly memory stuff like stb_dxt (and maybe crnlib).

This is when nothing is display but a lot of imageSheet are load.

I have already give some point to this request a long time ago :slight_smile:

I will try to use those libraries but I am not good for using libraries. :frowning:

Thank you for informations!

Oh, sorry, I should be more explicit.  :) Those aren’t Lua libraries, but I thought they might be good supplemental material (“look, there’s support!”) in case you wanted to make a feature request.

Going back to an earlier question, will these image sheets all be on screen at once? (If this is for Stronghold, for instance, you might only see some of the terrain.) If the answer is no, maybe you could split your sheets up and stream them on-demand into a canvas and build tiles off that? For instance, evict any tiles that aren’t inside the screen and that the camera couldn’t reach within X frames.

If it’s also a problem of image caching, maybe you’d want to go a step further and use texture resources too.

(This is giving me some ideas to improve a plugin or two, as well.)

Can you give some more information on what you load for one screen? File dimensions - file type - file size would definitely help. Something like this: 1920x1080 - jpg - 90kb

ok, I am sorry I am not cristal clear. :frowning: This texture memory used is when there is nothing display but a lot of imageload (with " graphics.newImageSheet( " ) I load near 400 images. I load all image when user are on the game menu. I load every things expect maps, I load only the map of the play level.

Near all my image are png (17.8ko)

{ width=225, height=230, numFrames=6,sheetContentWidth=225,sheetContentHeight=1380 } )

and property are like this one.

I perhaps make a too big game for corona sdk :frowning:

Actually, that’s just bad practice. You shouldn’t load all your assets at once if you are not using them at the same time. Considering CPU, GPU, RAM power / speed of today you can easily create some of your assets while the game is on the run. Also, when you try to load all of your assets at once, you will face serious performance issues on various devices. Players will have hard time playing your poorly optimized game. They will need far better devices / configurations to play your game than it’s needed.

Technically speaking, as far as I know, OpenGL frees up texture memory in powers of 2 like when you are trying to create a 225x1380 image sheet, OpenGL will free up a memory of 256x2048 (or 2048x2048, I’m not sure about that) which is the core of your problem here. This is how it will allocate memory for your single animation. Remember, you have 399 more of that animation. Best practice here should be partially loading your sprite sheets like StarCrunch said. It’s also the right way to do it.

Lastly, you should also check out Texture Packer. It works pretty great when you are trying to optimize your assets.

https://www.codeandweb.com/texturepacker

Hopefully, someone with more knowledge could appear and let us know how texture memory allocation is handled in OpenGL and Corona :slight_smile:

I thank for image it was not anymore like that. OnpenGL2 use the size of the image for the memory. Need to be confirm.

Most of the time there is no loading in my game and no lag. Loading are less than 1sec.

And for perf, the game is at 30fps with more than 100 characters on maps for 80% of device. 

What do you mean by “partially loading your sprite sheets”? Don’t load all image or load by a different way?

“Hopefully, someone with more knowledge could appear and let us know how texture memory allocation is handled in OpenGL and Corona  :)” I hope someone show and tell us how it realy work

Are you sure that loading 400 images of that size takes less than 1 second? I’ve tried loading a 720x1280 png on an iPhone 5 and Samsung Galaxy S3 once and it took more than 1 second for that single image. If you pulled this on device that’s impressive. Can you tell me the device you are testing the game on?

Do you show 100 characters at the same time? Even if this is a game for PC, that’s too much. I can only recall Total War series, Mount & Blade series, No Russian level in Call of Duty and a level in Hitman that shows that many characters on the screen at the same time and they all use their own engine to optimize those scenes. Maybe you should try loading those characters when you show the related part of the screen.

Again, we would be glad if someone who knows how this works in Corona and OpenGL can shed some light on it.

Loading are during the game menu. And when the player have finish to choose what he want, he have to wait a sec, my data are create with 10 000 users.

I have 100 units who walk or fight. You can try it, ( Stronghold on google play). Some user with good phone do some game with more a thousand of unit on the map.

I have optimize everythings, I have create my own game motor, 3 isometrics, physics, AI…

Sorry, I don’t have an Android device to explore Stronghold at this point but I must say, I’m very impressed by what I see in the trailer. Really great work, congratulations :slight_smile:

I can’t test it right now so my questions will be based on the trailer video. Are you loading all soldiers, zombies etc. at the start of the level? If so, can you try creating soldiers right before they appear on the screen? This way, some of them will already be dead by the time the reinforcements have arrived so you can remove their “walking” sheets and display the gravestone.pngs. You should know that I’m assuming animation sheets and gravestones are two different files.

I load all unit because it’s only in a few level we have many identical unit.

I will try to do it, I will save in a table all display image who are not use any more on the screen and use them again when I will need them for another units.

( Hopefully, someone with more knowledge could appear and let us know how texture memory allocation is handled in OpenGL and Corona  :)   )

Sorry for butting in here, but I don’t really see a problem being presented. Are you saying that performance is hindered by the high amount of texture memory? Since Corona can build for desktop machines, 700mb isn’t a taxing load for some installs. 

There have been some viable options decreasing texture memory load. These solutions are common practice when developers are working with Corona. Perhaps you could outline the  problems you’re encountering, and how they may relate to the high amount of texture memory used in your game? That might spur some Corona support engineers to give a more focused response to the issue.

To use a lot of memory is not big problem but some phone don’t have much texture memory and the game crash and on some device there is app in background who are kill. 

You’ve received quite a few very good suggestions and solutions that should present clues to resolve the issue. The main sugestion is really the only one you should be investigating given by bgmadclown below:

Actually, that’s just bad practice. You shouldn’t load all your assets at once if you are not using them at the same time. Considering CPU, GPU, RAM power / speed of today you can easily create some of your assets while the game is on the run. Also, when you try to load all of your assets at once, you will face serious performance issues on various devices. Players will have hard time playing your poorly optimized game. They will need far better devices / configurations to play your game than it’s needed.

“Optimization” is important when dealing with mobile development, since resources are at a premium, and one cannot just run rampant on lower-spec devices available on the market. To sum up, this is a device/optimization problem, not a Corona problem.

Could you let us know what you’ve done to try to mitigate the issue, and why you can’t perform the optimizations that have been suggested already?

The problem on google play if you app crash on some device, these users write a bad comment and it’s a big problem. Secondly with corona when we load image it’s stop the game runing. The game freeze until the image is load. If I load on demand image it’s going to lag. The only issue is to reduce the image size, I divide all image size by 4 or more. I have try many things for exemple put in one image a lot of image but it’s don’t change the texture size but the loading time(1ms by image remove). It’s make 3y I am on this project, I can correct every things by myself but not this problem

The solution isn’t to reduce the image size, it’s to reduce the load on the device. It’s entirely possible that you created a game that doesn’t run optimally on lower-spec devices. Take a look at the listing for Sproggiwood:

*** Designed for newer devices. Requires minimum 1GB of RAM. See list of tested devices at the bottom. ***

There are other developers that are aware that they are creating heavy-duty games, and inform the public accordingly.

It doesn’t sound like you want to go this route; you would rather make the game playable on all devices. Ths is done by  optimizing the game logic itself. Substitute timers for Runtime listeners that don’t need to update every frame. Don’t load every single character for a level, if you already know that a character has chosen a Gladiator as their “savior” (sorry if that isn’t the right terminology, I’m not that far into the game). using the newText() API is relatively taxing call in the fashion that Corona leverages it; perhaps you should investigate bitmap fonts. 

All of these are legitimate options to make your game function better on lower-powered devices. Starcrunch gives a few fantastic options above as well; considering the amount of downloads and reviews you have, it would benefit you greatly to adopt some of these to make your game as viable as you can.

To emphasize, I’m not trying to be harsh. I’m sure the language barrier is causing some problems (I noticed a few English language typos in the game, such as “ennemy” instead of “enemy”) so I want to make sure you understand we are trying to help you out. You have a quality release here and you would be doing yourself and your users a favor by making it as streamlined as possible.

Alex is right. You will probably face another bump up on the road if you try to solve this problem just by reducing the size of your assets(assuming you have done your fair share of asset optimization).

I’m not pretty sure if you are already doing this but another option can be limiting the number of created assets depending on the device. Maybe you can adjust your number of assets to load considering “maxTextureSize” or “androidApiLevel”. This way, “loading before level” can also work better.

https://docs.coronalabs.com/api/library/system/getInfo.html

Thank you every one for your help! I was wondering a bit of miracle answer :wink: Because a lot of game are heavier that mine and they use less texture memory.

I will try to find an issue, the problem I do loading before the user choose things. The only thing I haven’t load when the player choose something is the map.I will work on it :slight_smile:

@Alex@Panc I didn’t get what you mean when you talk about API and bitmap font. (Is it better than .otf or .ttf?)