comp.lang.ada
 help / color / mirror / Atom feed
* My XML/Ada code is leaking
@ 2011-05-17 21:04 Thomas Løcke
  2011-05-18 12:11 ` My XML/Ada code is leaking [SOLVED] Thomas Løcke
  2011-05-18 13:04 ` My XML/Ada code is leaking Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Løcke @ 2011-05-17 21:04 UTC (permalink / raw)


Hey all,

I'm using XML/Ada to build some Atom XML, and while things in general
are going well, I've hit a wall in a part of the code where I need to
build a DOM document from some string XML and add it to a DOM node.

The problem is basically that my code leaks, and I can't figure out how
to fix it.

I've made this small example that show the exact problem:

     http://pastebin.com/a8t0tAC2

When I execute the program using this:

     valgrind -v --leak-check=full --track-origins=yes foobar

I get a leak looking like this:

==18942== LEAK SUMMARY:
==18942==    definitely lost: 144 bytes in 1 blocks

The amount of bytes obviously goes up if more Create_Element calls are
made.

If there are any XML/Ada experts out there, please feel free to point
me in the right direction, because I'm at my wits end with this one.

The compiler used is GNAT GPL 2010 on Slackware 13.37 x86_64. Valgrind
is version 3.6.1, in case that matters.

:o)

-- 
Thomas L�cke

Email: tl at ada-dk.org
Web: http//:ada-dk.org
http://identi.ca/thomaslocke



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: My XML/Ada code is leaking [SOLVED]
  2011-05-17 21:04 My XML/Ada code is leaking Thomas Løcke
@ 2011-05-18 12:11 ` Thomas Løcke
  2011-05-18 13:04 ` My XML/Ada code is leaking Simon Wright
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Løcke @ 2011-05-18 12:11 UTC (permalink / raw)


On 05/17/2011 11:04 PM, Thomas L�cke wrote:
> Hey all,
>
> I'm using XML/Ada to build some Atom XML, and while things in general
> are going well, I've hit a wall in a part of the code where I need to
> build a DOM document from some string XML and add it to a DOM node.
>
> The problem is basically that my code leaks, and I can't figure out how
> to fix it.
>
> I've made this small example that show the exact problem:
>
> http://pastebin.com/a8t0tAC2
>
> When I execute the program using this:
>
> valgrind -v --leak-check=full --track-origins=yes foobar
>
> I get a leak looking like this:
>
> ==18942== LEAK SUMMARY:
> ==18942== definitely lost: 144 bytes in 1 blocks


I've solved the problem by getting rid of the First_Child call at line
124. That resulted in an excessive amount of XML declarations being
written, but that was easily solved by adding

     Print_XML_Declaration => False

to my DOM.Core.Nodes.Write call. Oh and I didn't add the entire output
code to the pastebin example, so you wont be able to find the Write call
in there. Just trust me when I say that it works.  :o)

I still don't quite understand why First_Child would cause those issues
but at least I now have a functioning system, and it's probably also a
faster system, as I'm no longer wasting time returning the First_Child
to get rid of the XML declarations. Yay!

-- 
Thomas L�cke

Email: tl at ada-dk.org
Web: http//:ada-dk.org
http://identi.ca/thomaslocke



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: My XML/Ada code is leaking
  2011-05-17 21:04 My XML/Ada code is leaking Thomas Løcke
  2011-05-18 12:11 ` My XML/Ada code is leaking [SOLVED] Thomas Løcke
@ 2011-05-18 13:04 ` Simon Wright
  2011-05-18 13:15   ` Thomas Løcke
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Wright @ 2011-05-18 13:04 UTC (permalink / raw)


Thomas Løcke <tl@ada-dk.org> writes:

> I'm using XML/Ada to build some Atom XML, and while things in general
> are going well, I've hit a wall in a part of the code where I need to
> build a DOM document from some string XML and add it to a DOM node.
>
> The problem is basically that my code leaks, and I can't figure out how
> to fix it.

I've tried this on Mac OS X Snow Leopard both with GCC 4.6.0 & XMLAda
from SVN and with GNAT GPL 2010 & its XML/Ada.

The leak detector is XCode / Instruments / Leaks, and shows no
leaks. Hmm.

Leaks looks at the status on a regular basis, every 10 seconds by
default, so I added a 'delay 11.0' at the end.

I tried adding a deliberate leak and Leaks spotted it. It didn't give me
any trace (beyond the address allocated, or perhaps from which the
allocation was made). Probably down to my ignorant fumblings!
Nevertheless, it looks as though there isn't a leak on the Mac.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: My XML/Ada code is leaking
  2011-05-18 13:04 ` My XML/Ada code is leaking Simon Wright
