[xsd-users] Memory leak - DbXml 2.2

Boris Kolpackov boris at codesynthesis.com
Thu Apr 13 17:13:14 EDT 2006


Good day,

Ravi Sakaria from VoicePulse Inc. was trying to use XSD-generated code
together with Berkeley DB XML and ran across some mysterious memory leaks.
He managed to track the problem down (with help from Sleepycat/Oracle
folks) and was kind enough to let me know about this. In turn, I am
forwarding this information to the xsd-users mailing list.


hth,
-boris


From: Ravi Sakaria <ravi.sakaria at voicepulse.com>
Subject: RE: FW: [bdbxml]  Memory leak - DbXml 2.2
Date: Fri, 7 Apr 2006 16:00:55 -0400
To: Boris Kolpackov <boris at codesynthesis.com>

Thanks for the suggestion and insight Boris.

I was able to work around the issue in my particular application by
causing my Berkeley Dbxml adapter to go out of scope before
instantiating one of the autogenerated classes.  So instead of:

* Instantiate Berkeley handles
* Use Berkeley handle to get XML string from storage
* Use XML string to instantiate class
* Destroy Berkeley handles

I simply do:

* Instantiate Berkeley handles
* Use Berkeley handle to get XML string
* Destroy Berkeley handle
* Use string to instantiate class

The problem only seems to occur if there is an existing instance of the
Berkeley XmlManager class.

(I hope someday this saves you or someone else from banging their head
against a wall like I did!)

Regards,
Ravi


From: Boris Kolpackov <boris at codesynthesis.com>
Subject: Re: FW: [bdbxml]  Memory leak - DbXml 2.2
Date: Fri, 7 Apr 2006 21:44:52 +0200
To: Ravi Sakaria <ravi.sakaria at voicepulse.com>

Hi Ravi,

Thanks for letting me know about this issue. As George said, it
appears that DbXml "takes over" Xerces-C++ memory management in
a way that prevents other applications from using Xerces-C++
functionality.

One thing that you can do is to move Xerces-related memory management
from the XSD runtime to your application and do it in a way that is
compatible with DbXml. To achieve this, you will need to create and
release DOMDocument in your application rather than delegating this
task to the XSD runtime. E.g., instead of

auto_ptr < hello_type > h (hello (argv[1]));

you will do

xercesc::DOMDocument* dom = ... // See Xerces examples on how to
                                // parse instance into a DOM Doc.

auto_ptr < hello_type > h (hello (*dom));

// Normally after that you would call dom->release () but you
// will need to do something else here.

hth,
-boris


From: Ravi Sakaria <ravi.sakaria at voicepulse.com>
Subject: FW: [bdbxml]  Memory leak - DbXml 2.2
Date: Fri, 7 Apr 2006 13:31:57 -0400
To: info at codesynthesis.com

Boris,

I thought you might find the following email conversation I had with
George Feinberg at Sleepycat / Oracle interesting.  We're trying to use
their Dbxml along with classes that were autogenerated with XSD and we
discovered the bug described below (it will make the most sense if you
start at the bottom).

Regards,
Ravi

