Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Possible memory leakage writing item on subscription
September 25, 2013
15:30, EEST
Avatar
d.zinato
Member
Members
Forum Posts: 9
Member Since:
September 25, 2013
sp_UserOfflineSmall Offline

Hi all, i have this problem : testing your OPC UA Client, i wrapped it into an OSGi bundle ( i’m working on Eclipse Equinox).
I created a simple thread that writes every second a random integer value on a MemoryBased variable (I’m using Kepware OPC UA Server).

If i register my variable on a MonitoredDataItemListener, the java process memory (Private Bytes) raises from 151 mb to 155 mb in less than an hour.
Instead, if i don’t use a MonitoredDataItemListener, and maintain the same write procedure, the process memory is more stable (~0.2 Mb in 30 minutes).

I’m not able to understand if this is a real leak, or it is a normal memory fluctuation, and with a long-time run it disappears….is it possible to run the evaluation library for an entire day (and not only for 2 hours)?

Otherwise, this is my write procedure :

public void writeItem(String itemFullName, Object value) throws Exception {
//translate itemFullName, i.e. MB.LW_MONITOR.LW_HEART_BEAT_TH1 , in a ReferenceDescription
ReferenceDescription found=util.getItemReference(itemFullName);
NodeId nodeId=client.getNamespaceTable().toNodeId(found.getNodeId());
UaNode node = client.getAddressSpace().getNode(nodeId);
if(node==null) throw new Exception(“Null node!”);
UaVariable v = (UaVariable) node;
if (v.getDataType() == null)
v.setDataType(client.getAddressSpace().getType(v.getDataTypeId()));
UaDataType dataType = (UaDataType) v.getDataType();
Object convertedValue=null;
try {
convertedValue = dataType != null ? client.getAddressSpace().getDataTypeConverter().parseVariant(value.toString(), dataType): value;
} catch (Exception e) {
logger.log(LogService.LOG_ERROR,”writeItem ERROR on writing [“+itemFullName+”] as [“+value+”] : ” + LogUtils.getMessageAndStackTrace(e));
}
boolean status = client.writeAttribute(nodeId, Attributes.Value,convertedValue);
if(!status)
logger.log(LogService.LOG_WARNING, “Item “+itemFullName+” written ASYNCROUSLY @ “+value);
}

I register the item using this procedure (my test item is member of an OPC Group, and i register all the variables of this group):

// get the reference to MB.LW_MONITOR group
ReferenceDescription found=util.getGroupReference(groupName);
List itemList = this.client.getAddressSpace().browse(client.getNamespaceTable().toNodeId(found.getNodeId()));
// create a subscription instance for entire group
Subscription subscription =new Subscription();
for(ReferenceDescription rd:itemList){
NodeId nd=client.getNamespaceTable().toNodeId(rd.getNodeId());
MonitoredDataItem mi=new MonitoredDataItem(nd, Attributes.Value, MonitoringMode.Reporting);
mi.addChangeListener(cacheListener); // cacheListener is my MonitoredDataItemListener instance…
subscription.addItem(mi);
}
// add subscription to the client
client.addSubscription(subscription);

thanks

September 25, 2013
18:34, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

I suggest you first use jvisualvm or jconsole, which are both available in the JDK bin folder, to monitor memory usage. It gives much better picture of the actual memory usage than the Windows Task Manager.

September 26, 2013
13:19, EEST
Avatar
d.zinato
Member
Members
Forum Posts: 9
Member Since:
September 25, 2013
sp_UserOfflineSmall Offline

Hi Jouni,

thank you for your response.
I yet tried JVisualVM, and i didn’t find the same behaviour.
The heap memory is always under control (but I saw a lot of thread, also 50-60, all named Blocking-Work-Executorxxx and this kind of thread lives for 10 seconds, and then dies….is it normal?)

I’d like run my test program for at least 1 day, or 1 week, to see the real memory behaviour…..is it possible? Can i have a license for at least 24-hour run?

thank you

September 26, 2013
14:26, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, the stack uses a thread pool for sending the service requests to the server, so the thread behavior is normal.

Please, send an email to our support and we will see what we can do for you.

September 27, 2013
15:50, EEST
Avatar
d.zinato
Member
Members
Forum Posts: 9
Member Since:
September 25, 2013
sp_UserOfflineSmall Offline

Can you give me the right email address?
I only have this : sales@prosysopc.com
thanks

September 27, 2013
20:12, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

uajava-support at prosysopc dot com

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 735

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1523

Posts: 6449

Newest Members:

rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1