Created
December 21, 2012 07:45
-
-
Save kanryu/4351283 to your computer and use it in GitHub Desktop.
problem: node.js make memory leaks about child_proces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//// problem: node.js make memory leaks about child_proces | |
// | |
// the javascript doing it tha same to the shell code | |
// $ cat mako_* | ./ffmpeg -y -f image2pipe -r 1 -vcodec bmp -r 29.7 -i - -vcodec utvideo movie.avi | |
var ffmpeg = require('basicFFmpeg'); | |
var fs = require('fs'); | |
var sprintf = require('sprintf').sprintf; | |
var spawn = require('child_process').spawn, | |
exec = require('child_process').exec; | |
function genProcArgs(processor) { | |
var args = ['-y', '-f', 'image2pipe', '-r', '1', '-vcodec', 'bmp', '-r', '29.7', '-i', '-', '-vcodec', 'utvideo', '-f', 'avi']; | |
// args.push('pipe:1'); | |
args.push("test.avi"); | |
return args; | |
} | |
var proc = spawn('ffmpeg', genProcArgs()); | |
for(var j = 0; j < 1000; j++) { | |
for(var i = 0; i <= 12; i++) { | |
var path = sprintf("mako_%04d.bmp", i); | |
var data = fs.readFileSync(path); | |
console.log(j, i); | |
// 1. writing out to ffmpeg process, occars memory leaks | |
proc.stdin.write(data); | |
//// 2. writing out to a local file, no memory leaks | |
// fs.appendFileSync("m.bmp", data); | |
} | |
} | |
proc.stdin.end(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment