How to clear the memory of my Meadow

Sometimes when I get a lot of characters, I eventually get this error

Could not allocate 8571 bytes

How can I clear this?

Do you have the latest firmware installed?

Current release is beta 5.3.

Regards,
Mark

These are the versions I have:

Connecting to Meadow on COM3
Meadow by Wilderness Labs, Model: F7Micro, H/W Version: F7v1, MeadowOS Version: 0.5.3.0 (Aug 30 2021 20:08:28), Processor: STM32F777IIK6, Processor Id: 1e-00-3a-00-0d-51-38-32-37-35-36-30, Serial Number: 3070355F3238, CoProcessor: ESP32, CoProcessor OS Version: 0.5.3.0, Mono Version: 0.5.3.0, Device Name: MeadowF7
Done!

Maybe I need to explain my question more further. I am working at a firm that produces wooden floors and my boss and I are assembeling our meadows into the production machines. We want to keep track of all the data that goes through the machines.

For example, you walk to your machine and you start it up. When the machine goes on, the meadow goes on as well and starts up his own Maple server. When the machine is ready and the maple server is running. You walk to a computer nearby where we made an interface for the machine you’re working on. In the interface you select the floor you’re going to work on, after that you get two buttons, Start and Stop. When you click start button you send a request to the maple server, that receives a json object that contains information about the floor. So the meadow knows what floor you’re going to be working on. When the floor is received and the status is OK, we start a while loop. This loop keeps on going until you click the stop button. In the while loop, every 3 seconds a request is send to the maple server, asking if their is any data to receive. But what data? The data comes from a laser. (SICK | Sensor Intelligence < this one) The laser is connected to the meadow and it will read the length of a wooden plank. So it must be possible to send data every 3 seconds. But after a while there are 3 scenarios that could happen, first is that I get the error:

Could not allocate 8571 bytes.

Second is I get this error:

Meadow StdOut: memalign returned null – out of memory?
Meadow StdOut: mono_os_mutex_trylock: pthread_mutex_trylock failed with “Error code ‘142’” (142)

and the third scenario is that the maple server just stops and doesn’t log anything.

I tried to console log my memory with Console.WriteLine(GC.GetTotalMemory(false)); which shows me how much memory I have, but the memory stays consistent, it goes up but not that much. After a while I have around 1282488 memory and I start with around 1032100 memory.

I also tried the following code:

GC.Collect(2, GCCollectionMode.Forced);

Which I don’t know if it works. It doesn’t show much effect.

Hopefully you understand what I am trying to achieve. If their is any more information needed please let me know so I can provide it to you.

exampleMeadow

Here I have a small gif of what we are making. As you can see, when I click the start button. The meadow receives a json object. After that the method “getMeters” will be looped until you click stop. getMeters sends the currentlength as a response. ( this is dummy data, it’s just a number that keeps on adding up ). And it works, as you can see the number keeps on adding up. Even the memory stays around 1177680 But after a while it stops or I get a out of memory error.

exampleNothingHappens

As you can see, around 60 request, the server stops pinging and nothing happens… This must only happen when I click the stop button or I reset the maple server.

Did you ever figure this out? I am having the exact same issue.