Jerry

Jerry

  • NA
  • 8
  • 0

The memory problem with .netcf on wince6.0

Jun 6 2011 9:09 PM

Hi,

I have a c# program which is working with .netcf3.5 on wince6.0 with 256M Ram.

The program is very large and cannot successfully run. It seems to be some kind of problem about memory. So I tried to simplify the situation and got the following result:

I use vs2008 to create a smart device project and place a button on the Form1 and then click "View Code". I just try to allocate 32MB of memory before InitializeComponent() as below:

 

public partial class Form1 : Form

    {

        public Form1()

        {

            byte[] data = new byte[1048576 * 32];

            InitializeComponent();

        }

    }

After running it, an error message "Application encountered a serious error and must shut down!" appears.

if I set break point on the line of "InitializeComponent();", the error appears after stepping over.

If not, it appears after I pressing the OK button on the upper right of Form1.

Even I move the allocation line back before the line "Application.Run(new Form1());", same thing!

If I change to allocate 32MB after the line of "InitializeComponent();", it works fine.

My problem is, since my platform has so large of free memory, why the simple program cannot run? Is there something about .NetCf3.5 memory rule that I don't know?

Are there any ideas available to me?

thanks in advance,


Answers (5)