mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 22:02:06 -06:00
[GH-ISSUE #453] It seems there is a memory leak in constant memory enabled when trying to insert date #356
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#356
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @videni on GitHub (Aug 27, 2024).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/453
Sorry, I don't know much about C. I can't reproduce it with C. I only found the problem in here. I copy the critical code here if you can spot it quickly. The code enabled const memory is not copied here, but it is enabled in my local. The code looks very normal.
@jmcnamara commented on GitHub (Aug 27, 2024):
If it is the last one and your /tmp is mapped to memory then the application is consuming disk space but that disk space has been mapped to memory.
If this is the case then libxlsxwriter has an option to change the location of the temp files it used:
http://libxlsxwriter.github.io/workbook_8h.html#a7329be90faba9e9ee65f58cb221aa4f1
Check if php-ext-xlsxwriter has the same opinion.
Note, libxlsxwriter has hundreds of tests for memory leaks that run in the CI so it is unlikely that it is an actual leak.
@videni commented on GitHub (Aug 27, 2024):
@jmcnamara, thansk for the tips, there is no option to change the location of the temp files in the php-ext-xlsxwriter , and the problem it not the tmp files, I run the code on MacOS, Ubuntu , Alpine linux, all have the issue.
I think it can reproduced by this link, you can observe continious growth of memory when constant memory enabled and insert 1 million rows with a datetime. sorry it is PHP code.
@jmcnamara commented on GitHub (Aug 27, 2024):
Ok. Sorry I can't help you other than the advice above.
@videni commented on GitHub (Aug 27, 2024):
@jmcnamara after some experiments, I found this line caused the memory leak. does the code below remind you something please?
the below are from the
datetime_writermethod above.@jmcnamara commented on GitHub (Aug 27, 2024):
That definitely looks like an issue. It seems to be creating a new format object for each call to
datetime_writer(). These objects are cleaned up on exit so it isn't a leak. However, it will cause a memory growth. Especially, if you writing a million cells.You should contact the author and let them know.
You may be able to work around it by writing a number instead of a date. In Excel a date is a number with a format. You will need to covert the dates yourself but it will avoid this issue (unless the number writer is doing the same thing).
See: https://libxlsxwriter.github.io/working_with_dates.html
@videni commented on GitHub (Aug 27, 2024):
@jmcnamara I see, thanks a lot. Finally, I understand what the real problem is. The
php-ext-xlswriteralmost calls theworkbook_add_formatmethod for each cell. that issue existed for 2 years, still not fixed. Some design issues might exist , not easy to fix. There might be two ways to solve the problem:set_columnmethod instead.except strings, the
numberhas the same issue asdatetime, if no format passed for theworksheet_write_string,worksheet_write_number,worksheet_write_datetime, it will use the format set by theset_columnmethod , right?@videni commented on GitHub (Aug 28, 2024):
Closed as solved by php-ext-xlswriter, @jmcnamara thanks for help,