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

Reduced memory consumption #16

Open
xiongsongsong opened this issue Mar 3, 2016 · 1 comment
Open

Reduced memory consumption #16

xiongsongsong opened this issue Mar 3, 2016 · 1 comment

Comments

@xiongsongsong
Copy link

screen shot 2016-03-03 at 10 59 39 am

Such as immediately after writer.addRow send content to the browser may be able to reduce the memory footprint?

thanks.

@xiongsongsong
Copy link
Author

var koa = require('koa');
var app = koa();
var XLSXWriter = require('xlsx-writestream');

app.use(function *() {

  var writer = new XLSXWriter();
  this.body = writer.getReadStream();
  var timer = 0;
  var cl = setInterval(function () {
    timer++;
    for (var i = 0; i < 5000; i++) {
      writer.addRow({
        "date": new Date().toString(),
        "string": 'super long string'
      });
    }
    if (timer > 500) {
      clearTimeout(cl);
      writer.finalize();
    }
  }, 500);
});

app.listen(3000);
<--- Last few GCs --->

  549171 ms: Scavenge 1399.0 (1458.1) -> 1399.0 (1458.1) MB, 0.8 / 0 ms (+ 2.7 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
  550436 ms: Mark-sweep 1399.0 (1458.1) -> 1398.9 (1458.1) MB, 1265.5 / 0 ms (+ 4.2 ms in 2 steps since start of marking, biggest step 2.7 ms) [last resort gc].
  551605 ms: Mark-sweep 1398.9 (1458.1) -> 1398.9 (1458.1) MB, 1168.8 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x280d020e3ac1 <JS Object>
    1: startRow [/Users/song/WebstormProjects/stream-excel/node_modules/xlsx-writestream/lib/blobs.js:~20] [pc=0x2378a7d8c20e] (this=0xe4b320ec419 <an Object with map 0x269ea5754649>,row=2272519)
    2: _repeat [/Users/song/WebstormProjects/stream-excel/app.js:~12] [pc=0x2378a7dcbb67] (this=0x25f51a4d9ce1 <JS Object>)
    3: _onTimeout(aka wrapper) [timers.js:~274] [pc=0x2378a7de9e75] (this=0x2...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Abort trap: 6

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

No branches or pull requests

1 participant