We are using the Gurux library to make a meters simulator used for testing purpose. We have around a hundred COSEM objects per meter including some from "Profile Generic" family (Class_id: 7) with a data history of several weeks in buffers.
The problem is that all this server instances with their COSEM objects takes a lot of space in JVM memory (~ 600KB per instance of GXDLMSServer and we have max 1000 counters, so we finally exceed 512MB Heap !
I want to have your advice in order to reduce the memory footprint and if you have already been faced with this problem for example when you want to deploy on a raspberry or device with small configuration ?
We have some ideas like storing some meters data in the database (eg sqlite) instead of heap memory.
Can you please telle me if i have understood correctly :
Solution 1 :
1 instance of gurux server for all meters, there are juste some constraints if we share all objects, some of them contains specific datas (eg : identifiers, security keys, ...) or when some object is set for 1 meter it will be updated for all meters ?
Solution 2 :
The reading method for objects (other than profile generic) stay the same (objects live always in memory)
I have never used the PreRead/PostRead method, I am interested if you have an example of how to use it with profile generic data.
"PreRead can be used if values are not in memory"
"PostRead is called after value is retrieved. Here server can close connections, release memory, etc."
1) I will check in "PreRead" method if it is a profile generic object and if yes i will initialize data for this object
2) After profile generic data reading, in "PostRead" I clean data from memory
Create 1000 instances from the server, but create objects, like clock only once.
I believe that now you create 1000 instances from clock object.
Create objects and give objects to the created server as a parameter.
Something like this:
//Only one instance.
GXDLMSClock clock1 = new GXDLMSClock();
for (int i = 0; i != 1000; i++)
{
GXDLMSServer s = new GXDLMSServer();
s.Items.Add(clock1);
}
Hi Mansour,
Hi Mansour,
Create objects once and share those objects for all meters.
So you have only one instance from the objects and 1000 instances from the counters.
You can also release profile generic data after reading in PostRead method.
BR,
Mikko
Hi Mikko,
Hi Mikko,
Thank you very much for your strategy advices !
Can you please telle me if i have understood correctly :
Solution 1 :
1 instance of gurux server for all meters, there are juste some constraints if we share all objects, some of them contains specific datas (eg : identifiers, security keys, ...) or when some object is set for 1 meter it will be updated for all meters ?
Solution 2 :
The reading method for objects (other than profile generic) stay the same (objects live always in memory)
I have never used the PreRead/PostRead method, I am interested if you have an example of how to use it with profile generic data.
"PreRead can be used if values are not in memory"
"PostRead is called after value is retrieved. Here server can close connections, release memory, etc."
1) I will check in "PreRead" method if it is a profile generic object and if yes i will initialize data for this object
2) After profile generic data reading, in "PostRead" I clean data from memory
Best Regards,
Mansour
Hi Mansour,
Hi Mansour,
Create 1000 instances from the server, but create objects, like clock only once.
I believe that now you create 1000 instances from clock object.
Create objects and give objects to the created server as a parameter.
Something like this:
//Only one instance.
GXDLMSClock clock1 = new GXDLMSClock();
for (int i = 0; i != 1000; i++)
{
GXDLMSServer s = new GXDLMSServer();
s.Items.Add(clock1);
}
BR,
Mikko