[gdome] Question about memory problem
- From: scetre <scetre obs ujf-grenoble fr>
- To: gdome gnome org
- Subject: [gdome] Question about memory problem
- Date: Tue, 09 Nov 2004 18:26:38 +0100
I write a short code to show you my memory problem. I simply create a
GdomeDOMImplementation and a GdomeDocument and I free them.
--------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <libgdome/gdome.h>
int main (int argc, char *argv[])
{
GdomeDOMImplementation *domimpl;
GdomeDocument *doc;
GdomeException exc;
/* Get a DOMImplementation reference */
domimpl = gdome_di_mkref ();
/* Load a new document from a file */
doc = gdome_di_createDocFromURI(domimpl, "test.xml", GDOME_LOAD_PARSING,
&exc);
gdome_doc_unref (doc, &exc);
gdome_di_unref (domimpl, &exc);
}
--------------------------------------------
the file test.xml is :
--------------------------------------------
<?xml version="1.0"?>
<TEST></TEST>
--------------------------------------------
I compile it with the command
--------------------------------------------
gcc gdomeTest.c -I/usr/include/libgdome -lgdome
-I/usr/lib/glib-2.0/include/ -I/usr/include/glib-2.0 -o gdomeTest
--------------------------------------------
then I run with valgrind and I have a memory problem :
--------------------------------------------
valgrind --leak-check=yes --show-reachable=yes ./gdomeTest
--------------------------------------------
I have :
--------------------------------------------
==2434== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
==2434== Copyright (C) 2002, and GNU GPL'd, by Julian Seward.
==2434== Using valgrind-1.9.6, a program instrumentation system for
x86-linux.
==2434== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==2434== Estimated CPU clock rate is 2824 MHz
==2434== For more details, rerun with: -v
==2434==
==2434==
==2434== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==2434== malloc/free: in use at exit: 670 bytes in 20 blocks.
==2434== malloc/free: 60 allocs, 40 frees, 74431 bytes allocated.
==2434== For counts of detected errors, rerun with: -v
==2434== searching for pointers to 20 not-freed blocks.
==2434== checked 5163672 bytes.
==2434==
==2434== 48 bytes in 2 blocks are still reachable in loss record 1 of 5
==2434== at 0x4015F3AF: malloc (in /usr/lib/valgrind/valgrind.so)
==2434== by 0x403DC5B1: xmlNewMutex (in /usr/lib/libxml2.so.2.6.9)
==2434==
==2434== 62 bytes in 8 blocks are still reachable in loss record 2 of 5
==2434== at 0x4015F3AF: malloc (in /usr/lib/valgrind/valgrind.so)
==2434== by 0x403D9465: xmlStrndup (in /usr/lib/libxml2.so.2.6.9)
==2434== by 0x37: ???
==2434==
==2434== 160 bytes in 8 blocks are still reachable in loss record 3 of 5
==2434== at 0x4015F3AF: malloc (in /usr/lib/valgrind/valgrind.so)
==2434== by 0x4044B2C2: xmlNewCharEncodingHandler (in
/usr/lib/libxml2.so.2.6.9)
==2434==
==2434== 200 bytes in 1 blocks are still reachable in loss record 4 of 5
==2434== at 0x4015F3AF: malloc (in /usr/lib/valgrind/valgrind.so)
==2434== by 0x4044B389: xmlInitCharEncodingHandlers (in
/usr/lib/libxml2.so.2.6.9)
==2434==
==2434== 200 bytes in 1 blocks are still reachable in loss record 5 of 5
==2434== at 0x404D6C5E: (within /usr/lib/valgrind/libpthread.so)
==2434== by 0x404D85FE: (within /usr/lib/valgrind/libpthread.so)
==2434== by 0x404D8717: __pthread_key_create (in
/usr/lib/valgrind/libpthread.so)
==2434== by 0x403DCA36: (within /usr/lib/libxml2.so.2.6.9)
==2434==
==2434== LEAK SUMMARY:
==2434== definitely lost: 0 bytes in 0 blocks.
==2434== possibly lost: 0 bytes in 0 blocks.
==2434== still reachable: 670 bytes in 20 blocks.
==2434== suppressed: 0 bytes in 0 blocks.
==2434==
--------------------------------------------
I don't know how I can freed the still reachable memory : 670 bytes in
20 blocks.
Thank you again for your future help.
Sylvain Cetre
I
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]