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

[writing] provide openxlsx2.export_with_pugi = FALSE option #1090

Closed
wants to merge 1 commit into from

Conversation

JanMarvin
Copy link
Owner

@JanMarvin JanMarvin commented Jul 20, 2024

This works on my linux machine with 32gb of memory, whereas it fails to export with pugixml due to the dom blowing up needs approximately 6gb more with pugixml.

library(openxlsx2)

n <- 10000
k <- 1000
mm <- matrix(rnorm(n * k), ncol = n, nrow = k)

temp <- temp_xlsx()

options("openxlsx2.export_with_pugi" = FALSE)
write_xlsx(x = mm, temp)

Interestingly reading does not requires that much memory.

wb <- openxlsx2::wb_load(temp)

@JanMarvin
Copy link
Owner Author

Unfortunately this isn't the magic key to really using way less memory. We create quite a few similar sized data objects, as in similar sized to x. Hence the wb_add_data() object is consuming that much memory, that certain larger objects cannot even be written into the wb. Therefore they also cannot be exported. Presumably it is possible to shrink some of the objects (rtype can be removed earlier, do we create a larg dims?), but I'm not sure this will bring much. And also it isn't that much fun to program and wait until the CPU fills all memory to crash.

@JanMarvin
Copy link
Owner Author

Just to add another thought: in theory we should be able to shrink our cc object and move e.g. all formula related columns into a smaller sized data frame. This would reduce the size of cc a lot, especially in cases where we have to write a lot of data. Currently we create a row of roughly eight values for each cell in the data.

@JanMarvin
Copy link
Owner Author

Closing for now. I might come back to this, but at the moment it does not seem all that useful to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant