Is this a memory problem?

Hello all,
I am using a Cerberus running 4.2. I have an RS232 module, an ENC28 module and a Char display.

My app takes Serial data massages it and creates an XML file that I am pushing out a socket connection on the ethernet port.

It all runs fine for about a half hour then just freezes…the debug messages stop, the socket stops publishing…just dead.

I am not seeing any exceptions or threads being abandoned.

I have tried the serial port on its own thread and on the main thread. I have read that some people are giving the serial port a sleep(10) to allow for GC, but I felt like that was in a system they were writing to not reading from.

Any suggestions?

Thanks in advance.

Could be OOM of a buffer overflow. Try running with MFDeploy attached and see if it spits anything out.

I have attached MFDeploy, I can see my debug statements,
I am seeing this float by but it does not seem to effect anything.

memp_malloc: out of memory in pool UDP_PCB

Cerberus has little memory. Try optimizing your resources.

That’s definitely a memory issue. Like Gus said, try an optimize code. Also throw it into RELEASE mode instead of DEBUG, this will free up a few resources for you.

The memp_alloc was a red herring in my call to a time server, I have cleared that up.

I have done the optimize, put it in release mode and started it with MFDeploy attached.
17 minutes in and just stopped, nothing in MFDeploy screen

What should I be looking for?

Can you provide us with something somewhat simple that we can test on our end?

hmm, let me see if I can pare out some code and see if it still happens.

I am trying to separate the code to make it simpler, it is difficult… did notice something though.

I am making a socket connection to a Time server using with some adapted code I saw on here.
As you can see it is an extension method of DateTime.

After it runs for a while It will start to throw exceptions of “System.Net.Sockets.SocketException” error code 10055…
When it hits the New Socket(… command

once this starts to fail, it will continue to fail…looks like indefinately

Here is the code:

    public static void SetFromNetwork(this DateTime dateTime, TimeSpan timeZoneOffset)
            var ran = new Random(DateTime.Now.Millisecond);
            var servers = new[]

            Debug.Print("Setting Date and Time from Network"); 

//Fails here
                    var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                    var endpoint = servers[ran.Next(servers.Length)];
                    Debug.Print("Calling Time server" + endpoint);
                    var endPoint = new IPEndPoint(Dns.GetHostEntry(endpoint).AddressList[0], 123);

                    var timeServerMessage = new byte[48]; // RFC 2030
                    timeServerMessage[0] = 0x1B;
                    for (int x = 1; x < 48; x++)
                        timeServerMessage[x] = 0;


                    byte offsetTransmitTime = 40;
                    ulong intpart = 0;
                    ulong fractpart = 0;
                    for (int x = 0; x <= 3; x++)
                        intpart = 256*intpart + timeServerMessage[offsetTransmitTime + x];

                    for (int x = 4; x <= 7; x++)
                        fractpart = 256*fractpart + timeServerMessage[offsetTransmitTime + x];

                    ulong milliseconds = (intpart*1000 + (fractpart*1000)/0x100000000L);

                    if (timeServerMessage[47] != 0)
                        TimeSpan timeSpan = TimeSpan.FromTicks((long) milliseconds*TimeSpan.TicksPerMillisecond);
                        var tempDateTime = new DateTime(1900, 1, 1);
                        tempDateTime += timeSpan;
                        DateTime networkDateTime = (tempDateTime + timeZoneOffset);
                catch (Exception ex)
                     Debug.Print("Time sync threw and exception:" + ex.Message);

can these errors eat the memory?


error 10055 means you have run out of buffers.

What does “run out of buffers” mean?
How do I fix it?
The socket is created, used, and closed.
The call is coming from a discrete thread just for sync of the clock.
I am not using a buffer.

after closing the socket set the var to null. then do a Debug.GC(true). see if that helps.

10055 means IP ran out of buffers. you might have a memory problem somewhere else in your program. when you do Debug.GC it will display available memory.

Thanks for the help. would this effect the memory over time?

@ Tal_McMahon - not sure what “this” is? I suspect you are running out of memory. you need to study your program and calculate memory usage.