This is my first post here, so please let me know if I am posting in the wrong place
So, as to the issue...
I have a setup where I am using one of the Netduino COMs as serial interface to an external chip (an IMU), communication works, and everything is fine and dandy (a.k.a I get my data through the serial), but I eventually (pretty much at predictable intervals) get an 'Out of Memory' error.
I honestly thought that moving to a managed framework meant that you didn't have to care about your memory anymore, is that true? do I need to release / dispatch memory blocks somehow? Do I need to manually invoke the garbage collector?
Could you give a look to the code and tell me if I am doing something terribly wrong?
thanks!!
-rod
IMUSerial = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); IMUSerial.DataReceived += new SerialDataReceivedEventHandler(IMUSerial_DataReceived); IMUSerial.Open(); //write IMU code Debug.Print("Serial is " + (IMUSerial.IsOpen? "open" : "not opened")); byte[] pip = System.Text.Encoding.UTF8.GetBytes("r"); Debug.GC(true); while (true) { IMUSerial.Write(pip, 0, 1); Thread.Sleep(100); } static void IMUSerial_DataReceived(object sender, SerialDataReceivedEventArgs e) { byte[] buffer = new byte[10]; IMUSerial.Read(buffer, 0, 10); String message = new String(System.Text.Encoding.UTF8.GetChars(buffer)); Debug.Print(message); }