Out of memory (to many layouts in DF?)

Hi, I'm building a complex data field that uses layouts. I currently have 7 different layouts defined in my layouts.xml file (to handle different devices and field obscures). When I run the DF in my SIM I get this in my console:

Error: Out Of Memory Error
Details: Failed invoking <symbol>
Stack:
- MainLayout() at Rez:40 0x10001b3f
- onLayout() at  

 This happens when I test multiple field layouts in the SIM. 

if I remove one of my layouts (having only 6 different layouts) in the layouts.xml file the problem disappears. 

I understand it may be a simulation problem only since you typically cannot run the same DF on multiple fields on the same "screen" on the device, but it would be very helpful to be able to test all field layouts in the sim. 

 Is there a known memory limitation in the Simulator, or am I doing something wrong with my layouts?

Layouts.xml:

<layouts>
    
    <!-- A generic, centered layout. -->
    <layout id="MainLayout">
        <drawable class="Background" />
        <bitmap id="img" x="dc.getWidth()/2 + 25" y="dc.getHeight()/2" filename="../drawables/None.png" />
        <label id="label" x="center" y="3" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        <label id="value" x="dc.getWidth()/2+20" y="dc.getHeight()/2 - 5" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MEDIUM" />
        <label id="message" x="center" y="dc.getHeight()/2" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_MEDIUM" />
    </layout>
    
    <!-- A generic, centered layout for Edge devices. -->
    <layout id="EdgeLayout">
        <drawable class="Background" />
        <bitmap id="img" x="dc.getWidth()/2 + 20" y="dc.getHeight()/2-3" filename="../drawables/None.png" />
        <label id="label" x="center" y="3" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        <label id="value" x="dc.getWidth()/2+15" y="dc.getHeight()/2 - 5" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MILD" />
        <label id="message" x="center" y="dc.getHeight()/2" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_MEDIUM" />
    </layout>
    
    <!-- centered layout for 1-field layout. Flag = 15 -->
    <layout id="FullLayout">
        <drawable class="Background" />
        <bitmap id="img" x="dc.getWidth()/2 + 35" y="center" filename="../drawables/None.png" />
        <label id="label" x="center" y="dc.getHeight()/2 - 60" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        <label id="value" x="dc.getWidth()/2 + 30" y="center" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_HOT" />
        <label id="message" x="center" y="center" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_LARGE" />
    </layout>
    
    <!-- Top Left. Flag = 3 -->
    <layout id="TopLeftLayout">
         <drawable class="Background" />
         <bitmap id="img" x="dc.getWidth()/2 + 25" y="80" filename="../drawables/None.png" />
        <label id="label" x="dc.getWidth()/2 + 10" y="45" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        <label id="value" x="dc.getWidth()/2 + 20" y="75" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MEDIUM" />
        <label id="message" x="dc.getWidth()/2 + 10" y="75" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
    </layout>
    
    <!-- Top Right. Flag = 6 -->
    <layout id="TopRightLayout">
         <drawable class="Background" />
        <bitmap id="img" x="dc.getWidth()/2 + 15" y="80" filename="../drawables/None.png" />
        <label id="label" x="dc.getWidth()/2 - 10" y="45" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        <label id="value" x="dc.getWidth()/2 + 10" y="75" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MEDIUM" />
        <label id="message" x="dc.getWidth()/2 - 10" y="75" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" /> 
    </layout>
    
    <!-- Bottom Left. Flag = 9 -->
    <layout id="BottomLeftLayout">
         <drawable class="Background" />
        <bitmap id="img" x="dc.getWidth()/2 + 30" y="35" filename="../drawables/None.png" />
        <label id="label" x="center" y="0" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        <label id="value" x="dc.getWidth()/2 + 25" y="30" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MEDIUM" />
        <label id="message" x="center" y="30" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        
    </layout>
    
    <!-- Bottom Right. Flag = 12 -->
    <layout id="BottomRightLayout">
         <drawable class="Background" />
        <bitmap id="img" x="dc.getWidth()/2 + 15" y="35" filename="../drawables/None.png" />
        <label id="label" x="center" y="0" color="Graphics.COLOR_LT_GRAY" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
        <label id="value" x="dc.getWidth()/2 + 10" y="30" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_RIGHT" font="Graphics.FONT_NUMBER_MEDIUM" />
        <label id="message" x="center" y="30" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" font="Graphics.FONT_TINY" />
    </layout>
    
</layouts>

And here is where I set the layout in the onLayout() function:

    // Top left quadrant so we'll use the top left layout (3)
       	if (obscurityFlags == (OBSCURE_TOP | OBSCURE_LEFT)) { 
            View.setLayout(Rez.Layouts.TopLeftLayout(dc));
            
        // Top right quadrant so we'll use the top right layout (6)
        } else if (obscurityFlags == (OBSCURE_TOP | OBSCURE_RIGHT)) { 
            View.setLayout(Rez.Layouts.TopRightLayout(dc));
           
        // Bottom left quadrant so we'll use the bottom left layout (9)
        } else if (obscurityFlags == (OBSCURE_BOTTOM | OBSCURE_LEFT)) {
            View.setLayout(Rez.Layouts.BottomLeftLayout(dc));
          
        // Bottom right quadrant so we'll use the bottom right layout (12)
        } else if (obscurityFlags == (OBSCURE_BOTTOM | OBSCURE_RIGHT)) { 
            View.setLayout(Rez.Layouts.BottomRightLayout(dc));          
            
        // square device (edge) layout (0)
        } else if (obscurityFlags == 0) { 
        	View.setLayout(Rez.Layouts.EdgeLayout(dc));
        	
        // one-field full layout (15)
        } else if (obscurityFlags == (OBSCURE_TOP | OBSCURE_RIGHT | OBSCURE_BOTTOM | OBSCURE_LEFT)) { 
        	View.setLayout(Rez.Layouts.FullLayout(dc));

        // For all other fields, use the generic centered layout
        } else {
            View.setLayout(Rez.Layouts.MainLayout(dc));
          
        }

  • Amazing, it seems to work!! I only implemented your first suggestion and I have not seen any out of memory messages yet but I think I am close to the max memory so will take a stab at your second suggestion as well to see if I can reduce memory consumption a bit more. You really made my day!