簡體   English   中英

Node.js 內存使用

[英]Nodejs memory usage

我想我的內存使用有問題。 我有一個 node.js 服務器:

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

需要從.json數據導出所需對象的模塊

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);
})

(兩種方式都在使用相同的注釋或帶開關的方式)

通過單擊類別(例如:Cards、Action)從瀏覽器調用 get 函數,並通過 http、來自 angularjs 的控制器發送請求。 問題是,當我在服務器上console.log退出時,首先單擊每個類別都可以正常工作,但是在那之后,服務器需要很多時間來console.log退出信息。(如果是這樣,瀏覽器中會發生什么服務器很難)。

我做了什么來加載這么多內存嗎?

添加res.end(); 在你的開關盒之后。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM