Memory leak while using CORBA
|
|
---|---|
Hi all, We have a device server having TIME (Tango::DevString) attribute to which system time is written at every 1 sec. Here is the syntax we are using to write value to it. Initialized with NULL pointer inside init_device().
Value assigned inside TangoTimeDS::read_TIME(Tango::Attribute &attr)
Device server is working fine but memory keeps increasing slowly. valgrind shows above commented line to cause memory leakage. I am not getting what is going wrong. Would anyone please provide suggestion/solution to get leak stop increasing? Thanks and Regards, TCS-GMRT
Regards,
TCS_GMRT |
|
|
---|---|
I suggest to use CORBA::string_free() instead of free() since this is what should be used when you want to free memory allocated with CORBA::string_dup(). By the way, I would also suggest to use Tango::string_dup() instead of CORBA::string_dup() which does currently invoke CORBA::string_dup() under the hood. This will make your code compatible with future versions of Tango which will be able to use a communication layer based on something different than CORBA. You can try to use Tango::string_free() too but I think this one was introduced recently so it might not be available in the Tango version you are using.
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new. |
|
|
---|---|
Hi Reynald, Thanks for your prompt response. I have already tried both way to free memory (free() and CORBA::string_free()). But both doesn't work. Even I tried using Tango::string_dup() (which internally uses CORBA::string_dup() ) but that doesn't work too. Is there any alternative way to assign value to Tango::DevString without using CORBA::string_dup()? Thanks & Regards, TCS-GMRT
Regards,
TCS_GMRT |
|
|
---|---|
Do you free this memory in your delete_device() method too? If yes, can you please post the valgrind report and your code?
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new. |
|
|
---|---|
> Is there any alternative way to assign value to Tango::DevString without using CORBA::string_dup()? I would say "no" since the omniORB implementation of the CORBA API works smoothly for years. BTW, valgring is sometimes wrong… |
|
|
---|---|
Hello, May be this HowTo page could help Good luck Emmanuel |