Skip to content

Persistent BadOutOfMemory errors with Arduino Opta OPC UA server #44

@alejandrofdelhierro

Description

@alejandrofdelhierro

Hello,

I am running the Arduino Opta (RS485 variant) with the Arduino OPC UA library (Arduino_OPC_UA) as an embedded OPC UA server. The server runs fine initially, but after several hours or days under load it eventually starts returning BadOutOfMemory to OPC UA clients, and the SecureChannel is closed.

Typical log excerpt:

[info/channel] TCP … | SC 3190 | Processing the message failed with StatusCode BadOutOfMemory. Closing the channel.
[warn/channel] TCP … | SC 3190 | Processing the message failed with error BadOutOfMemory

From the O1Heap diagnostics we see that:

Heap capacity ~393 KB
Peak allocated climbs close to the limit
oom_count (out-of-memory events) increases over time

We added telemetry, memory guards, and even a “recycle” mechanism to restart the OPC UA server thread when OOM occurs. This helps, but the server sometimes fails to restart cleanly because the TCP socket on port 4840 cannot be rebound immediately (Error binding the socket to the address …).

What we tried so far:

Increased server heap size (O1Heap) to ~384 KB.
Limited subscriptions, sessions, monitored items in UA_ServerConfig.
Added memory watchdog and automatic server recycle on OOM.
Added backoff/retry logic to UA_Server_run_startup() to cope with TIME_WAIT.

Remaining issues:

Even with the above, OOM events still occur after long runtime.
After recycling, the server sometimes cannot bind port 4840 for several seconds and startup fails.
The client only performs lightweight reads (about 20 variables every 2 minutes), so the memory growth looks unexpected.

Questions to the community:

Has anyone else observed memory fragmentation or leaks in the current Arduino Opta OPC UA library build (based on open62541)?
Are there recommended patches or configuration flags to stabilize memory usage over long uptime?
Any guidance on making the server recycle/restart more reliably on constrained devices like the Opta?

Thanks a lot in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions