Righto - call me thicko

So i have wired up the new shiny CP7 to the HDR updated the firmware to 4.2.4.0 but i’m getting an An unhandled exception of type ‘System.OutOfMemoryException’ occurred in Microsoft.SPOT.Graphics.dll

public static Bitmap LCD = new Bitmap(800, 480);

erm - dazed and confused…

using GHI.Premium.Hardware;
using Microsoft.SPOT;

namespace CP7Test
{
    public class Program
    {
        public static Bitmap LCD = new Bitmap(800, 480);

        public static void Main()
        {
            SetLcdConfig();
            LCD.Clear();
            LCD.DrawImage(0, 0, Resources.GetBitmap(Resources.BitmapResources.Untitled_1), 0, 0, 800, 480);
            LCD.Flush();
            System.Threading.Thread.Sleep(-1);
        }
        static void SetLcdConfig()
        {
            Configuration.LCD.Configurations lcdConfig = new Configuration.LCD.Configurations();

            lcdConfig.Width = 800;
            lcdConfig.Height = 480;
            
            lcdConfig.OutputEnableIsFixed = true;
            lcdConfig.OutputEnablePolarity = true;

            lcdConfig.HorizontalSyncPolarity = true;
            lcdConfig.VerticalSyncPolarity = true;
            lcdConfig.PixelPolarity = false;

            lcdConfig.HorizontalSyncPulseWidth = 1;
            lcdConfig.HorizontalBackPorch = 46;
            lcdConfig.HorizontalFrontPorch = 16;
            lcdConfig.VerticalSyncPulseWidth = 1;
            lcdConfig.VerticalBackPorch = 23;
            lcdConfig.VerticalFrontPorch = 7;

            lcdConfig.PixelClockRateKHz = 25000;
            Configuration.LCD.Set(lcdConfig);
            if (Configuration.LCD.Set(lcdConfig))
                Microsoft.SPOT.Hardware.PowerState.RebootDevice(false); ;
        }
    }
}

Increase your heap size:

@ Architect - Thanks for the link, i have been looking for that after reading another post about increasing the heap.
You will still need to call me thicko as i can’t see it in 4.2

Looks like it is not in 4.2 yet.

Heap is fixed in 4.2 to something works for everyone but you need to keep in mind that you need to dispose images. Glide was tested fine to work with couple windows and keyboards. I think it is set to 3MB or 4MB.

Edit: Your code above should work fine with what we have so maybe you do not have the latest firmware?

I have been looking thu the CP7 Gadgeteer driver and cannot see anything obvious in there…
So how do you draw a 800x480 bitmap without memory issues?

@ Gus - latest and greatest firmware 4.2.4.0

Latest hdr firmware…soon as I create a bitmap it moans about out of memory…even 320x240…

Few suggestions:

  • allocate Bitmap inside Main
  • Force GC output before allocating the bitmap.

@ Architect - alas I have left the office…
I have 2 boards…shipping firmware doesn’t die but the CP7 isn’t happy…
Latest firmware screen appears happy but memory issues…

I am curious to see what GC shows for the available memory.

@ Architect - 7 mb I think from memory…no pun intended…

Must be a bug in the lates firmware. I will check on mine tonight.

@ Architect - cheers fella, I was going to cheekily ask you that very thing :slight_smile:

Righto - maybe i’m not totally thick…(my wife might beg to differ) :smiley:

From the Wiki “Bitmaps larger than 192,000 pixels are automatically allocated on the custom heap.”

A Bitmap of 442 x 441 (194922 pixels) works but any think else throws a memory error.

So it looks like Bitmaps (anything?) bigger than 190.8 kb causes the error.

So does that mean the it’s not using the Custom Heap?

We have found the issue, and i will be in the next SDK, due out in a couple of days. Cross-posting from the related thread to avoid confusion.