Code Monkey home page Code Monkey logo

Comments (6)

jmcnamara avatar jmcnamara commented on July 17, 2024

But, when deploying it to my production server, I am getting memory leaks that generate files which names contains some parts of the content of my .xlsx, not in the directory it was called, by in the root directory of my application.

The libxlsxwriter lib creates some temporary files that are zipped/assembled into a xlsx file. It is possible that if the application fails that these temp files are left behind. Typically they are xml files.

This shouldn't be causing a memory leak though.

Yesterday, I also got the problem:

[ERROR][packager.c:62]: Error opening zip file for xlsx
[ERROR][workbook.c:1108]: Memory allocation failed.

This is a misleading error. It is caused by not having sufficient write permission to create the output file. See the explanation in Issue #12.

Do I have to grant writing permission recursively to the directories preceding the directory where the file is being generated?

Possibly. You, or your app, should be able to do something like this without getting an error:

touch /path/to/output/dir/some_new_file.xlsx

I there a way you would recommend me to simulate my production environment in order to effectively test the embedded lib?

I don't have any sure fire suggestions. Debugging write permission in a web app can be tricky.

By the way, there is a Ruby port of the original Perl module that libxlsxwriter is ported from: https://github.com/cxn03651/write_xlsx

from libxlsxwriter.

eroncastro avatar eroncastro commented on July 17, 2024

Thank you for answering.

I already use write_xlsx gem. The problem with it is that it consumes too much memory when exporting a large number of rows (~ 1MM), which makes my app to stop the process in order not to fall.
When I used your solution embedded with my Rails app in constant memory mode, it only consume 2% of my machine RAM and took only 30 seconds to generate my .xlsx file. I'm going to try once again and I'll report you any other issues!

Thank you again!

from libxlsxwriter.

jmcnamara avatar jmcnamara commented on July 17, 2024

I already use write_xlsx gem. The problem with it is that it consumes too much memory when exporting a large number of rows (~ 1MM), which makes my app to stop the process in order not to fall.

I didn't realise that the Ruby port hadn't ported the constant_memory/optimization mode. It was in the original Perl module and is in my Python and Lua versions as well.

from libxlsxwriter.

eroncastro avatar eroncastro commented on July 17, 2024

I used strace command to attach it to the process. The error I get is the following:

open("/var/www/app/public/exports/ff/c3/8e/ffc38ef077171f690eb01cfe8792845b/test.xlsx", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 EACCES (Permission denied)
write(2, "[ERROR][packager.c:62]: Error op"..., 56) = 56
write(2, "[ERROR][workbook.c:1108]: Memory"..., 52) = 52
write(1, "=> 1\n", 5)

I just did not realise yet what is causing this.

from libxlsxwriter.

jmcnamara avatar jmcnamara commented on July 17, 2024

Closing this issue because it looks more like a permissions issue than a libxlsxwriter issue.

Note, the current HEAD version gives a clearer error message in this condition:

    $ make examples       
    $ ./examples/hello          

    $ chmod -w hello_world.xlsx 
    $ ./examples/hello          
    [ERROR] Error creating 'hello_world.xlsx': Permission denied

from libxlsxwriter.

AlfonsoUceda avatar AlfonsoUceda commented on July 17, 2024

@eroncastro do you have your wrapper open sourced?

@jmcnamara sorry if this bothers you

from libxlsxwriter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.