Sorry for the duplicate. I hit a weird set of key strokes and the email
was sent.
I have a class which is containing a shared_ptr to data. This class
parses in a XML file and populates the data based upon the contents.
There is a memory problem in this file where I reset the shared_ptr.
Am I right in interpreting the output of valgrind that the problem is at
Line 110 in Formula_Parser.cpp or is it somewhere else? I thought it was
in Formula_Parser.cpp so I printed out here what is happening in the
function. I am trying to create a Graph pointer where data will be added
to it when the XML parser calls back endElement. So I cannot pass the
pointer to the graph as a part of the XML calls without editing that
library. So I made it a member variable to the class. The idea is that
the Graph is populated with Components and then returned at the end of
parse(). Am I correctly resetting m_graph?
Stephen
----------------
class Graph;
class Parser {
public:
boost::shared_ptr<Graph>
parse ( std::string filename,
std::string directory )
{
// Line 110 Formula_Parser.cpp
m_graph.reset ( new Graph() );
... parse file ...
return m_graph;
}
void endElement ( ... )
{
// Add item to m_graph
m_graph.add ( new Component );
}
private
boost::shared_ptr<Graph> m_graph;
};
==28769== Uninitialised byte(s) found during client check request
==28769== at 0x4161127: libreverse::api::Reverse_Impl::print_Graph(libreverse::infrastructure::Component_Graph const&, std::string) const (Reverse_Impl.cpp:183)
==28769== by 0x4161D96: libreverse::api::Reverse_Impl::execute_Input_Section(boost::shared_ptrlibreverse::infrastructure::Component_Graph, std::lessstd::string, std::allocatorlibreverse::infrastructure::Component_Graph > > > > const&, boost::shared_ptr, boost::shared_ptrlibreverse::infrastructure::Component) (Reverse_Impl.cpp:45)
==28769== by 0x4154024: libreverse::api::Reverse::execute(std::string const&, unsigned const&, unsigned const&) (Reverse.cpp:128)
==28769== by 0x8055869: main (reverse.cpp:50)
==28769== Address 0x4389BC0 is 8 bytes inside a block of size 60 alloc'd
==28769== at 0x4005BA5: operator new(unsigned) (vg_replace_malloc.c:163)
==28769== by 0x41968E1: libreverse::infrastructure::Formula_Parser::get_Graph(std::string, std::string) (Formula_Parser.cpp:110)
==28769== by 0x419351E: libreverse::infrastructure::Configurator::get_Graph(unsigned, unsigned) (Configurator.cpp:110)
==28769== by 0x4153FBC: libreverse::api::Reverse::execute(std::string const&, unsigned const&, unsigned const&) (Reverse.cpp:115)
==28769== by 0x8055869: main (reverse.cpp:50)
==28769==
==28769== Uninitialised byte(s) found during client check request
==28769== at 0x4161176: libreverse::api::Reverse_Impl::print_Graph(libreverse::infrastructure::Component_Graph const&, std::string) const (Reverse_Impl.cpp:184)
==28769== by 0x4161D96: libreverse::api::Reverse_Impl::execute_Input_Section(boost::shared_ptrlibreverse::infrastructure::Component_Graph, std::lessstd::string, std::allocatorlibreverse::infrastructure::Component_Graph > > > > const&, boost::shared_ptr, boost::shared_ptrlibreverse::infrastructure::Component) (Reverse_Impl.cpp:45)
==28769== by 0x4154024: libreverse::api::Reverse::execute(std::string const&, unsigned const&, unsigned const&) (Reverse.cpp:128)
==28769== by 0x8055869: main (reverse.cpp:50)
==28769== Address 0xBE9D82CC is on thread 1's stack