max-mapper / filereader-stream

Read an HTML5 File object (from e.g. HTML5 drag and drops) as a stream.
BSD 2-Clause "Simplified" License
102 stars 18 forks source link

Memory leak #14

Open gitfoxi opened 8 years ago

gitfoxi commented 8 years ago

This could be my fault because I don't know anything about javascript but it looks like the chunks don't get garbage collected. I got this far:


var drop = require('drag-and-drop-files')
var concat = require('concat-stream')
var fileReaderStream = require('filereader-stream')
var zlib = require('zlib')

drop(document.body, function(files) {
  var first = files[0]
  console.log("start gzip " + first.name);
  gzip = zlib.createGzip({'level':1})
  gunzip = zlib.createGunzip()
  // fileReaderStream(first).pipe(gzip.pipe(gunzip))
  datin = fileReaderStream(first)
  // datin.setEncoding('utf8')
  datin.pipe(gzip)
  gzip.pipe(gunzip)
  gunzip.setEncoding('utf8')
  var count = 0
  gunzip.on('data', function(chunk) { count = count + chunk.length })
  gunzip.on('finish', function() { console.log("done, got " + count + " bytes") })
})

When I drop a 300MB file on the browser, I watch the memory go up and up. When it's done, there's a bunch of blob:// objects like:

blobs

gitfoxi commented 8 years ago

If I do it with the debugger closed, the problem doesn't occur. Does that mean it's Safari's fault? Reporting bugs to Apple is no fun.

max-mapper commented 8 years ago

Hmm yea seems like a Safari specific thing