@ 2011-05-18 13:15   ` Thomas Løcke
  2011-05-18 14:20     ` Georg Bauhaus
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Løcke @ 2011-05-18 13:15 UTC (permalink / raw)


On 05/18/2011 03:04 PM, Simon Wright wrote:
> I've tried this on Mac OS X Snow Leopard both with GCC 4.6.0&  XMLAda
> from SVN and with GNAT GPL 2010&  its XML/Ada.
>
> The leak detector is XCode / Instruments / Leaks, and shows no
> leaks. Hmm.
>
> Leaks looks at the status on a regular basis, every 10 seconds by
> default, so I added a 'delay 11.0' at the end.
>
> I tried adding a deliberate leak and Leaks spotted it. It didn't give me
> any trace (beyond the address allocated, or perhaps from which the
> allocation was made). Probably down to my ignorant fumblings!
> Nevertheless, it looks as though there isn't a leak on the Mac.


Well, that is interesting Simon. Is valgrind available for Mac? Maybe
the issue is one of valgrind reporting a false positive.

I've recently bought a Macbook Air, so maybe I should give it a whirl
myself. Is it difficult to get GNAT/GPS up and running on Mac?

-- 
Thomas Løcke

Email: tl at ada-dk.org
Web: http//:ada-dk.org
http://identi.ca/thomaslocke



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: My XML/Ada code is leaking
  2011-05-18 13:15   ` Thomas Løcke
@ 2011-05-18 14:20     ` Georg Bauhaus
  2011-05-18 19:01       ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Georg Bauhaus @ 2011-05-18 14:20 UTC (permalink / raw)


On 18.05.11 15:15, Thomas Løcke wrote:

> I've recently bought a Macbook Air, so maybe I should give it a whirl
> myself. Is it difficult to get GNAT/GPS up and running on Mac?

You would have a 64bit CPU, so not difficult at all: get GNAT GPL
from AdaCore as usual.  Be sure to have installed X for Mac OS X,
it is an optional component to be found on the installation medium.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: My XML/Ada code is leaking
  2011-05-18 14:20     ` Georg Bauhaus
@ 2011-05-18 19:01       ` Simon Wright
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Wright @ 2011-05-18 19:01 UTC (permalink / raw)


Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

> On 18.05.11 15:15, Thomas Løcke wrote:
>
>> I've recently bought a Macbook Air, so maybe I should give it a whirl
>> myself. Is it difficult to get GNAT/GPS up and running on Mac?
>
> You would have a 64bit CPU, so not difficult at all: get GNAT GPL
> from AdaCore as usual.  Be sure to have installed X for Mac OS X,
> it is an optional component to be found on the installation medium.

Also Xcode (for as, ar, ld ...)



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-18 19:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-17 21:04 My XML/Ada code is leaking Thomas Løcke
2011-05-18 12:11 ` My XML/Ada code is leaking [SOLVED] Thomas Løcke
2011-05-18 13:04 ` My XML/Ada code is leaking Simon Wright
2011-05-18 13:15   ` Thomas Løcke
2011-05-18 14:20     ` Georg Bauhaus
2011-05-18 19:01       ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox