open62541 / open62541

Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
http://open62541.org
Mozilla Public License 2.0
2.58k stars 1.24k forks source link

Correct way to reduce the RAM requirements of application by reducing the size of information model? #3988

Open nqduy35 opened 3 years ago

nqduy35 commented 3 years ago

Hello everyone,

I heard about the myth that "it is possible to configure minimal servers that require less than 100kB of RAM and ROM" published here. I did everything except to reduce the information model, and the RAM and ROM requirements are still high: running a server example requires 800KB of RAM. So I decided to reduce the information model NS0 by trying to remove unnecessary nodes. I want to find a "correct way" to do it. One way to do it I post in the issue #3978, but it does not work. Please give me some advice?

Many thanks for considering my request.

Checklist

Please provide the following information:

jpfr commented 3 years ago

Have you tried selecting the minimal ns0 in the build config?

nqduy35 commented 3 years ago

I have run through and applied every tip in the tutorial. In the tutorial, there is also these lines

The RAM requirements of a server are mostly due to the following settings:

  • The size of the information model
  • The number of connected clients
  • The configured maximum message size that is preallocated

Follow the above remarks, I have already:

But RAM consumption is still high.

juangburgos commented 3 years ago

Already on this topic, maybe we should start thinking on a way of abstracting the node store (including references), in such a way that it can be moved to different backends (as done with the historic plugin).

The case being, in QUaServer I have been playing with alarms. In specific the ExclusiveLevelAlarm has a very heavy information model, just for one instance, because includes state machines, with lots of nodes and references. So I made tests with around 1000 alarms (which is not much for an industrial application) and the server eats up to 100 megs.

Now to be fair, every node in QUaServer is also a QObject, which adds to the problem, but when I profile the memory, actually the objects that consume most memory (around 40%) are OpcUa references (references within nodes) instantiated by open62541.

Ideally, by abstracting out the node store and references, one could move all that data to (for example) an SQLite database. True this would penalize speed of data access, but would reduce dramatically the use or RAM.

Tradeoffs...