MATLAB OPC Package Memory Usage - Error

I am building a Python package in MATLAB for read/write through an OPC connection. For some reason, each time a read or write command is executed, the memory usage of MATLAB increases by about 1 MB or more. Eventually, the memory consumption will be too high and the application will crash. I am trying to delete as much variables as possible in MATLAB, but it is still not working. Please see below for the "write" code, the read code is similar:
DAobj = opcda(server_host_name, server_name);
connect(DAobj);
write_group = addgroup(DAobj,'Write_group');
add_item = additem(write_group, cellstr(items), data_type);
write(write_group, val);
obj.msg = 'Write Successful';
obj.val = val;
cleareventlog(DAobj)
clear write_group
disconnect(DAobj);
opcreset;
clear DAobj add_item val server_host_name server_name val items data_type action
clearvars -global

Answers (0)

Asked:

on 7 Nov 2020

Edited:

on 7 Nov 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!