Memory management responsibilities
|
|
---|---|
Hi, I've read 235ff (8.2.3 C++ memory management) in the tango manual. But the explanations there don't match my questions. I have a device server and client in C++. The manual states Fortunately, for incoming data, the method have no memory management responsibilities. Server: Does that mean that in the device server I never have to deallocate memory inside command or attribute handling functions? Client: Lets say I write to an attribute using . Who owns, and thus must free, the memory in the DeviceData object? Does that depend on wether write_attribute throws an exception or not?What about the return value of ?I'm also glad for every relevant RTFM link :) |
|
|
---|---|
Hi, the manual is correct. The DeviceData memory management is handled by the tango library i.e. any incoming data memory is allocated and freed by the library. It is logical if you consider the library is the first to receive the data from the network and to allocate memory in order to unpack it. It is independent of whether the method implementing the attribute throws an exception. Of course if your code allocates memory to make a copy of the data then it is your responsibility to free the memory. For outgoing data you need to allocate and free the memory as explained in the section of the manual you cited. I don' t know if more documentation exists e.g. how to or whatever. Ask if you still have questions! Andy |
|
|
---|---|
Hi, Some more doc about memory management for DeviceData and DeviceAttribute classes is available in Tango book chapter 6.2 (DeviceData) and 6.4 (DeviceAttribute). Regards Emmanuel |
|
|
---|---|
Thanks Andy and Emmanuael for the explanations. |