Overview
Features
Download
Documentation
Community
Add-Ons & Services

Memory leaks in windows. (in DOMParser and URIStreamOpener)

A general discussion forum.

Memory leaks in windows. (in DOMParser and URIStreamOpener)

Postby abhayr » 26 Jul 2011, 10:06

Hi,

I contacted the support for the leaks found using VLD and one other leak detector, below are the details:

They said there are no memory leaks and if VLD detect it may be of static objects. As far as static (e.g. singelton) are concerns I don't bother about leaks but actually there are leaks of non-static objects because:

- Every time we call parser.parse() and URIStreamOpener::defaultOpener().open(uri1); the memory gets increased and which never fall down. The leak detector detects these leaks multiple time which confirms that these are not static object leaks.

Can anybody aware of these links and/or solution to overcome.

-Abhay

---------------------------------------------------------------------------------------------------------------
On Mon, Jul 25, 2011 at 6:21 PM, Applied Informatics Support <support@appinf.com> wrote:
Hi,

this is very probably a false positive reported by VLD. POCO uses a few static objects that allocate memory on the heap. The way VLD works it can happen that VLD reports false memory leaks for these static objects. This is because the destructors of these objects are called after VLD runs the leak report.

To our knowledge there are no memory leaks in POCO.

----------------------------------------------------------------------------------------------------------------

> On Tue, Jul 19, 2011 at 2:55 PM, Abhay Raghuwanshi <abhay.raghuwanshi@globallogic.com> wrote:
> Hi Support Team,
>
> Thanks for the reply.
>
> I am agree that one should either use auto_ptr or delete the object returned. we actually tried all the three ways (std:auto_ptr, Poco::SharedPtr and explicitly deletion of object), but we still gets the same leaks.
>
> Please see here is a simple snippet, where we are explicitly deleting the object but still we are getting leaks, Please see the attached file mleaks.txt for leak information and call stack.
>
> SRC Snippet:
> ---------------------------------------------------------
>
> #include "Poco/URI.h"
> #include <iostream>
> #include "Poco/URIStreamOpener.h"
> #include "Poco/Net/HTTPStreamFactory.h"
> #include "vld.h"
>
> using Poco::URI;
>
> using Poco::URIStreamOpener;
> using Poco::Net::HTTPStreamFactory;
>
> int main(int argc, char** argv)
> {
> URI uri1("http://lh5.ggpht.com/-YXt3q7zVDcY/Tdzh_Cxx7kE/AAAAAAAAApU/py7rlvVZ26I/s160-c/May25201104.jpg?imgmax=1600");
>
> HTTPStreamFactory::registerFactory();
>
> std::istream* pStr=URIStreamOpener::defaultOpener().open(uri1);
> delete pStr;
>
> return 0;
> }
>
>
> Can you please suggest if there any thing needs to be done something specific in Poco library before start using it's API or else?
>
>
> - Abhay
>
--------------------------------------------------------------------------------------------------------------

> On Tue, Jul 5, 2011 at 1:15 AM, Applied Informatics Support <support@appinf.com> wrote:
> Hi Abhay,
>
> URIStreamOpener::open() returns a pointer to a stream object and that object must be explicitely deleted when no longer needed.
> I'd suggest assigning the result of URIStreamOpener::open() to an std::auto_ptr or a Poco::SharedPtr to avoid leaks.
>
> Poco::SharedPtr<std::istream> pStr = URIStreamOpener::defaultOpener().open(uri1);
>
> should fix your memory leaks.
>
> The memory leaks reported for parser.parse() are probably related to the first one, as I'm not aware of any memory leaks in the XML parser.
>
> Best regards,
>
> --
> Support Team
> Applied Informatics Software Engineering GmbH
> A-9182 Maria Elend | Maria Elend 96/4 | www.appinf.com
> P: +43 4253 32596 M: +43 676 5166737 F: +43 4253 32096
>
> Company Registration: FN 276491 f | Landesgericht Klagenfurt
> Managing Director: DI Günter Obiltschnig
>
>
>
---------------------------------------------------------------------------------------------------
Original post by abhay:

> > Hi,
> >
> > We are using poco-1.4.1p1 on windows and facing memory leaks.
> >
> > We are deleting all the objects returned from Poco Lib, but still the memory is not reaching back to initial level.
> >
> > We used VLD to detect leak and found 2 places where leak is getting generated:
> >
> >
> > a. pStr=URIStreamOpener::defaultOpener().open(uri1); //<The uri1 is an HTTP uri.>//This line initiating several leaks.
> >
> > b.
> > InputSource src(responseStream);
> > //The responseStream is one returned from HTTPClientSession.receiveResponse
> >
> > DOMParser parser;
> >
> > AutoPtr<Document> pDoc = parser.parse(&src);//This line initiating several leaks.
> >
> > Can you please let us know if we are not following any standard steps and/or these are leaks in Poco lib which have been fixed in any later releases?
> >
> >
> > --
> > Abhay Raghuwanshi
> > Globallogic Inc.
----------------------------------------------------------------------------------------------------------------
abhayr
 
Posts: 2
Joined: 26 Jul 2011, 09:09

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest