Re: [gdome] problems with API gdome_di_createDocFromMemory()...



On 4/29/06, Sameer Oak <sameer oak airtightnetworks net> wrote:
Hello,

I am facing severe problems with API gdome_di_createDocFromMemory(). The
underlying call xmlParseMemory() of libxml2 is probably causing these
leaks.

These leaks are being resulted eventhough I am calling gdome_di_unref()
and gdome_doc_unref().

Also, API gdome_di_createDocFromURI() is not useful for me since it is
making frequent I/O calls.

My Server-Client architecture requires the in-memory persistent XML
object.
Once done with parsing the Client's configuration, which is sent as an
XML file, I need to free all the objects created for the parsing
context.

Gustavo helped me on this. I am very much grateful to him for his time
and efforts. But I'm still facing the problems.

Please guid me, I'm held up on this.

Well... as I said to you, I still have no time to look at this, but I
do really think it's not a memory leak, but global variables that live
through the whole program life (singletons), they could have their
memory freed, but not freeing it's not an error.

You could test that with:

int main( void )
{
  int i, n = 1000;
  const static gchar xml[] = "<root><a><b>t0</b><c>t1</c></a>t3</root>";
  GdomeDOMImpl *di = gdome_di_mkref();
  GdomeException exc = 0;
  for ( i=0; i < n; n++ ) {
     GdomeDocument *doc = gdome_di_createFromMemory( di, xml, &exc );
     GdomeNode *node = gdome_doc_documentElement( doc, &exc );
     gdome_n_unref( node, &exc );
     gdome_doc_unref( doc, &exc );
  }
  gdome_di_unref( di, &exc );
}


run with n=1000 and other big numbers... it it really leaks memory it will show.

(note: untested code, may have bugs)

--
Gustavo Sverzut Barbieri
--------------------------------------
Jabber: barbieri gmail com
  MSN: barbieri gmail com
 ICQ#: 17249123
 Skype: gsbarbieri
Mobile: +55 (81) 9927 0010
Phone:  +1 (347) 624 6296; 08122692 sip stanaphone com
  GPG: 0xB640E1A2 @ wwwkeys.pgp.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]