Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High memory usage while creating a xlsx file and xlsx.UseDiskVCellStore not working #596

Closed
Harikesh00 opened this issue Jul 9, 2020 · 7 comments · Fixed by #636
Closed

Comments

@Harikesh00
Copy link

Harikesh00 commented Jul 9, 2020

I have large data (160K+ rows & 39 columns) and while creating excel file it consumes 4GB+ memory and shows out of memory
As you have mentioned in [#487 ] use UseDiskVCellStore as a file option.
I have passed in the xlsx.NewFile(xlsx.UseDiskVCellStore) but it's not working, please check why it's not working and give example how to use it or any other solution.

@tealeg tealeg self-assigned this Jul 9, 2020
@tealeg
Copy link
Owner

tealeg commented Jul 9, 2020

Do you have some code that you can share - it's hard for me to debug it based on what you've told me.

@Harikesh00
Copy link
Author

Sure, I have removed extra code (like error checking) to make it small and simple.

excelGeneration.txt

@tealeg
Copy link
Owner

tealeg commented Jul 11, 2020

OK, I did some profiling and it looks like there might be a leak in the NewCell call, I'm looking into it.

@tealeg
Copy link
Owner

tealeg commented Jul 11, 2020

Perhaps leak is too strong a term. At the moment it seems to rest on the following:

We always hold an entire row of cells in memory at once. If you're using a spreadsheet with many columns, this can use quite a significant chunk of memory. Originally I wrote the backend to work around this by only keeping a single cell in memory at a time, but this required adding a "Save" call to the Cell which needed to be called every time you modified a cell, and was rather slow. However, I think something along this lines might be required to fix this issue. I'll think some more.

@Harikesh00
Copy link
Author

Harikesh00 commented Jul 11, 2020

Okay.
I had also done profiling NewCell and file Save took to much memory

@LiuShiYi1027
Copy link

I ran into the same problem, When I try to open an excel file (more than 300,000 rows) used xlsx.OpenFile(path) method,
my service crashed.

@github-actions
Copy link

Stale issue message

tealeg added a commit that referenced this issue Oct 19, 2020
Note, DiskVCellStore is designed to deal with the specific corner case
of dealing with very large spreadsheets.  To that end, I've favoured
enforcing behaviours on developers over modifying the public API of
this library to support those cases.  This manifests itself as the
following rule:

When using dhe DiskVCellStore you can only update the row or cell
most recently returned from the cell store.

In effect this means that if you keep multiple cells or rows in
temporary variables, that's fine, so long as you're referencing them
only, but should you try to set a value on an old cell or row you'll
get a deliberate panic from the library.
tealeg added a commit that referenced this issue Oct 19, 2020
Fix #596. DiskVCellStore persists with cell level granuality.
dolmen pushed a commit to dolmen-go/tealeg-xlsx.fork that referenced this issue May 11, 2023
Note, DiskVCellStore is designed to deal with the specific corner case
of dealing with very large spreadsheets.  To that end, I've favoured
enforcing behaviours on developers over modifying the public API of
this library to support those cases.  This manifests itself as the
following rule:

When using dhe DiskVCellStore you can only update the row or cell
most recently returned from the cell store.

In effect this means that if you keep multiple cells or rows in
temporary variables, that's fine, so long as you're referencing them
only, but should you try to set a value on an old cell or row you'll
get a deliberate panic from the library.
dolmen pushed a commit to dolmen-go/tealeg-xlsx.fork that referenced this issue May 11, 2023
Fix tealeg#596. DiskVCellStore persists with cell level granuality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants