-
Notifications
You must be signed in to change notification settings - Fork 7.3k
node has memory leak #4524
Comments
Apparently, you're not closing incoming connections which results in a leak. Also, buffers are allocated outside v8's heap, that's why you can't see real RSS when running node with --trace-gc. Closing this issue. |
idont think so, if client.js }) just buf = new Buffer(16_1024) .toString() change to buf = new Buffer(16_1024), memory is few and i cant understand you say you're not closing incoming connections which results in a leak, var net=require("net") i add client.end() . just the same and i want keep connection,dont close it . i think where is some malloc in node ,and dont free. buf = new Buffer(16_1024) vs buf = new Buffer(16_1024) .toString() there is different in src/stream_wap.cc:346 buf = new Buffer(16*1024) .toString() to malloc big memory,but in AfterWrite memthod delete[] it so i dont undstand,, can you help me |
What node version are you using? |
node-v0.8.16-linux-x64 , |
Ok, so what process is leaking: server or client? |
client |
(16 * 1024) * 100000 = 1638400000 bytes = 1600000 kb = 1562 mb = 1.52 gb. Try writing less data, or writing it in parts. |
var net=require("net") setTimeout(function(){ i add client.write(buf,function(){ so the temporary storing in memory i found in src/stream_wap.cc:346 char * storage = new char[sizeof(WriteWrap)+storgize+15] this is temporary but in src/stream_wap.cc:463 MakeCallback(); --> client.write(buf,function(){ so temporary shoud free,. but it cant , when i say console.log("end") , i say rss still 1.3g |
you are still writing it all at once. try writing next chunk in socket.write()'s callback. |
var net=require("net") function write(){ } setTimeout(function(){ yes , this is ok ,but why ? where is the temporary memory , can you tell me . |
Imagine you're on a postal office and giving heavy letters to the worker. He'll stay and keep all your letters until he'll be able to go to the storage. If you'll give him all letters at once, he'll hold very big amount of data (1.5 gb). But if you'll wait for him to come to the storage and return back to you, before giving him the next letter - worker won't need to hold everything at once and will use much less data. |
server.js
var net=require("net")
var server = net.createServer(function (socket) {
socket.on("error",function(e){
console.log(e)
})
});
server.listen(7888,function() {
address = server.address();
console.log("opened server on %j", address);
});
client.js
var net=require("net")
max=100000
client=net.createConnection(7888,function(){
console.log("con")
buf = new Buffer(16*1024).toString();
for(i=0;i<max;i++){
b = client.write(buf)
}
console.log("end"+error)
})
so.memory grow bigger and bigger , but i run node --trace-gc client.js ,i found heap only 50m, but i top -p pid , rss is 1.3g, so what is the problem? there is some memory leak,
The text was updated successfully, but these errors were encountered: