In Delphi 7 Enterprise, I use IXMLDocument to load an XML file.
Task Manager says memory is allocated when I set Active to True,
which sounds right to me. IXMLDocument should be automatically
destroyed when it goes out of scope, but Task Manager says the
memory is still allocated.
I must be doing something wrong. Please show me the error of
my ways.
Chris
-----------------------------------------------
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;
-----------------------------------------------------
This message was posted using http://www.gdse.com/
Task manager isn't a goot tool to profile apps' memory usage - u can't rely
on it reports making decisions wether your app have memory leaks or not. Use
special tools instead.
Good luck.
Thanks for the reply. Can you suggest a good tool I can use?
Chris
> ...or just operator malfunction?
>
> In Delphi 7 Enterprise, I use IXMLDocument to load an XML file.
> Task Manager says memory is allocated when I set Active to True,
> which sounds right to me. IXMLDocument should be automatically
> destroyed when it goes out of scope, but Task Manager says the
> memory is still allocated.
>
> I must be doing something wrong. Please show me the error of
> my ways.
>
> Chris
[...]
Hi Chris,
I ran into something similar using IXMLDocument and IXMLDOMDocument.
It was frustrating, because we could only see the memory usage growing
using the Windows task manager. George is right that this isn't the
best tool for detecting memory leaks, but it's plenty accurate enough
to tell me that the machine is out of RAM and that my app is the
culprit. So you aren't entirely crazy.
Turns out the problem showed up on Windows 2000. We solved it by
upgrading the MSXML 3.0 that shipped with Windows 2000 to SP2. I see
they have SP4 available now. I think this update is also installed if
you get the latest IE6 patches.
http://www.microsoft.com/downloads/details.aspx?FamilyID=c0f86022-2d4c-4
162-8fb8-66bfc12f32b0&DisplayLang=en
Let me know if this helps.
--
Regards,
Bruce McGee
Glooscap Software
Try to search in google with "Delphi memory profiling".
Good luck.
I have the same memory problem. I have W2000 SP4 installed, but the problem
still exist. Do you have other solutions?
Further, setting Active to True costs lots of CPU. Is this normal? I should
deal with 1000 XMLDocuments per second. Is this to much for the DOM or am I
doing something wrong? When I get the information out of the XML by
stringoperations, it only takes a fraction of the CPU, even for 1000
documents per second.
Regards,
Jurgen
"Bruce McGee" <bmc...@glooscap.com> wrote in message
news:xn0djnxm7...@newsgroups.borland.com...
Install MSXML4 update:
http://www.microsoft.com/downloads/details.aspx?FamilyID=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&DisplayLang=en
Petr.
> Bruce,
> Chris,
>
> I have the same memory problem. I have W2000 SP4 installed, but the
> problem still exist. Do you have other solutions?
>
> Further, setting Active to True costs lots of CPU. Is this normal? I
> should deal with 1000 XMLDocuments per second. Is this to much for
> the DOM or am I doing something wrong? When I get the information out
> of the XML by stringoperations, it only takes a fraction of the CPU,
> even for 1000 documents per second.
>
> Regards,
>
> Jurgen
I solved this by installing a service pack of MSXML3, or as Petr
suggested, install MSXML4. Chris mentioned that MSXML4 solved his
problem.
Please let us know how you make out.
Jurgen
"Bruce McGee" <bmc...@glooscap.com> wrote in message
news:xn0dkfxzl...@newsgroups.borland.com...