We have a serious problem. We wrote a program that accepts data from 200 devices using the ModBus protocol. The data from these devices come with a high frequency and represent a telegram that is parsed on the server side, the data received are recorded in Raima. The problem is that we are experiencing memory overflows. Help please understand the problem.
Code: Select all
#uses "CtrlADO"
main() {
while(1) {
blob s;
dyn_string path_to_section, path_to_pos_in_section, signal_name;
dyn_blob First_stack_value;
string dpName, dpName_for_para, Descr, normal_data = "";
dyn_int bit_number;
uint id_skv, type_tel, number_tel, datasets_cont, reg_cont, ts_min, ts_sec, status_c, analog_c, name_reg, val_reg, val_reg1, val_reg2, hours, mins, secs, msec, Sig_int=0, Exp_int=0, Man_int=0;
int g=0, reg_pos=16, discret_value;
float analog_value = 0;
int rc;
dbConnection conn;
dbCommand cmd;
dbRecordset rs;
dyn_anytype sql_result;
time t;
dpGet("System1:Settings.Buffer.Stack:_original.0._value", First_stack_value);
if(dynlen(First_stack_value)>0){
s = First_stack_value[dynlen(First_stack_value)];
blobGetValue(s, 0, id_skv ,2 ,TRUE);
blobGetValue(s, 2, type_tel ,2 ,TRUE);
blobGetValue(s, 4, number_tel ,2 ,TRUE);
blobGetValue(s, 6, datasets_cont ,1 ,TRUE); // it's used
blobGetValue(s, 7, reg_cont ,1 ,TRUE);
blobGetValue(s, 8, ts_min ,2 ,TRUE);
blobGetValue(s, 10, ts_sec ,2 ,TRUE);
blobGetValue(s, 12, status_c ,1 ,TRUE);
blobGetValue(s, 14, analog_c ,2 ,TRUE);
// 14 15 - zero
// 000A - 16
// 3100 - 18
// ~16 - id, 17 - value
//DebugN(status_c, "-------", analog_c);
if(type_tel != 1049) {
hours = ts_min / 60;
mins = ts_min - hours*60;
secs = ts_sec / 1000;
msec = ts_sec - secs*1000;
t=getCurrentTime();
sprintf(normal_data,"%02d:%02d:%02d:%03d",hours,mins,secs,msec);
normal_data = formatTime("%Y-%m-%d", t) + " " + normal_data;
while(g