Re: [xml] xmlMemUsed() always returns 0 even when mem debug is activated



Thank you for your answer.

You were right, actually ldd shows that the binary links with the system-wide dynamic library (/usr/lib/libxml2.so.2), not the recompiled one. This is really strange, since I followed the instructions on this page: http://xmlsoft.org/FAQ.html#Developer, and precised an absolute path for xml2-config. Indeed its output seems correct, for:

gcc -o xml `/home/felip/libxml2/bin/xml2-config --cflags` -g xml.c `/home/felip/libxml2/bin/xml2-config --libs`

is expanded as:

gcc -o xml -I/home/felip/libxml2/include/libxml2 -g xml.c -L/home/felip/libxml2/lib -lxml2 -lm

I was able to make my program work by temporarily changing the link in /usr/lib, but of course this is not a satisfactory solution. How would I have to proceed in order to force a correct linking ? (I'm sorry but I had never really dealt with dynamic libraries and compilations options before...)

Regards,

Felip.


En/na Daniel Veillard ha escrit:
On Thu, Dec 18, 2008 at 03:29:55PM +0100, apaxeros gmail com wrote:
Hello,

I've been trying to evaluate the amount of memory allocated using
xmlMemUsed. A similar question was asked in 2004:
http://mail.gnome.org/archives/xml/2004-March/msg00232.html, and Daniel
replied that mem debug had to be activated. That's why I recompiled libxml2
(version 2.6.30, on Ubuntu 8.04) with the option --with-mem-debug.
Unfortunately, the following code:

 doc = xmlParseFile(argv[2]);
  if (doc == NULL)
  {
      printf ("%s could not be parsed\n", argv[2]);
      exit (1);
  }
  printf("Used memory: %d\n", xmlMemUsed());
  xmlDocDump(stdout, doc);

always returns "Used memory: 0", while xmlDocDump() generates a correct
output. Is there a special way of using this function ?

  make 100% sure you link with the newly recompiled library,
if needed run under gdb and put a breakpoint on xmlMallocLoc.

Daniel




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