Memleak while writing xml file
- From: Hugo van den Brand <h vd brand gmail com>
- To: libxmlplusplus-list gnome org
- Subject: Memleak while writing xml file
- Date: Sun, 5 Feb 2012 13:39:16 +0100
L.S.
I'm using the libxml++-2.6 wrapper in a C++ program that runs a simulation (include with gtkmm-2.4)
At the start of every simulation I write the settings to an xml file.
However, while doing this I noticed that every time I run a new Simulation additional memory is required (about 404 kb).
I use the following code and I wonder if I'm missing something:
short SimulationWriter::write_xmlfile(string i_filename)
{
{ // Check whether the file can be opened.
fstream fin;
fin.open(i_filename.c_str(),ios::out);
bool not_opened=!(fin.is_open());
fin.close();
if (not_opened)
return 1;; // Failure opening the file for writing.
}
xmlpp::Document xmldoc;
// Add the root node
xmlpp::Element* pe_root=xmldoc.create_root_node("simulation");
// Add all members to the simulation node
add_simulation_members(pe_root);
// Write the file
xmldoc.write_to_file_formatted(i_filename,"ISO-8859-1");
}
When I comment from xmlpp::Document ... to the end I don't experience the memory leak.
Am I missing some clean-up code or is there something else happening?
Any help would be really appreciated.
Best wishes,
Hugo van den Brand
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]