Forum > Packages and Libraries

[SOLVED] FPSpreadSheet, ReadAsText seems to create Memory leak

<< < (3/4) > >>

TRon:

--- Quote from: andresayang on December 09, 2024, 09:10:19 pm ---But if @wp do not have it, and we do, maybe something outside FPSPreadSheet (I was thinking about locals setup because it should be the only thing from system which could influence FPSpreadSheet).

--- End quote ---
It seems more related to the xml parser. Note that xml_dom seem to be showing its colours (the memory blocks that are not freed are much bigger there).

So, either the spreadsheet itself contains xml that can't be handled or the xml parser chokes itself by not freeing something which it allocated.


--- Quote ---So my locals are utf8 - us

--- End quote ---
Same here but might be pure coincidence.


--- Quote ---The thing is, in the example, if you keep only "SUMMARY" sheet in the workbook, no more memory leak. The function is supposed to read only "SUMMARY" sheet.

--- End quote ---
And it does only 'handle' one sheet, though I am not familiar with what the search engine actually does.

Note that the example code you've posted just runs and produce the results the program seem to be looking for. It seem the xml backend used by fpSpreadsheet seems to be tripping over something in particular (which it shouldn't).

I admit, it is out of the ordinary that wp is not able to reproduce... Still thinking about that one.

andresayang:
Hi,

Is FPSpreadSheet developed and maintained by WP ? (Maybe I should submit my example directly to maintainers ?)

Cheers

TRon:

--- Quote from: andresayang on December 09, 2024, 10:34:35 pm ---Is FPSpreadSheet developed and maintained by WP ? (Maybe I should submit my example directly to maintainers ?)

--- End quote ---
To my knowledge yes, though afaik nothing official. I consider WP an authority on/at/for fpSpreadsheet.

The "problem" is he's doing a lot of other (important) development as well so he might be a bit busy and isn't always capable of immediately directing his attention to a specific issue. That is why I tried to reproduce and am still trying to see what might be the culprit though I am not that familiar with the code-base of fpSpreadSheet (but I am at least capable of reading a trace  :) ).

andresayang:

--- Quote ---The "problem" is he's doing a lot of other (important) development as well so he might be a bit busy and isn't always capable of immediately directing his attention to a specific issue. That is why I tried to reproduce and am still trying to see what might be the culprit though I am not that familiar with the code-base of fpSpreadSheet (but I am at least capable of reading a trace  :) ).

--- End quote ---

Man, yes of course, no problem and thanks a lot for Lazarus !
Lazarus is a free software thanks to all developers from a guys who learn Pascal (UCSD was the first compiler I use), then Turbopascal, then Delphi which was too expensive for me (as I use it at work, to reduce my daily work load, can not play with non legal software).

Cheers

So i digg a little bit more deeper: (I hope it can help)

The leak is created directly at the workbook creation, and seems to come from the "PLOT" sheet (If I remove it, no more leaks).

If you comment all after "mySearchEngine:= TsSearchEngine.Create(TheWorkBook);" (line 95) and close the comment just before the "finally" (line 155) we still have the same leaks, with same "288 unfreed memory blocks".

So I went deeper on this and I do not think the problem is from FPSpreadSheet .... but from the excel worksheet itself (it should be somehow wrongly formatted or I do not know).

I try: moving the "PLOT" sheet in another workbook, saved the original file then move back the "PLOT" worksheet in main workbook: No more leaks.

I tag the subject as Solved ...

wp:
Looking up the trace I see a call to ReadEmbeddedObjs. This is normally used for images, pictures etc. And your test file does contain a chart which is handled by this function, too. I assume that you are using the OPM version of fpspreadsheet which does not have chart support at all, or partial - I don't remember, while I am using the svn version of FPSpreadsheet where much work was put into chart support.

To verify this idea I switched to the OPM version of FPSpreadsheet, and now I can confirm the issue. And going a step further - deleting the charts from the PLOT sheet removes the memory leak.

Therefore, the solution for you would be to either remove the charts from the xlsx file, or to install the svn version (use svn, or get the zipped snapshot from https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/fpspreadsheet/)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version