简体   繁体   中英

Nodejs memory usage

I think I have a problem with memory usage. I have a node.js server :

var arcadeGames = require('./server/js/arcade');
var cardsGames = require('./server/js/cards');

requires modules that exports object required from .json data

var http = require('http');
var express = require('express');
var app = express();
var server = http.createServer(app);
//var io = require('socket.io').listen(server);
//var fs = require('fs');

app.get('/specificCategory/:id',function(req,res,next){ 
switch(req.params.id){

    case "Cards":
        console.log(cardsGames.titles);
        break;
    case "Action":
    console.log(actionGames.titles);
    break;
    default:
    console.log("undefined");
}


//var specificCaategory = require('./server/js/'+ req.params.id.toLowerCase());
    //var categoryTitlesAndUrlThumbs = spe
    //console.log(specificCaategory.titles);
})

(both way are working the same commented one or the one with switch)

the get function is called from browser by clicking the categories ex :Cards, Action and send the request through http, controller from angularjs. The problem is that when I console.log ed out on server first click on each category works fine, but after that, the server takes a lot of time to console.log out the info.(what will happends in browser if this is so hard for server).

Have I done something to load the memory so much?

Add res.end(); after your switch case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM