I would like to know if there exists any tool (like a profiler), or a Windows function, to monitor how much memory is used by a particular COM object.
For example:
var
WordApplication, WordDocument: Variant;
begin
WordApplication := CreateOleObject('Word.Application');
WordDocument := WordApplication.Documents.Add;
//here I would like to know how much memory is used by
//the WordApplication and WordDocument variables.
end;
In general there could be no such tool. For such a tool to exist it would need to know about the internals of any general COM object and I think that’s too much to ask.
In this example,
WordDocumentis part ofWordApplicationand so the memory use for the application is somewhat more pertinent. What you could do is work out how much memory the instance of Word that hostsWordApplicationis consuming. Process Explorer will tell you that.