Memory leak in generation DDS network #4474
-
I am working on a project to create a DDS network automatically by creating a wrapping code in API for each DDS vendor and reading files containing the information of the DDS network. I made a wrapping code using API in Open dds, but I uploaded a question because I think I am doing the wrong allocation and free of memory. Please let me know if there is any information that can help me with debugging. Here are a network file defined by me and And I attached my project PoC.zip. Please make a domain.txt
PoC.cpp
The following is the disconstructor for each wrapping code: NodeDomain.cpp
NodeParticipant.cpp
NodePublisher.cpp
NodeSubscriber.cpp
NodeDatareader.cpp
NodeDatawriter.cpp
Disconstructors free memory one after another, calling from I think it's because of the difference and characteristics between As a side note, can't Thank you for reading the long text. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That sounds very similar to bench, specifically the builder library that's part of bench, though bench only currently works with OpenDDS. @simpsont-oci may be able to speak on how easy it would be to have it use other DDS vendors. Regardless of that, it would probably serve as a good reference.
This is part of the CORBA memory management. It's reference counted like The members that are currently raw pointers should definitely be class NodeDatawriter{
public:
Publisher_var publisher_;
DataWriter_var datawriter_; For the constructor arguments, I would either make them raw pointers that require a NodeDatawriter::NodeDatawriter(Publisher* pub, Topic* topic, DataWriterQos dw_qos, std::string id){
id_ = id;
publisher_ = Publisher::_duplicate(pub);
listener_.id_ = id; or a
(This is what bench builder does) If you want a details on how CORBA memory management actually works, this page looks like it provides a decent explaination. There's also the IDL-to-C++ section on interface mapping.
This is for a similar reason as the DataReaders, etc. The pointer needs the std::string type_name;
{
CORBA::String_var type_name_sv = ts->get_type_name();
type_name = type_name_sv.in();
} If you have C++17, you could avoid the copy and use At some point in the future all of this will modernized as part of "Remove dependency on TAO" in the roadmap, but we have other tasks to do before that. |
Beta Was this translation helpful? Give feedback.
That sounds very similar to bench, specifically the builder library that's part of bench, though bench only currently works with OpenDDS. @simpsont-oci may be able to speak on how easy it would be to have it use other DDS vendors. Regardless of that, it would probably serve as a good reference.
This is part of the CORBA memory management. It's reference counted like
std::shared_ptr
, but unfortunately it requires much more c…