I Added a new class to my project and when building it comes CLE_E_OUT_OF_MEMORY Error. In This class i have 36 double type variables. When I comment out variables and getters/setters the error disappears. How much there is memory for variables in EMX?
For a start, you MUST get Visual C# Express 2010 (or a 2010 version of VS) if you’re using the current 4.1 SDK.
And if you’re using an older SDK you may just be hitting an old bug that’s now fixed (although I doubt it). Ultimately, unless you have a reason not to, then you need to move to the latest SDK
OOM errors are usually easiest to debug when you monitor GC output over time, so it’ll help if you share what you see there. (edit: when BUILDING. GC won’t help here sorry )
If you’re worried about having 36 of these objects have you tried 1 and seen whether that works - and if it does then you don’t have to worry about whether it’s a valid thing to use yeah
And finally, OOM errors are usually coding errors. Get back to the smallest code sample that shows the fault and share that with us again.
There are somethings that you can improve for sure. Work with ArrayList in your load method - do not convert it to array of strings. In your save method you create a string out of all individual values and then you split it,just write the values directly to the stream, there is no need to do that extra work.
Do you have any idea why the CLR_E_OUT_OF_MEMORY Error occurs when building project with visual studio 2008 professional. I do not have SDK 4.1 but 4.0.3. If You look at the GC listing from currently working version, is there something which points to memory problem?
Here is smallest code which generates the error when building the project. If I comment out the last getter/setter line (AirFlowExhaust) or any other then the error disappears.
/*
** File: HeatRecoverySettings.cs
** Description: Heat Recovery Settings
** Author: Aarni Jäntti
** +358-504675562
** aarni.jantti@ gsd.fi
** Date: 16.03.2011
**
*/
using System;
using System.Collections;
using System.IO;
using Microsoft.SPOT;
namespace GSD.MF.Utilities
{
public sealed class HeatRecoverySettings
{
static readonly HeatRecoverySettings instance = new HeatRecoverySettings();
private double airdensity = 1.2;
private double duct1widthinlet = 0.0;
private double duct2widthinlet = 0.0;
private double duct1heightinlet = 0.0;
private double duct2heightinlet = 0.0;
private double duct1surfaceinlet = 0.0;
private double duct2surfaceinlet = 0.0;
private double ductround1diameterinlet = 0.0;
private double ductround1amountinlet = 0.0;
private double ductround1surfaceinlet = 0.0;
private double ductround2diameterinlet = 0.0;
private double ductround2amountinlet = 0.0;
private double ductround2surfaceinlet = 0.0;
private double ducttotalsurfaceinlet = 0.0;
private double duct1widthexhaust = 0.0;
private double duct2widthexhaust = 0.0;
private double duct1heightexhaust = 0.0;
private double duct2heightexhaust = 0.0;
private double duct1surfaceexhaust = 0.0;
private double duct2surfaceexhaust = 0.0;
private double ductround1diameterexhaust = 0.0;
private double ductround1amountexhaust = 0.0;
private double ductround1surfaceexhaust = 0.0;
private double ductround2diameterexhaust = 0.0;
private double ductround2amountexhaust = 0.0;
private double ductround2surfaceexhaust = 0.0;
private double ducttotalsurfaceexhaust = 0.0;
private double heatrecoveryinlet = 0.0;
private double heatingcapacityinlet = 0.0;
private double airflowinlet = 0.0;
private double heatrecoveryexhaust = 0.0;
private double coolingcapacityexhaust = 0.0;
private double airflowexhaust = 0.0;
public double AirDensity { get { return airdensity; } set { airdensity = value; } }
public double Duct1WidthInlet { get { return duct1widthinlet; } set { duct1widthinlet = value; } }
public double Duct2WidthInlet { get { return duct2widthinlet; } set { duct2widthinlet = value; } }
public double Duct1HeightInlet { get { return duct1heightinlet; } set { duct1heightinlet = value; } }
public double Duct2HeightInlet { get { return duct2heightinlet; } set { duct2heightinlet = value; } }
public double Duct1SurfaceInlet { get { return duct1surfaceinlet; } set { duct1surfaceinlet = value; } }
public double Duct2SurfaceInlet { get { return duct2surfaceinlet; } set { duct2surfaceinlet = value; } }
public double DuctRound1DiameterInlet { get { return ductround1diameterinlet; } set { ductround1diameterinlet = value; } }
public double DuctRound1AmountInlet { get { return ductround1amountinlet; } set { ductround1amountinlet = value; } }
public double DuctRound1SurfaceInlet { get { return ductround1surfaceinlet; } set { ductround1surfaceinlet = value; } }
public double DuctRound2DiameterInlet { get { return ductround2diameterinlet; } set { ductround2diameterinlet = value; } }
public double DuctRound2AmountInlet { get { return ductround2amountinlet; } set { ductround2amountinlet = value; } }
public double DuctRound2SurfaceInlet { get { return ductround2surfaceinlet; } set { ductround2surfaceinlet = value; } }
public double DuctTotalSurfaceInlet { get { return ducttotalsurfaceinlet; } set { ducttotalsurfaceinlet = value; } }
public double Duct1WidthExhaust { get { return duct1widthexhaust; } set { duct1widthexhaust = value; } }
public double Duct2WidthExhaust { get { return duct2widthexhaust; } set { duct2widthexhaust = value; } }
public double Duct1HeightExhaust { get { return duct1heightexhaust; } set { duct1heightexhaust = value; } }
public double Duct2HeightExhaust { get { return duct2heightexhaust; } set { duct2heightexhaust = value; } }
public double Duct1SurfaceExhaust { get { return duct1surfaceexhaust; } set { duct1surfaceexhaust = value; } }
public double Duct2SurfaceExhaust { get { return duct2surfaceexhaust; } set { duct2surfaceexhaust = value; } }
public double DuctRound1DiameterExhaust { get { return ductround1diameterexhaust; } set { ductround1diameterexhaust = value; } }
public double DuctRound1AmountExhaust { get { return ductround1amountexhaust; } set { ductround1amountexhaust = value; } }
public double DuctRound1SurfaceExhaust { get { return ductround1surfaceexhaust; } set { ductround1surfaceexhaust = value; } }
public double DuctRound2DiameterExhaust { get { return ductround2diameterexhaust; } set { ductround2diameterexhaust = value; } }
public double DuctRound2AmountExhaust { get { return ductround2amountexhaust; } set { ductround2amountexhaust = value; } }
public double DuctRound2SurfaceExhaust { get { return ductround2surfaceexhaust; } set { ductround2surfaceexhaust = value; } }
public double DuctTotalSurfaceExhaust { get { return ducttotalsurfaceexhaust; } set { ducttotalsurfaceexhaust = value; } }
public double HeatRecoveryInlet { get { return heatrecoveryinlet; } set { heatrecoveryinlet = value; } }
public double HeatingCapacityInlet { get { return heatingcapacityinlet; } set { heatingcapacityinlet = value; } }
public double AirFlowInlet { get { return airflowinlet; } set { airflowinlet = value; } }
public double HeatRecoveryExhaust { get { return heatrecoveryexhaust; } set { heatrecoveryexhaust = value; } }
public double CoolingCapacityExhaust { get { return coolingcapacityexhaust; } set { coolingcapacityexhaust = value; } }
public double AirFlowExhaust { get { return airflowexhaust; } set { airflowexhaust = value; } }
public static HeatRecoverySettings Instance
{
get
{
return instance;
}
}
}
}
Ok, thanks Architect, so the Visual Studio 2008 Professional is the problem and i should do what Gus and Bret stated for updating to VS 2010 and SDK 4.1.
Now I have updated to VS2010 and NETMF 4.1 and updated TinyBooter and Firmware to the lates version 4.1. I still got the same error and then I looked a bit closer the link from Architect http://netmf.codeplex.com/workitem/310 and understand that this is compiler problem which will be corrected in version NETMF 4.2?
I would suspect a restriction of NETMF. I think I remember that double array [][] are not supported and leads to “violent” exception without clear message. May be this is somewhere connected. Can you change the way you allocate the arrays
ArrayList al = new ArrayList();
string[] s = (string[])al.ToArray(typeof(string));
I would suggest a test with may be fixed size.