pombreda / libkml

Automatically exported from code.google.com/p/libkml
Other
0 stars 0 forks source link

Memory leaks on kmldom::Parse() in libkml-1.2.0 #154

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a simple dialog based MFC application (tested with VS2005 C++)and 
configure the project to include libkml-1.2.0.
2. Paste the following code to OnInitDialog():

BOOL CTestDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);         // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon

    std::string errors;
  kmldom::ElementPtr element = kmldom::Parse(
    "<kml>"
      "<Placemark>"
        "<name>hi</name>"
        "<Point>"
          "<coordinates>1,2,3</coordinates>"
        "</Point>"
      "</Placemark>"
    "</kml>",
    &errors);

  // Convert the type of the root element of the parse.
  const kmldom::KmlPtr kml = kmldom::AsKml(element);
  const kmldom::PlacemarkPtr placemark = kmldom::AsPlacemark(kml->get_feature());

    return TRUE;  // return TRUE  unless you set the focus to a control
}

This code is based on first example from here: 
http://code.google.com/p/libkml/wiki/QuickStart

3. Compile and run.

What is the expected output? What do you see instead?
No memory leaks expected but I can see a lot of memory leaks of 52 and 32 bytes 
long detected. AQtime allocation profiler points to kmldom::Parse() call as to 
the cause of memory leaks.

Please use labels and text to provide additional information.
VS2005 project is attached...

Original issue reported on code.google.com by nebulus...@gmail.com on 13 Jul 2010 at 1:00

Attachments:

GoogleCodeExporter commented 9 years ago
I suspect this is a duplicate of 
http://code.google.com/p/libkml/issues/detail?id=43

What you're seeing is our singleton usage. kmldom::Xsd and kmldom::KmlFactory 
are allocated, but never freed until your program shuts down.

Original comment by kml.mash...@gmail.com on 17 Aug 2010 at 7:18