Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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 if 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,

[edit]Code block added, urgency deleted: It may be urgent to you, but it isn't to us. All that your stressing the urgency does is to make us think you have left it too late, and want us to do it for you. This annoys some people, and can slow a response.- OriginalGriff[/edit]
Posted
Updated 2-Jun-11 21:23pm
v3
Comments
Dalek Dave 3-Jun-11 3:23am    
Edited for Grammar and Readability.

Seems to me that the size of the program is not an issue (how large is it?). I think it's more about how you use your memory. Are you disposing objects you are done with?

As long as there is a reference to an object, the garbagecollector will not remove it from memory.
 
Share this answer
 
Thanks for reply,

As mentioned in the last post, I have simplified the large program into a small and simple one as below:
public partial class Form1 : Form
{
public Form1()
{
byte[] data = new byte[1048576 * 32];
InitializeComponent();
}
}
and within InitializeComponent(), just for one button from .netcf. Further more, I thought no more 32MB limits for wince6 and there is still so large free memory and my program is the first one running up after the os booted, the memory should be clean. Am I right?

Is there still any memory concepts about .netcf3.5 and wince6.0 that I don't know?

Thanks!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900