Why the same program uses more memory in a G30 than a G80?

Hi. I am developing a program that will run in G30 and G80 SoC, and I noticed that when I deploy the program to a G30, its size is 7K larger than when I deploy it to a G80. Just to be sure, I did a test with a very simple program and I got the same results.

Looking at the deploy messages I noticed that Microsoft.SPOT.Graphics.pe and Microsoft.SPOT.IO.pe are included only for the G30, and probably that explains the difference in size, but I don’t understand why they are included for the G30 (or why they are not included in the case of the G80).

I am getting some OutOfMemory exceptions in the G30 (in my production program) so if I can get rid of those 7K I’ll be more than happy.

Here is the program (I’m also attaching screenshots of deployment messages for both processors).

namespace WISEBOX
{
    public class Program
    {
        public static void Main()
        {
            int ciclo = 0;              // Contador de ciclos
            Debug.Print("Iniciando\n\r");
            Debug.Print("Fecha-Hora RTC  :" + RealTimeClock.GetDateTime().ToString());
            Debug.Print("Fecha-Hora Local:" + DateTime.Now.ToString());
            while (true)
            {
                ciclo++;
                Thread.Sleep(1000);
                Debug.Print("Ciclo=" + ciclo.ToString());
            }
        }
    }

}

Any help will be heartily appreciated.

JCP

A deployed program is written to flash. An out of memory exception refers to RAM.

Most likely, the memory shortage is caused by your program, not the program size.

Thanks a lot or the replies. Now I see I was putting a lot of effort trying to reduce code size and the problem was on my RAM usage.

I did some tests and noticed that OutOfMemory exceptions occur more often when I read a file from an SD card. I added a Debug.GC(true) sentence just before opening the files and now OutOfMemory are less frequent.

I am using Debug.Print(Debug.GC(true).ToString()) to check available RAM and it is always somewhere between 13000 and 14000 bytes.

The files I am reading are small text files of less than 1 or 2 Kb (mainly help files I am providing to my project users and serialized images of parameter arrays I load into RAM when my program starts). Those arrays are small too (less than 1Kb).

Any advices on how to analize and optimize RAM usage?

@ jcplaza@ wiseaccess.com -

are you able to show your code?

@ jcplaza@ wiseaccess.com - OutOfMemotyException is thrown when there is no single large enough block of Memory for your request.
This can happen when you allocate and free Memory often (fragmentation).
If you have a read buffer for your file, you should not create it each time you read, but only once at program Startup (or 1st usage) and then reuse the same buffer over and over again (store it as a static field).
This will also improove Performance.

Dat: unfortunalety I am not allowed to show the code.

Reinhard: I’ll do as you say.

As an embedded systems programmer I tend to be very conservative with resources in all my projects. But when I started this one, my very first project with Visual Studio, C#, OO programming, etc., I got dazzled by the easiness of this environment and completely forgot to be conservative.

A common netmf syndrome. I think everyone catches it. Almost everyone builds up a resistance to catching it again.