BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: TXMLDocument - is there a memory leak?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.components.usage
View previous topic :: View next topic  
Author Message
cwogle
Guest





PostPosted: Wed Jun 16, 2004 2:28 pm    Post subject: Re: TXMLDocument - is there a memory leak? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.components.usage All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.