 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
cwogle Guest
|
Posted: Wed Jun 16, 2004 2:28 pm Post subject: Re: TXMLDocument - is there a memory leak? |
|
|
I also see a memory leak, but mine occurs even if I don't delete any nodes.
Interfaces such as IXMLDocument are
supposed to be lifetime-managed and, if created with no
owner, be automatically destroyed when they go out of
scope. Try running this with Task Manager and watch
your allocated memory climb!
Any help is sincerely appreciated. Example code follows:
procedure TForm1.Button1Click(Sender: TObject);
var
Metafile : IXMLDocument;
begin
// Create & initialize IXMLDocument.
// Have also tried: Metafile := LoadXMLDocument
( 'Metadata.xml' );
Metafile := TXMLDocument.Create( nil );
Metafile.FileName := 'Metadata.xml';
// Populate the IXMLDocument. This allocates
// lots of memory.
Metafile.Active := True;
// Shouldn't have to do anything else to release
// the IXMLDocument, but...
// Try removing all child nodes to release memory.
while Metafile.DOMDocument.firstChild <> nil do
Metafile.DOMDocument.removeChild(
Metafile.DOMDocument.firstChild );
// Try explicitly releasing the IXMLDocument.
Metafile._Release;
// Try forcing the reference count to zero.
Metafile := nil;
// Nope. Even after exiting here, memory
// is still allocated.
end;
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|