Nicu Ionut Campian
Nicu Ionut Campian

Reputation: 49

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.loged 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?

Upvotes: 2

Views: 92

Answers (1)

Alexandr Lazarev
Alexandr Lazarev

Reputation: 12862

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

Upvotes: 1

Related Questions