delphi - What is the correct way to free embed object in TOmniMessage? -
i have tasks sending various messages data.
for example:
task.comm.send(msg_job_error,[string, string,string,string,string, tobject]) ;
on receiving side have
procedure tudpbroadcast.onworkerjoberror(var msg: tomnimessage); var s : string ; begin try s := 'task: ' + msg.msgdata.asarrayitem[0].asstring + ', ip: ' + msg.msgdata.asarrayitem[1].asstring + ', port: ' + msg.msgdata.asarrayitem[2].asstring + ', data: ' + msg.msgdata.asarrayitem[3].asstring + ', reply: '+ msg.msgdata.asarrayitem[4].asstring ; xlog('job error > ' + s, 'udpbroadcast') ; processworkobject(msg.msgdata.asarrayitem[4].asobject) ; msg.msgdata.clear ; end; end;
but don't feel msgdata.clear correctly unallocate memory.
what correct handling of tomnivalue deallocation?
msg.msgdata tomnivalue. in recent versions of omnithreadlibrary, tomnivalue can own object setting tomnivalue.ownsobject:=true, , has other helper methods facilitate functionality. if ownsobject true, object freed when tomnivalue freed, not have worry memory management longer.
Comments
Post a Comment