> -----Original Message-----
> From: George Feinberg [mailto:george.feinberg at oracle.com]
> Sent: Friday, April 07, 2006 11:49 AM
> To: Ravi Sakaria
> Subject: Re: [bdbxml] Memory leak - DbXml 2.2
>
>
> Ravi,
>
> I see the issue.  It's a problem, but I'm not yet sure how to
> fix it/work around it.  I may assign this to John Snelson.  I've
> created an SR, and you'll hear back on it.
>
> The basic problem is that BDB XML takes over the Xerces-C
> default memory manager, which is inconsistent with the XSD
> library's use.
>
> Thanks for the test case.
>
> George
>
> > George,
> >
> > OK - here's an example.  The driver.cxx is an example provided with
> > XSD.
> > I've modified it to duplicate the memory leak I'm experiencing in
> > other
> > code by adding the Berkeley Dbxml "myDbxmlAdapter" class.  All of my
> > modifications are commented as such (just search for "Ravi").
> >
> > I'm not sure how familiar you are with CodeSynthesis' XSD tool, but
> > basically it took hello.xsd and autogenerated hello.cxx and hello.hxx.
> >
> > Please let me know if I can provide more data that might be
> > helpful.  I
> > could even arrange for you to SSH into the box that I have this on:
> >
> > 1.  g++ and kernel info
> > 2.  ldd output
> > 3.  compilation commands
> > 4.  source code
> > 5.  output without valgrind
> > 6.  output with valgrind
> >
> > ============= BEGN g++ and kernel info ============
> > [root at fcdev03 hello]# g++ -v
> > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs
> > Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> > --infodir=/usr/share/info --enable-shared --enable-threads=posix
> > --disable-checking --disable-libunwind-exceptions --with-system-zlib
> > --enable-__cxa_atexit --host=i386-redhat-linux
> > Thread model: posix
> > gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
> > [root at fcdev03 hello]# uname -a
> > Linux fcdev03.voicepulse.com 2.6.10-1.9_FC2 #1 Thu Jan 13 17:54:57 EST
> > 2005 i686 i686 i386 GNU/Linux
> > ============= END g++ and kernel info =============
> >
> > ============= BEGIN LDD OUTPUT ====================
> > [root at fcdev03 hello]# ldd ./driver
> >         libxerces-c.so.27 => /usr/lib/libxerces-c.so.27 (0x0374b000)
> >         libdb_cxx-4.4.so => /usr/lib/libdb_cxx-4.4.so (0x00607000)
> >         libdbxml-2.2.so => /usr/lib/libdbxml-2.2.so (0x0073a000)
> >         libxquery-1.2.so => /usr/lib/libxquery-1.2.so (0x00393000)
> >         libpathan.so.3 => /usr/lib/libpathan.so.3 (0x00a97000)
> >         libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x009da000)
> >         libm.so.6 => /lib/tls/libm.so.6 (0x00111000)
> >         libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00730000)
> >         libc.so.6 => /lib/tls/libc.so.6 (0x004d1000)
> >         libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00134000)
> >         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x004b8000)
> > ============= END LDD OUTPUT ======================
> >
> > ============= BEGIN COMPILATION COMMANDS ==========
> > modified:
> >         g++ -W -Wall -c driver.cxx -o driver.o
> >         g++ -W -Wall -o driver driver.o hello.o -lxerces-c -ldb_cxx
> > -ldbxml -lxquery -lpathan
> > ============= END COMPILATION COMMANDS ============
> >
> > ============= BEGIN TEST SOURCE CODE ===============
> > [root at fcdev03 hello]# cat driver.cxx
> > // file      : examples/cxx/tree/hello/driver.cxx
> > // author    : Boris Kolpackov <boris at codesynthesis.com>
> > // copyright : not copyrighted - public domain
> >
> > #include <memory>               // std::auto_ptr
> > #include <iostream>
> > #include <dbxml/DbXml.hpp>    //<--Ravi
> >
> > #include "hello.hxx"
> >
> > using
> >   std::cerr;
> > using
> >   std::endl;
> > using
> >   std::auto_ptr;
> >
> > //// Ravi - Begin
> > using namespace
> >   DbXml;
> >
> > class
> >   myDbxmlAdapter
> > {
> > public:
> >   myDbxmlAdapter (int x);
> >   ~
> >   myDbxmlAdapter ();
> > private:
> >   DbEnv *
> >     mpEnv;
> >   XmlManager *
> >     mpManager;
> >   XmlContainer *
> >     mpXmlContainer;
> >   XmlUpdateContext *
> >     mpUpdateContext;
> > };
> >
> > myDbxmlAdapter::myDbxmlAdapter (int x)
> > {
> >   std::cout << "Inside the constructor...\n";
> >   u_int32_t env_flags =
> >     DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
> > DB_INIT_TXN;
> >   mpEnv = new DbEnv (0);
> >   mpEnv->open ("/tmp/bdb_views", env_flags, 0);
> >   mpManager = new XmlManager (mpEnv);
> >   if (!mpManager->existsContainer ("/tmp/bdb_views/testcontainer"))
> >     {
> >       std::cout << "Container doesn't exist.\n";
> >       mpXmlContainer =
> >         new XmlContainer (mpManager->
> >                                  createContainer
> >                                  ("/tmp/bdb_views/testcontainer", 0,
> >                                   XmlContainer::NodeContainer, 0));
> >       mpUpdateContext =
> >         new XmlUpdateContext (mpManager->createUpdateContext ());
> >     }
> >   else
> >     {
> >       std::cout << "Container already exists.\n";
> >       mpXmlContainer =
> >         new XmlContainer (mpManager->
> >                          openContainer
> >                                  ("/tmp/bdb_views/testcontainer", 0));
> >       mpUpdateContext =
> >         new XmlUpdateContext (mpManager->createUpdateContext ());
> >     }
> > }
> >
> > myDbxmlAdapter::~myDbxmlAdapter ()
> > {
> >   std::cout << "Inside the destructor\n";
> >   delete mpUpdateContext;
> >   delete mpXmlContainer;
> >   delete mpManager;
> >   mpEnv->close (0);
> >   delete mpEnv;
> > }
> > ////////  Ravi - End
> >
> > int
> > main (int argc, char *argv[])
> > {
> >   if (argc != 2)
> >     {
> >       cerr << "usage: " << argv[0] << " hello.xml" << endl;
> >       return 1;
> >     }
> >
> > /// Following two lines added by Ravi
> >   std::cout << "About to construct...\n";
> >   myDbxmlAdapter myAdapter (5);  //<-- If this is commented out,
> > program
> > doesn't leak
> >
> >   try
> >   {
> >     auto_ptr < hello_type > h (hello (argv[1]));
> >
> >     for (hello_type::name::const_iterator i (h->name ().begin ());
> >          i != h->name ().end (); ++i)
> >       {
> >         cerr << h->greeting () << ", " << *i << "!" << endl;
> >       }
> >   }
> >   catch (xml_schema::exception const &e)
> >   {
> >     cerr << e << endl;
> >     return 1;
> >   }
> > }
> > ============= END TEST SOURCE CODE =================
> >
> > ============= OUTPUT WITHOUT VALGRIND ==============
> > [root at fcdev03 hello]# ./driver hello.xml
> > About to construct...
> > Inside the constructor...
> > Container already exists.
> > Hello, sun!
> > Hello, moon!
> > Hello, world!
> > Inside the destructor
> > ============= END OUTPUT WITHOUT VALGRIND ==========
> >
> > ============= BEGIN VALGRIND OUTPUT ================
> > [root at fcdev03 hello]# valgrind --leak-check=full -v ./driver hello.xml
> > ==13076== Memcheck, a memory error detector.
> > ==13076== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et
> > al.
> > ==13076== Using LibVEX rev 1575, a library for dynamic binary
> > translation.
> > ==13076== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
> > ==13076== Using valgrind-3.1.1, a dynamic binary instrumentation
> > framework.
> > ==13076== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et
> > al.
> > ==13076==
> > --13076-- Command line
> > --13076--    ./driver
> > --13076--    hello.xml
> > --13076-- Startup, with flags:
> > --13076--    --leak-check=full
> > --13076--    -v
> > --13076-- Contents of /proc/version:
> > --13076--   Linux version 2.6.10-1.9_FC2
> > (bhcompile at porky.build.redhat.com) (gcc version 3.3.3 20040412 (Red
> > Hat
> > Linux 3.3.3-7)) #1 Thu Jan 13 17:54:57 EST 2005
> > --13076-- Arch and subarch: X86, x86-sse2
> > --13076-- Valgrind library directory: /usr/local/lib/valgrind
> > --13076-- Reading syms from /lib/ld-2.3.3.so (0x4B8000)
> > --13076-- Reading syms from /usr/doc/xsd/examples/cxx/tree/hello/
> > driver
> > (0x8048000)
> > --13076-- Reading syms from /usr/local/lib/valgrind/x86-linux/memcheck
> > (0xB0000000)
> > --13076--    object doesn't have a dynamic symbol table
> > --13076-- Reading suppressions file:
> > /usr/local/lib/valgrind/default.supp
> > --13076-- REDIR: 0x4C9420 (index) redirected to 0xB001AF3E
> > (vgPlain_x86_linux_REDIR_FOR_index)
> > --13076-- Reading syms from
> > /usr/local/lib/valgrind/x86-linux/vgpreload_core.so (0x4000000)
> > --13076-- Reading syms from
> > /usr/local/lib/valgrind/x86-linux/vgpreload_memcheck.so (0x4003000)
> > --13076-- REDIR: 0x4C95C0 (strlen) redirected to 0x4005F8C (strlen)
> > --13076-- Reading syms from /usr/lib/libxerces-c.so.27.0 (0x374B000)
> > --13076-- Reading syms from /usr/lib/libdb_cxx-4.4.so (0x402B000)
> > --13076-- Reading syms from /usr/lib/libdbxml-2.2.so (0x73A000)
> > --13076-- Reading syms from /usr/lib/libxquery-1.2.so (0x393000)
> > --13076-- Reading syms from /usr/lib/libpathan.so.3.0.1 (0xA97000)
> > --13076-- Reading syms from /usr/lib/libstdc++.so.5.0.5 (0x9DA000)
> > --13076--    object doesn't have a symbol table
> > --13076-- Reading syms from /lib/tls/libm-2.3.3.so (0x5F5000)
> > --13076-- Reading syms from /lib/libgcc_s-3.3.3-20040413.so.1
> > (0x730000)
> > --13076--    object doesn't have a symbol table
> > --13076-- Reading syms from /lib/tls/libc-2.3.3.so (0x4D1000)
> > --13076-- Reading syms from /lib/tls/libpthread-0.61.so (0x62D000)
> > --13076-- REDIR: 0x4B87A0 (_dl_sysinfo_int80) redirected to 0xB001AF3B
> > (???)
> > --13076-- REDIR: 0x538B10 (memset) redirected to 0x4006680 (memset)
> > --13076-- REDIR: 0x537D70 (rindex) redirected to 0x4005C88 (rindex)
> > --13076-- REDIR: 0x5374E0 (strcpy) redirected to 0x4005FC4 (strcpy)
> > --13076-- REDIR: 0x538FE0 (memcpy) redirected to 0x40062A4 (memcpy)
> > --13076-- REDIR: 0x537AB0 (strnlen) redirected to 0x4005F4C (strnlen)
> > --13076-- REDIR: 0x537A00 (strlen) redirected to 0x4005F70 (strlen)
> > --13076-- REDIR: 0xA6D380 (operator new(unsigned)) redirected to
> > 0x4004779 (operator new(unsigned))
> > --13076-- REDIR: 0x5311D0 (malloc) redirected to 0x40043EE (malloc)
> > --13076-- REDIR: 0xA6D4C0 (operator new[](unsigned)) redirected to
> > 0x4004BA7 (operator new[](unsigned))
> > --13076-- REDIR: 0x537CC0 (strncpy) redirected to 0x4006084 (strncpy)
> > About to construct...
> > Inside the constructor...
> > --13076-- REDIR: 0x537300 (index) redirected to 0x4005D3C (index)
> > --13076-- REDIR: 0x5336A0 (free) redirected to 0x4004EE5 (free)
> > --13076-- REDIR: 0x538630 (memchr) redirected to 0x4006280 (memchr)
> > --13076-- REDIR: 0x5398A0 (rawmemchr) redirected to 0x4006714
> > (rawmemchr)
> > --13076-- REDIR: 0x538CD0 (stpcpy) redirected to 0x4006440 (stpcpy)
> > --13076-- REDIR: 0x531350 (realloc) redirected to 0x400574C (realloc)
> > --13076-- REDIR: 0x538AB0 (memmove) redirected to 0x40066A8 (memmove)
> > Container already exists.
> > --13076-- REDIR: 0xA6BE10 (operator delete[](void*)) redirected to
> > 0x4005491 (operator delete[](void*))
> > --13076-- REDIR: 0x537470 (strcmp) redirected to 0x4006218 (strcmp)
> > --13076-- REDIR: 0xA6BDB0 (operator delete(void*)) redirected to
> > 0x4005179 (operator delete(void*))
> > --13076-- REDIR: 0x537BF0 (strncmp) redirected to 0x40061B8 (strncmp)
> > ==13076== Conditional jump or move depends on uninitialised value(s)
> > ==13076==    at 0x39C7D96:
> > xercesc_2_7::XMLUTF8Transcoder::transcodeFrom(unsigned char const*,
> > unsigned, unsigned short*, unsigned, unsigned&, unsigned char*) (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B26F8:
> > xercesc_2_7::XMLReader::xcodeMoreChars(unsigned short*, unsigned
> > char*,
> > unsigned) (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B0D74: xercesc_2_7::XMLReader::refreshCharBuffer()
> > (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x392FAC3: xercesc_2_7::ReaderMgr::peekNextChar() (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B6BEC: xercesc_2_7::XMLScanner::scanProlog() (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39095CC:
> > xercesc_2_7::IGXMLScanner::scanDocument(xercesc_2_7::InputSource
> > const&)
> > (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B54A6:
> > xercesc_2_7::XMLScanner::scanDocument(unsigned short const*) (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x3872329:
> > xercesc_2_7::AbstractDOMParser::parse(unsigned short const*) (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0xC296D8: PathanBuilderImpl::parseURI(unsigned short
> > const*) (in /usr/lib/libpathan.so.3.0.1)
> > ==13076==    by 0x805228B:
> > xsd::cxx::xml::dom::auto_ptr<xercesc_2_7::DOMDocument>
> > xsd::cxx::xml::dom::dom<char>(std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> > const&,
> > xercesc_2_7::DOMErrorHandler&, xsd::cxx::xml::properties<char> const&,
> > bool) (in /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804FA68:
> > xsd::cxx::xml::dom::auto_ptr<xercesc_2_7::DOMDocument>
> > xsd::cxx::xml::dom::dom<char>(std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> > const&,
> > xsd::cxx::xml::error_handler<char>&, xsd::cxx::xml::properties<char>
> > const&, bool) (in /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804D296: hello(std::string const&,
> > xsd::cxx::tree::flags, xsd::cxx::tree::properties<char> const&) (in
> > /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > Hello, sun!
> > Hello, moon!
> > Hello, world!
> > Inside the destructor
> > ==13076==
> > ==13076== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 23 from
> > 1)
> > ==13076==
> > ==13076== 2 errors in context 1 of 1:
> > ==13076== Conditional jump or move depends on uninitialised value(s)
> > ==13076==    at 0x39C7D96:
> > xercesc_2_7::XMLUTF8Transcoder::transcodeFrom(unsigned char const*,
> > unsigned, unsigned short*, unsigned, unsigned&, unsigned char*) (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B26F8:
> > xercesc_2_7::XMLReader::xcodeMoreChars(unsigned short*, unsigned
> > char*,
> > unsigned) (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B0D74: xercesc_2_7::XMLReader::refreshCharBuffer()
> > (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x392FAC3: xercesc_2_7::ReaderMgr::peekNextChar() (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B6BEC: xercesc_2_7::XMLScanner::scanProlog() (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39095CC:
> > xercesc_2_7::IGXMLScanner::scanDocument(xercesc_2_7::InputSource
> > const&)
> > (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x39B54A6:
> > xercesc_2_7::XMLScanner::scanDocument(unsigned short const*) (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x3872329:
> > xercesc_2_7::AbstractDOMParser::parse(unsigned short const*) (in
> > /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0xC296D8: PathanBuilderImpl::parseURI(unsigned short
> > const*) (in /usr/lib/libpathan.so.3.0.1)
> > ==13076==    by 0x805228B:
> > xsd::cxx::xml::dom::auto_ptr<xercesc_2_7::DOMDocument>
> > xsd::cxx::xml::dom::dom<char>(std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> > const&,
> > xercesc_2_7::DOMErrorHandler&, xsd::cxx::xml::properties<char> const&,
> > bool) (in /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804FA68:
> > xsd::cxx::xml::dom::auto_ptr<xercesc_2_7::DOMDocument>
> > xsd::cxx::xml::dom::dom<char>(std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> > const&,
> > xsd::cxx::xml::error_handler<char>&, xsd::cxx::xml::properties<char>
> > const&, bool) (in /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804D296: hello(std::string const&,
> > xsd::cxx::tree::flags, xsd::cxx::tree::properties<char> const&) (in
> > /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > --13076--
> > --13076-- supp:   23 Ubuntu-stripped-ld.so
> > ==13076==
> > ==13076== IN SUMMARY: 2 errors from 1 contexts (suppressed: 23 from 1)
> > ==13076==
> > ==13076== malloc/free: in use at exit: 305,148 bytes in 300 blocks.
> > ==13076== malloc/free: 2,898 allocs, 2,598 frees, 1,059,290 bytes
> > allocated.
> > ==13076==
> > ==13076== searching for pointers to 300 not-freed blocks.
> > ==13076== checked 1,329,884 bytes.
> > ==13076==
> > ==13076==
> > ==13076== 32 bytes in 1 blocks are possibly lost in loss record 2 of 5
> > ==13076==    at 0x400446D: malloc (vg_replace_malloc.c:149)
> > ==13076==    by 0x82A152: DbXml::SimpleMemoryManager::allocate
> > (unsigned)
> > (Globals.cpp:50)
> > ==13076==    by 0x399DC92: xercesc_2_7::XMemory::operator new
> > (unsigned,
> > xercesc_2_7::MemoryManager*) (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x3912C38:
> > xercesc_2_7::XMLPlatformUtils::makeMutex(xercesc_2_7::MemoryManager*)
> > (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0x82B4D7: DbXml::Globals::initialize(DbEnv*)
> > (Globals.cpp:61)
> > ==13076==    by 0x82E49A: DbXml::Manager::initialize(DbEnv*)
> > (Manager.cpp:142)
> > ==13076==    by 0x82D76C: DbXml::Manager::Manager(DbEnv*, unsigned)
> > (Manager.cpp:82)
> > ==13076==    by 0x827C08: DbXml::XmlManager::XmlManager(DbEnv*,
> > unsigned) (XmlManager.cpp:49)
> > ==13076==    by 0x804AAF1: myDbxmlAdapter::myDbxmlAdapter(int) (in
> > /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804B154: main (in
> > /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==
> > ==13076==
> > ==13076== 20,108 (80 direct, 20,028 indirect) bytes in 2 blocks are
> > definitely lost in loss record 3 of 5
> > ==13076==    at 0x400446D: malloc (vg_replace_malloc.c:149)
> > ==13076==    by 0x82A152: DbXml::SimpleMemoryManager::allocate
> > (unsigned)
> > (Globals.cpp:50)
> > ==13076==    by 0x399DC92: xercesc_2_7::XMemory::operator new
> > (unsigned,
> > xercesc_2_7::MemoryManager*) (in /usr/lib/libxerces-c.so.27.0)
> > ==13076==    by 0xC2CB64: PathanImplementation::createDOMBuilder
> > (short,
> > unsigned short const*, xercesc_2_7::MemoryManager*,
> > xercesc_2_7::XMLGrammarPool*) (in /usr/lib/libpathan.so.3.0.1)
> > ==13076==    by 0x8051EDA:
> > xsd::cxx::xml::dom::auto_ptr<xercesc_2_7::DOMDocument>
> > xsd::cxx::xml::dom::dom<char>(std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> > const&,
> > xercesc_2_7::DOMErrorHandler&, xsd::cxx::xml::properties<char> const&,
> > bool) (in /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804FA68:
> > xsd::cxx::xml::dom::auto_ptr<xercesc_2_7::DOMDocument>
> > xsd::cxx::xml::dom::dom<char>(std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> > const&,
> > xsd::cxx::xml::error_handler<char>&, xsd::cxx::xml::properties<char>
> > const&, bool) (in /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804D296: hello(std::string const&,
> > xsd::cxx::tree::flags, xsd::cxx::tree::properties<char> const&) (in
> > /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==    by 0x804B1D5: main (in
> > /usr/doc/xsd/examples/cxx/tree/hello/driver)
> > ==13076==
> > ==13076== LEAK SUMMARY:
> > ==13076==    definitely lost: 80 bytes in 2 blocks.
> > ==13076==    indirectly lost: 20,028 bytes in 247 blocks.
> > ==13076==      possibly lost: 32 bytes in 1 blocks.
> > ==13076==    still reachable: 285,008 bytes in 50 blocks.
> > ==13076==         suppressed: 0 bytes in 0 blocks.
> > ==13076== Reachable blocks (those to which a pointer was found) are
> > not shown.
> > ==13076== To see them, rerun with: --show-reachable=yes
> > --13076--  memcheck: sanity checks: 142 cheap, 6 expensive
> > --13076--  memcheck: auxmaps: 0 auxmap entries (0k, 0M) in use
> > --13076--  memcheck: auxmaps: 0 searches, 0 comparisons
> > --13076--  memcheck: secondaries: 59 issued (3776k, 3M)
> > --13076--  memcheck: secondaries: 176 accessible and distinguished
> > (11264k, 11M)
> > --13076--     tt/tc: 54,806 tt lookups requiring 70,768 probes
> > --13076--     tt/tc: 54,806 fast-cache updates, 3 flushes
> > --13076-- translate: new        23,006 (479,971 -> 8,534,036; ratio
> > 177:10) [0 scs]
> > --13076-- translate: dumped     0 (0 -> ??)
> > --13076-- translate: discarded  8 (187 -> ??)
> > --13076-- scheduler: 7,143,675 jumps (bb entries).
> > --13076-- scheduler: 142/38,020 major/minor sched events.
> > --13076--    sanity: 143 cheap, 6 expensive checks.
> > --13076--    exectx: 30,011 lists, 2,899 contexts (avg 0 per list)
> > --13076--    exectx: 5,521 searches, 2,757 full compares (499 per
> > 1000)
> > --13076--    exectx: 296 cmp2, 69 cmp4, 0 cmpAll
> > ============= END VALGRIND OUTPUT ==================
> >
> >
> >> -----Original Message-----
> >> From: George Feinberg [mailto:george.feinberg at oracle.com]
> >> Sent: Friday, April 07, 2006 10:07 AM
> >> To: Ravi Sakaria
> >> Subject: Re: [bdbxml] Memory leak - DbXml 2.2
> >>
> >> OK.  I'll close the SR, as well, and if this takes a while, I'll reopen
> >> another.
> >>
> >> George
> >>
> >>> George,
> >>>
> >>> Thanks very much for your follow-up -- I've been beating my head
> >>> against
> >>> a wall for a week... I'll create a stripped down example that leaks
> >>> and
> >>> send it to you shortly.
> >>>
> >>> Best Regards,
> >>> Ravi
> >>>
> >>>> -----Original Message-----
> >>>> From: George Feinberg [mailto:george.feinberg at oracle.com]
> >>>> Sent: Thursday, April 06, 2006 6:45 PM
> >>>> To: Ravi Sakaria
> >>>> Subject: Re: [bdbxml] Memory leak - DbXml 2.2
> >>>>
> >>>>
> >>>> Ravi,
> >>>>
> >>>> What does the leaking code look like?
> >>>>
> >>>> George
> >>>>
> >>>>>> -----Original Message-----
> >>>>>> From: George Feinberg [mailto:george.feinberg at oracle.com]
> >>>>>> Sent: Thursday, April 06, 2006 5:20 PM
> >>>>>> To: Ravi Sakaria
> >>>>>> Cc: Ravi; xml at sleepycat.com
> >>>>>> Subject: Re: [bdbxml] Memory leak - DbXml 2.2
> >>>>>>
> >>>>>> Just to be clear.  Static class members are not instantiated
> >>>>>> with class instances, so it's only ever the 32-bits that
> >>>>>> are allocated.
> >>>>>>
> >>>>>> That said, I don't like the fact that this occurs -- at a minimum,
> >>>>>> it's a distraction, and I may make some changes that will
> >>>>>> eliminate this issue.
> >>>>> [Ravi Sakaria]
> >>>>> George,
> >>>>>
> >>>>> This is actually part of a larger problem that I'm trying to get to
> >>>>> the bottom of...
> >>>>>
> >>>>> I also use some classes that were auto-generated with the
> >>>>> CodeSynthesis
> >>>>> XSD application (www.codesynthesis.com).  When I instantiate one of
> >>>>> these classes *after* opening the dbxml handle (as in the sample code
> >>>>> below), the test program "definitely leaks 80 bytes".  But when I
> >>>>> do it without opening the dbxml handle, it doesn't leak at all.
> >>>>>
> >>>>> Also, if I open the dbxml handle inside curly brackets so it goes
> >>>>> out of scope before the XSD class instantiation, there is no leak.
> >>>>>
> >>>>> I'm still trying to figure out how the two operations are stepping on
> >>>>> each other.
> >>>>>
> >>>>> -- Ravi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060413/1ae65bc1/attachment.pgp


More information about the xsd-users mailing list