June 3rd, 2011, 2:33 pm
I know a lot of the people who maintain XLW are frequent contributors here, so I am hoping this is the best place to ask this question.I've been using XLW for a long time and it works beautifully (version 3.0.0f). However, I encountered a memory-leak problem, which only shows up intermittently. This particular function uses ADO to run a query against a SQL Server and returns the results in the spreadsheet. For certain queries, it shows a heap allocation error. In debug mode, it breaks in XlfExcel::FreeMemory, on the line "delete[] freeList_.back().start;". It doesn't seem like it does anything wrong. I can even ignore the error (when the dialog with "Abort|Retry|Ignore" shows up), and everything keeps working as it's supposed to. The particular query exhibiting the behavior doesn't even return that much data, it's about 300 rows and 3 columns. For that size CellMatrix, XlfExcel::GetMemory is requesting in the neighborhood of 60K bytes. If I change the initial buffer size to 256K, the error disappears. The other thing I discovered is that it seems related to how I am reading strings returned by ADO. The ADO type for those is adVarChar, which is represented as a BSTR, which is typedef'ed as a wchar_t *. If I just return a constant string instead of converting the BSTR to a std::string (using WideCharToMultiByte), the problem goes away as well.I guess my questions are the following:- has anyone experienced any similar behavior? How did you solve it?- would switching over to version 4 get rid of this problem?- is the solution I came up with (increasing the initial buffer size) a real solution or will it just make the problem appear less often?Thanks,Marc.