deprecate shared pointer to parent link to fix memory leak
This commit is contained in:
parent
379c125184
commit
807338a5a0
|
@ -30,6 +30,10 @@ rosbuild_add_boost_directories()
|
||||||
rosbuild_add_executable(urdf_check src/urdf_check.cpp)
|
rosbuild_add_executable(urdf_check src/urdf_check.cpp)
|
||||||
target_link_libraries(urdf_check ${PROJECT_NAME})
|
target_link_libraries(urdf_check ${PROJECT_NAME})
|
||||||
|
|
||||||
|
rosbuild_add_executable(mem_test test/memtest.cpp)
|
||||||
|
target_link_libraries(mem_test ${PROJECT_NAME})
|
||||||
|
|
||||||
|
|
||||||
rosbuild_add_executable(test_parser EXCLUDE_FROM_ALL test/test_robot_model_parser.cpp)
|
rosbuild_add_executable(test_parser EXCLUDE_FROM_ALL test/test_robot_model_parser.cpp)
|
||||||
rosbuild_add_gtest_build_flags(test_parser)
|
rosbuild_add_gtest_build_flags(test_parser)
|
||||||
target_link_libraries(test_parser ${PROJECT_NAME})
|
target_link_libraries(test_parser ${PROJECT_NAME})
|
||||||
|
|
|
@ -206,12 +206,16 @@ public:
|
||||||
/// every link can have one parent
|
/// every link can have one parent
|
||||||
boost::shared_ptr<Joint> parent_joint;
|
boost::shared_ptr<Joint> parent_joint;
|
||||||
/// Get Parent Link throught the Parent Joint
|
/// Get Parent Link throught the Parent Joint
|
||||||
boost::shared_ptr<Link> parent_link;
|
boost::shared_ptr<Link> parent_link __attribute__((deprecated)); // use getParent() instead
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<Joint> > child_joints;
|
std::vector<boost::shared_ptr<Joint> > child_joints;
|
||||||
std::vector<boost::shared_ptr<Link> > child_links;
|
std::vector<boost::shared_ptr<Link> > child_links;
|
||||||
|
|
||||||
bool initXml(TiXmlElement* config);
|
bool initXml(TiXmlElement* config);
|
||||||
|
|
||||||
|
boost::shared_ptr<Link> getParent() const
|
||||||
|
{return parent_link_.lock();};
|
||||||
|
|
||||||
void setParent(boost::shared_ptr<Link> parent);
|
void setParent(boost::shared_ptr<Link> parent);
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
|
@ -228,6 +232,10 @@ public:
|
||||||
void setParentJoint(boost::shared_ptr<Joint> child);
|
void setParentJoint(boost::shared_ptr<Joint> child);
|
||||||
void addChild(boost::shared_ptr<Link> child);
|
void addChild(boost::shared_ptr<Link> child);
|
||||||
void addChildJoint(boost::shared_ptr<Joint> child);
|
void addChildJoint(boost::shared_ptr<Joint> child);
|
||||||
|
|
||||||
|
private:
|
||||||
|
boost::weak_ptr<Link> parent_link_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -407,6 +407,7 @@ bool Link::initXml(TiXmlElement* config)
|
||||||
void Link::setParent(boost::shared_ptr<Link> parent)
|
void Link::setParent(boost::shared_ptr<Link> parent)
|
||||||
{
|
{
|
||||||
this->parent_link = parent;
|
this->parent_link = parent;
|
||||||
|
this->parent_link_ = parent;
|
||||||
ROS_DEBUG("set parent Link '%s' for Link '%s'", parent->name.c_str(), this->name.c_str());
|
ROS_DEBUG("set parent Link '%s' for Link '%s'", parent->name.c_str(), this->name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include <urdf/model.h>
|
||||||
|
#include <ros/ros.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv){
|
||||||
|
ros::init(argc, argv, "memtest");
|
||||||
|
while (ros::ok()){
|
||||||
|
urdf::Model urdf;
|
||||||
|
urdf.initFile(std::string(argv[1]));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue