I've just discovered a rather strange performance issue in my Excel COM add-in. The issue arose when I took the upgrade to version 4.0.12 having previously used 4.0.11. I'm compiling under XE7, 64 bit, and the troublesome module is an Excel COM add-in.
It's pretty tricky to reproduce, which I know is frustrating. Perhaps you could help me understand what the madExcept code is doing to help me narrow down my search. I rather imagine that my code is raising a lot of handled exceptions, but I don't at the moment see why it would, nor am I able to run under the debugger to inspect because the 64 bit debugger is, er, unreliable. I'm not able to get any debug symbols. What debugging I have done suggests that my code is raising handled exceptions, and I will try to understand why.
What is interesting is that I looked at the changes introduced in 4.0.12 and I found that I could resolve the performance issue by making a change here:
In 4.0.12 IsClass is implemented like this:
Code: Select all
function IsClass(obj: TObject; const className: AnsiString) : boolean;
var cn : AnsiString;
inot : boolean;
begin
result := IsValidObjectEx(obj, cn, inot, className);
end;
Code: Select all
function IsClass(obj: TObject; const className: string) : boolean;
var clss : TClass;
begin
result := false;
try
if obj <> nil then begin
clss := obj.ClassType;
while (clss <> nil) and (clss.ClassName <> className) do
clss := clss.ClassParent;
result := clss <> nil;
end else
result := false;
except end;
end;
As of now I'm going to try to understand why my code is raising lots of handled exceptions and see if I can reduce the number of them. However, it does feel as though the 64 bit performance is impacted by handled exceptions from 4.0.12.
From my perspective, with my incomplete knowledge, I prefer the implementation of IsClass from 4.0.11!