如果我快速连续多次加载,Node.js应用将无响应 [英] Node.js app becomes unresponsive if I reload multiple times in quick succession

查看:106
本文介绍了如果我快速连续多次加载,Node.js应用将无响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个node.js应用,该应用显示一个包含地图数据的页面(最终将通过.ajax调用进行更新)。

I'm developing a node.js app that displays a single page with map data (which will eventually be updated using an .ajax call).

现在,我的代码如下:

    app.get('/', function(req, res) {
    postgres.retrieve('SELECT * FROM settings', function(err, proj_data){
        if (err){
            res.send(500);
        }
        else{
            postgres.retrieve('SELECT * FROM report ORDER BY ordering', function(err, report_data){
                res.render('map', {project: proj_data[0], report: report_data});
            });
        }
    });

和postgres.retrieve是使用node-postgres客户端的函数:

and postgres.retrieve is a function that uses the node-postgres client:

        retrieve: function(query, complete){
            pg.connect(connection, function(err, client, done){
                client.query(query, function(err, results){
                    if (err){
                        done();
                        return complete(err, null);
                    }
                    else {
                        done();
                        return complete(null, results.rows);
                    }
                });
            });
        },

当前,如果我击中f5 10次(例如超过10秒) ),所有内容似乎都可以很好地响应,但是在此之后,内存使用率迅速上升,应用程序变得完全无响应。我想知道我的代码中是否有导致此问题的东西。

Currently, if I hit f5 10 times (over, say, 10 seconds), everything seems to respond fine, but right after, memory usage goes way up and the app becomes totally unresponsive. I'm wondering if there's something in my code that's causing this problem.

谢谢!

推荐答案

糟糕,这似乎是Node v0.10.0 +中的问题

Oops, it seems that this is an issue in Node v0.10.0 +

https://github.com/joyent/node/issues/5108

这篇关于如果我快速连续多次加载,Node.js应用将无响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