The memory problem
by Lucheng · in General Discussion · 09/02/2008 (8:09 pm) · 4 replies
Hi guys!
Now we are making a game about education with TGB1.74.When I start the development platform the memory costs about 600MB...
All of the images are only 30MB.I found that if I add images to platform with "create a new imagemap" the memory will cost a lot and it reached 1GB when I didn't use datablock to create images.God!!!
I am a freshman so please told me how to solve it.It's hurry because there are so many tasks for the project.
Thanks!
Now we are making a game about education with TGB1.74.When I start the development platform the memory costs about 600MB...
All of the images are only 30MB.I found that if I add images to platform with "create a new imagemap" the memory will cost a lot and it reached 1GB when I didn't use datablock to create images.God!!!
I am a freshman so please told me how to solve it.It's hurry because there are so many tasks for the project.
Thanks!
#2
I used the method which you told me but there is another problem.
when I set the preload to false and allowunload to true,the TGB will quit itself if there are too many images
in one of the levels.Is it a limit to preload?If so,should I set some of them the preload to true?
Hope your post.
09/15/2008 (2:11 am)
Thank you very much!I used the method which you told me but there is another problem.
when I set the preload to false and allowunload to true,the TGB will quit itself if there are too many images
in one of the levels.Is it a limit to preload?If so,should I set some of them the preload to true?
Hope your post.
#3
I don't know about any TGB's memory limitations besides WinXP's. AFAIK you can allocate about 3,5GB in this OS and about 1,3GB for single application. So if Torque starts to load many images it can overload memory and then crash (or be crashed by system).
After all you still need to optimize your game - such big memory allocations are not good for any one and it won't work on older machines and/or with worse graphics cards and/or less memory.
09/15/2008 (5:49 am)
Method I told is only some kind of workaround without implementing (or using) more complicated memory management system, just the on engine already has. For specific project maybe you will need to get specific memory management. But for now you probably just need to limit number of imageMaps (maybe remove useless) or pack them into single and big (1024x1024 or even 2048x2048) map packs.I don't know about any TGB's memory limitations besides WinXP's. AFAIK you can allocate about 3,5GB in this OS and about 1,3GB for single application. So if Torque starts to load many images it can overload memory and then crash (or be crashed by system).
After all you still need to optimize your game - such big memory allocations are not good for any one and it won't work on older machines and/or with worse graphics cards and/or less memory.
#4
Actually my scripts are so terrible...
09/15/2008 (8:47 pm)
Thanks a lot!I will limit the number of imageMaps first and I must rebuild the structure.Actually my scripts are so terrible...
Torque Owner Adam RJ
First of all you are missing one important thing: 30MB of pictures are probably PNGs or JPEGs which are compressed files while game engine and graphics card uses almost uncompressed images.
In fact it's even worse - every image is rounded to POT (Power Of Two) size bitmap. So you need to optimize your files - take small images into bigger tilemaps and rember that 520x40px image tooks same amount of mememory as it was 1024x1024px !!!
For quick fix: you can lower memory usage setting for imageMaps two options:
* preload to false (uncheck in TGB)
* allowUnload to true
First will load images only where they are needed and later will unload them when last sprite using it will be removed.
More on this here: tdn.garagegames.com/wiki/Torque_2D/ImageMap_Tutorial
and in some other tutorials which you can find around this site.