1
votes

Delphi XE6. I am writing a COM PlugIn for Excel (using Add-In Express). I iterate through all rows, reading a given column, which is a business name. I then use my own algorithm to try to match this name in a Database, updating the rest of the spreadsheet columns if I can match the name (aka is the University of Chicago the same as Chicago University, etc). The program compiles and runs. My issue is that after a certain point, it slows down dramatically.

As an example, I have 1,000 rows of data. I copy this data 6 times, making 6,000 rows in my spreadsheet. I take an average of processing time every 50 rows. Up to 3600 rows, the average is 450 ms per row. CONSISTENTLY at 3600 rows, the average jumps up to (and stays) in the 4200ms per row range.

I have looked for memory leaks, using

ReportMemoryLeaksOnShutdown:=True; 

And not found any. It is the exact same data every 1000 rows, so it is not data related. I am running 64 bit windows (8.1), although 32 bit Excel and 32 bit compiled dll. I have checked memory my app is using (with GetProcessMemoryInfo)... It may start at 120MB, and jump up 4-5 MB during the whole process. It jumps up in increments of 60-80K.

I have tried saving the Excel spreadsheet every 200 rows, but that made no difference.

My matching algorithm uses RegEx, so I have tried using an external RegEx library. That made no difference. I am in the process of rewriting the match routines with AnsiStartsText instead of Regex now...

I feel that I am looking at some kind of memory issue. I am using a Class I created. This class is called AccountSearch. It has a descendant class, called AccountCriteria, as well a TLIST of objects called HITS (aka possibilities that are scored). I pass these around between various functions and procedures. Are there any unique issues when passing classes as arguments? In effect, they are treated as VAR parameters, and no additional memory issues need to be addressed, correct? They are not copied, they use no extra memory when used as arguments, correct?

Is there anything else I should be looking at?

1
You'll need to do some profiling. Very unlikely to get a diagnosis from here.David Heffernan
@@David, can you comment on passing classes as parameters questions?user1009073
Classes are reference types. So yes, given AObject: TObject, AObject is simply a pointer to the object.David Heffernan
If you put Add-In Express to one side and just create an Excel-automating app that does the same, do you get the same slow-down? If you post your actual code, readers would be better placed to comment & maybe help.MartynA

1 Answers

2
votes

Objects are passed by referenced, yes.

Since you are creating a COM plugin, and using an older version of Delphi, you need to make sure that you are not being bitten by the OLE reference leak bug. These would not be reported as memory leaks on shutdown, because they are not really memory leaks:

https://marc.durdin.net/2012/07/understanding-and-correcting-interface-reference-leaks-in-delphis-vcl-olectrls-pas/