This tutorial is part of the Marmalade SDK tutorials collection. To see the tutorials index click here
Available Application Memory
Ok, this is the first of my bite-sized tutorials that I have started running alongside my usual meaty tutorials. I see these types of problems cropping on the forums often so I thought that I would cover them in small bite sized tutorials. Another good reason for bite sized tutorials is that I get the chance to blog a little more often as I can put one of these together in 10 minutes.
I’m pretty sure that most if not all of you Marmaladians have seen this dialog box before. If you haven’t then you are truly blessed 🙂
Heap 0 out of memory. Allocating 2048 bytes but only 576 available (540 LFB).
Increase icf setting [s3e] MemSize (current value is 14584).
This error is basically the Marmalade system telling you that it wants to allocate 2048 bytes but doesn’t have enough memory to allocate it, in fact in this case we only have 567 bytes left.
To solve the problem you need to edit a file that Marmalade has generated for you and placed in your data folder called app.icf. This file is the main app configuration file and is where Marmalade stores certain runtime settings such as how much memory to allocate to your program or how big to make the data cache etc..
To change the amount of memory available to your app simply add the following section to this file:
This value is the number of bytes to allocate to your app, in this case we have reserved 10MB. Note that without specifying your own MemSize you will have a default heap size of 3MB
If you are dealing with multiple heaps then you can set the the available memory per heap using:
and so on…..
When running an x86 Debug build the Marmalade system will usually require additional memory to build resources and such. Marmalade provides an additional S3E app.icf option that allows you to specify memory size during debug builds.
Data Cache Memory
The Marmalade SDK uses a data caching system to store certain data that it is going to use during rendering for example vertex streams and materials. Its not possible to allocate these kinds of data on the stack as they must persist until rendering has finished (when the app hits IwGxFlush()). If you are drawing a lot of stuff using a lot of different materials then there is a good chance that you are going to run of data cache and receive an error like that shown below:
IwAssert failure (GX, 761).
Message: Data cache overflow allocating 336. Increase [GX] DataCacheSize (currently 800)
To increase the amount of memory available to the data cache use the following app.icf setting (The default is 16384 bytes):
Vertex Cache Memory
When the Marmalade SDK transfoms your geometry it requires some work memory to place the transformed vertices prior to sending them to the GPU to be rendered. For example, if you are using IwGxFont to draw fonts then the vertices that make up the polygons of your glyphs will be transformed by the system into this vertex cache then rendered. You can change the amount of memory available for vertex transform using the following app.icf setting:
Keep an eye out for more bite sized tutorials coming very soon!