How much RAM and Flash am I using?

I’m trying to figure out how much memory my application is using on my Raptor board but I don’t really understand how to interpret the information that VS2013 gives me. I’m particularly interesting in knowing how much I’m using of the 92 MBytes of RAM and 1.4 MBytes of Flash that are available on the Raptor, but I’d kind of like to know what all the other numbers mean like STRING, FREEBLOCK, ASSEMBLY, BINARY_BLOB_HEAD, and APPDOMAIN_HEAD. Here is what shows up in the VS2013 output window when I download my app.

Thanks - Gene

Found debugger!

Create TS.

 Loading start at 202dd578, end 2030ca0c

   Assembly: mscorlib (4.3.1.0)     Assembly: Microsoft.SPOT.Native (4.3.1.0)     Assembly: Microsoft.SPOT.Security.PKCS11 (4.3
.1.0)     Assembly: System.Security (4.3.1.0)     Assembly: Microsoft.SPOT.Hardware (4.3.1.0)  
   Assembly: Microsoft.SPOT.Graphics (4.3.1.0)     Assembly: Microsoft.SPOT.TinyCore (4.3.1.0)  
   Assembly: Microsoft.SPOT.IO (4.3.1.0)     Assembly: System.IO (4.3.1.0)     Assembly: Microsoft.SPOT.Hardware.Usb (4.3.1.0) 
    Assembly: Microsoft.SPOT.Hardware.SerialPort (4.3.1.0)     Assembly: Microsoft.SPOT.Touch (4.3.1.0)  
   Assembly: Microsoft.SPOT.Ink (4.3.1.0)     Assembly: Microsoft.SPOT.Hardware.PWM (4.3.1.0)  
Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: GHI.Hardware (4.3.7.10)  Attaching deployed file.

   Assembly: System (4.3.1.0)  Attaching deployed file.

   Assembly: CPF (1.0.0.0)  Attaching deployed file.

   Assembly: GHI.Usb (4.3.7.10)  Attaching deployed file.

   Assembly: GHI.Pins (4.3.7.10)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net (4.3.1.0)  Attaching deployed file.

   Assembly: MissionClass (1.0.0.0)  Resolving.

GC: 2msec 350472 bytes used, 66755292 bytes available

Type 0F (STRING              ):     24 bytes

Type 15 (FREEBLOCK           ): 66755292 bytes

Type 17 (ASSEMBLY            ):  35520 bytes

Type 1E (BINARY_BLOB_HEAD    ): 314856 bytes

Type 34 (APPDOMAIN_HEAD      ):     72 bytes

GC: performing heap compaction...

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\mscorlib.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Native.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Graphics.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.TinyCore.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Touch.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Ink.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\NETMF v4.3 SDK\Libraries\le\GHI.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Net.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'V:\Software\Gene\CPF\MissionClass\MissionClass\bin\Debug\le\MissionClass.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'V:\Software\Gene\CPF\CPF\bin\Debug\le\CPF.exe', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\NETMF v4.3 SDK\Libraries\le\GHI.Usb.dll'
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\NETMF v4.3 SDK\Libraries\le\GHI.Pins.dll'
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Program Started

1 Like

For Flash:
Erase your application with FezConfig and then deploy it with VS. The Output window will Show you how much was deployed.

For RAM:
Call
Debug.GC(false);
The return value it the remaining RAM in Bytes.
The Output in the Output window (when Debugger is attached) will Show you how much RAM is used, and what types are using how much.

Hope this helps.

1 Like

@ Reinhard Ostermeier - Won’t Debug.GC(false) first clear some memory then report on the free size?

No, i don’t think so.
Debug.GC(true);
would do so if I understand this bool Parameter correctly.

Seems like the information in the output window might be pretty useful and I’d like to understand a little more about what it means so I’ll try to be more specific. One of the lines in the output window says

“Loading start at 202dd578, end 2030ca0c” The difference between those 2 hex value is decimal 193684. Does that mean my app used that much flash or does it mean something else?

It also says “GC: 2msec 350472 bytes used, 66755292 bytes available” Does that mean I need 350472 bytes of RAM or something else? And why are only 66.7 MBytes available when GHI suggest there are 92 MBytes available?

Are any of the following numbers important for me to know? If so, does anyone know what they mean?

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 66755292 bytes

Type 17 (ASSEMBLY ): 35520 bytes

Type 1E (BINARY_BLOB_HEAD ): 314856 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

Thanks

In a managed and dynamic system like netmf, ram usage changes constantly depending on your needs and your coding style. The good news is that you probably have a lot more ram than you ever need.

Flash is the same, if you are only storing code in flash, then you will probably never use it all.

But what others pointed out is good if you are curious.

The bool parameter is for forcing collection immediately. You will need to specify it true for expected results.

350472 bytes is how many Bytes your application is currently using,
66755292 bytes is how many Bytes are currently available for your application
The difference between the official 92MByte RAM and the available 67MByte is used for several other Things.
The RAM is partitionized for several usages:
Runtime, Code, some is reserved for RLP, …
I think GHI added this Information to the documentation somewhere.