It's quite weird because, in my local machine it all seems to work
properly, but when I upload it to the server it starts using a lot of
memory and keeps increasing until it crashes.
I've researched quite a lot, on how to investigate this leaks, I've tried
to optimise as hard as I could, nulling every variable I use, using mysql
pools... but no luck. I've done a heap dump, but I couldn't quite
understand how to relate it to my code, on the dump it looks like there's
this huge object that references itself, but I don't know which object is
it or how to fix it.
[image: Screenshot of the heapdump]
The code (shortened) looks like this:
var express = require('express')
, app = require('express')()
, server = require('http').createServer(app, {log:false})
, io = require('socket.io').listen(server)
, Stomp = require('stomp-client')
, mysql = require('mysql')
, heapdump = require("heapdump")
, pool = mysql.createPool({
host: '127.0.0.1',
user: 'root',
password: '',
database: 'leader'
})
, moment = require('moment');
//Server setup stuff
server.listen(3000);
app.use("/css", express.static(__dirname + '/css'));
app.use("/js", express.static(__dirname + '/js'));
app.use("/img", express.static(__dirname + '/img'));
app.engine('html', require('ejs').renderFile);
io.set('log level', 1);
//Main page get
app.get("/", function(req, res) {
pool.getConnection(function(err, connection){
connection.query('select band.*, DATE_FORMAT(`event`.`date`,"%d-%m-%Y")
as `date`, `stage`.`stage_name` from band LEFT JOIN `event` ON `event`.band_id
= band.id LEFT JOIN `stage` ON `event`.stage_id = stage.id WHERE
`stage`.`festival_id` = 3 GROUP BY band.id ORDER BY score desc,actual_position
asc', function(err, rows){
connection.query('select * from genre order by name', function(err,
genres){
res.render(__dirname + '/index.html', {bands: rows, genres:
genres, page:'overall'});
rows = null;
genres = null;
page = null;
connection.end();
});
});
});
});[.. some more pages ...]//Stomp socketvar connected = false;var destination
= '/queue/jstweets';var client = new Stomp('127.0.0.1', 61613, 'user', 'pass');
client.connect(function(sessionId) {
client.subscribe(destination, function(body, headers) {
var data = JSON.parse( body );
if(typeof data.user !== 'undefined'){
//console.log(data.user.screen_name+': '+data.text);
//Emit broadcast to all clients
io.sockets.emit('tweet', {tweet: data});
}
data = null;
});});
I've tried with different versions of node with the same result.
Any help is welcome.
--
--
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.