Hi
We are using node js and express module and providing download files 
functionality to the users. Its MVC kind of architecture but its used over 
LAN. We are sending average 50 files per request averaging about 700 mb in 
size. We have our own c program which writes these files at run time and 
child node processes which send these files to the users in synchronous 
fashion. We are using ffi module to call c functions . The problem we are 
facing is node using 50 % memory and gets crashed also it doesnt free 
significant amount of memory. H/W config is 1 Ghz single core proc and 512 
MB RAM. The question here is why V8 not releasing memory after each request 
OR is there any special kind of compilation required for node / v8. We have 
tested our c programs with valgrind and it did not show any memory leak.


<https://github.com/joyent/node/issues/7060#issuecomment-34325630> 
 
part of my child proc
async.series([

                                      function DecryptFile(cb) {

                                            logger.debug("call decrypting 
Function for========="+param);



                                            var childProc = cp.fork(__dirname + 
'/child.js');



                                            childProc.on('message', function(m) 
{

                                        logger.debug('PARENT got message:', 
m.timestamp);

                                        decFile=m.timestamp;

                                        if(decFile){

                                                        if(bluetoothReq){

                                                              
res.send(conf.get('contentTempFile')+decFile+"/"+ fName);

                                                              return;

                                                        }else{



                                                              
logger.debug("downloading for device : "+param);

                                                              var 
folderPath=conf.get('contentTempFile')+decFile;

                                                              var downloadPath 
= path.join(folderPath, fName);



                                                              stats = 
fs.lstatSync(downloadPath);

                                                              if 
(stats.isFile()) {



                                                                    
res.download(downloadPath,fName, function(err){

                                                                            if 
(err) {

                                                                              
// handle error, keep in mind the response may be partially-sent

                                                                              
// so check res.headerSent

                                                                                
logger.debug("res Error :");

                                                                                
console.log("res Error :");

                                                                            } 
else {

                                                                              
// decrement a download credit etc

                                                                                
logger.debug("res Successfull :");

                                                                                
console.log("res Successfull :");

                                                                            }



                                                                            
logger.debug("res on End :");

                                                                                
rmdir(folderPath, function(error){

                                                                                
      logger.debug("content download Succefully :"+downloadPath);

                                                                                
      console.log("delete Folder Successfull :"+downloadPath);

                                                                                
      if(error){

                                                                                
            logger.debug('rm -rf '+folderPath);

                                                                                
            exec('rm -rf '+folderPath);

                                                                                
      }

                                                                                
});

                                                                          });



                                                              }

                                                        }

                                                  }else{

                                                        
statsLogger.addStats(req,statsCode.TYPE_ERROR_DOWNLOAD,contentId,content.title+"-"+fileName);

                                                        res.send("1,Problem 
while Downloading ");

                                                  }

                                        childProc.kill();

                                      });

                                            childProc.send({ filePath     : 
folderName+ fileName,

                                                               temp       : 
conf.get('contentTempFile'),

                                                               timestamp  : 
timestamp,

                                                               fName            
: fName });

 



Please c the code below i copied it from the internet and ran it on my 
server 

var express = require('express')

, app = module.exports = express();

app.get('/', function(req, res){
res.send('

   '
   + '
   - Download amazing.txt <https://github.com/amazing.txt>.'
   + '
   - Download missing.txt <https://github.com/missing.txt>.'
   + '

');
}); 

// /files/* is accessed via req.params[0]
// but here we name it :file
app.get('/:file(*)', function(req, res, next){
var file = req.params.file
, path = __dirname + '/files/' + file;

res.download(path);
});

// error handling middleware. Because it's
// below our routes, you will be able to
// "intercept" errors, otherwise Connect
// will respond with 500 "Internal Server Error".
app.use(function(err, req, res, next){
// special-case 404s,
// remember you could
// render a 404 template here
if (404 == err.status) {
res.statusCode = 404;
res.send('Cant find that file, sorry!');
} else {
next(err);
}
});

if (!module.parent) {
app.listen(10000);
console.log('Express started on port %d',10000);
}

after downloading 3 files of 80 MB node's memory usage reaches to 19.2% and 
never comes down even is server is steady. Is this the normal behavior node 
and v8?





Please help me to solve this issue.
Thanks in advance.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to