Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

memory leak ?? #43

Open
GoogleCodeExporter opened this issue Mar 17, 2015 · 11 comments
Open

memory leak ?? #43

GoogleCodeExporter opened this issue Mar 17, 2015 · 11 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. see code below

What is the expected output? What do you see instead?
memory consumption increasing !! 

What version of the product are you using? On what operating system?
last one checkout done for here and also on 2.5.3

Please provide any additional information below.

(see valgrind output below)

[source lang="cpp"]
#include <ticpp.h>
#include <ostream>

using namespace std;

int main() {
    ticpp::Document   xml;
    string topName;

    ticpp::Node * _top;

    xml.LoadFile("test.xml");
    _top    = xml.FirstChild(false); // throwIfNoChildren=false
    topName = ((ticpp::Element*)_top)->GetAttribute("atom");

    cout << topName << endl;

    while (1) {
        ticpp::Element * pElem = _top->FirstChildElement();
        cout << pElem << endl;
    };
}


test.xml:
[source lang="cpp"]
<params atom="unit_2ddfba91" name="top">
        <atom name="base_22475976">
                <step value="0">
                        <param name="enRead" type="Boolean" value="True"/>
                        <param name="enWrite" type="Boolean" value="True"/>
                </step>
        </atom>
        <atom name="base_22111976">
                <step value="0">
                        <param name="enRead" type="Boolean" value="False"/>
                        <param name="enWrite" type="Boolean" value="True"/>
                </step>
        </atom>
</params>



[/source]

valgrind output:
valgrind --log-file=val --leak-resolution=high --leak-check=full
--show-reachable=yes test.out

...
==28684== 624 bytes in 12 blocks are still reachable in loss record 38 of 40
==28684==    at 0x4004790: operator new(unsigned) (vg_replace_malloc.c:164)
==28684==    by 0x80665A5: TiXmlElement::Parse(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x806623D: TiXmlElement::ReadValue(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x806670D: TiXmlElement::Parse(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x806623D: TiXmlElement::ReadValue(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x806670D: TiXmlElement::Parse(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x806623D: TiXmlElement::ReadValue(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x806670D: TiXmlElement::Parse(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x8066B6A: TiXmlDocument::Parse(char const*,
TiXmlParsingData*, TiXmlEncoding) (in test.out)
==28684==    by 0x8063333: TiXmlDocument::LoadFile(_IO_FILE*,
TiXmlEncoding) (in test.out)
==28684==    by 0x80634E9: TiXmlDocument::LoadFile(char const*,
TiXmlEncoding) (in test.out)
==28684==    by 0x804DFB4: ticpp::Document::LoadFile(char const*,
TiXmlEncoding) (in test.out)
==28684==
==28684==
==28684== 8,388,608 bytes in 1 blocks are still reachable in loss record 39
of 40
==28684==    at 0x4004790: operator new(unsigned) (vg_replace_malloc.c:164)
==28684==    by 0x805C5BB: std::vector<ticpp::Base*,
std::allocator<ticpp::Base*>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<ticpp::Base**,
std::vector<ticpp::Base*, std::allocator<ticpp::Base*> > >, ticpp::Base*
const&) (in test.out)
==28684==    by 0x8054304: ticpp::Node::FirstChildElement(char const*,
bool) const (in test.out)
==28684==    by 0x805443E: ticpp::Node::FirstChildElement(bool) const (in
test.out)
==28684==    by 0x804AD95: main (params.cc:97)
==28684==
==28684==
==28684== 12,748,332 bytes in 1,062,361 blocks are still reachable in loss
record 40 of 40
==28684==    at 0x4004790: operator new(unsigned) (vg_replace_malloc.c:164)
==28684==    by 0x8053EC5: ticpp::Node::FirstChildElement(char const*,
bool) const (in test.out)
==28684==    by 0x805443E: ticpp::Node::FirstChildElement(bool) const (in
test.out)
==28684==    by 0x804AD95: main (params.cc:97)


Original issue reported on code.google.com by [email protected] on 25 Mar 2009 at 11:57

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant