Memory issues and test cases

This is learning diary post from Uni Helsinki course Software Factory / Facebook academy – SocketIO team. For more info about this course read  “Ready, Set, Start Coding!”.

You can find open issues and questions I collect from past week in my quick project notes.

Moving back to Finland

The biggest thing since last Wednesday when I did my last working hours to Software Academy and Socket.io project was moving back to Finland/Espoo. Organizing everything take more time then you ever planned for it, 2 days turn into four days so quickly that you do not notice it. Gladly, it is possible to be flexible with this course and needed working working hours can be done during a long period of time. :)

Catching up with Socket.io development

Last thing I developed was stress/load test cases for Engine.io. One thing learned was that with node.js it is impossible to have control over garbage collection, it can be called when using expose garbage collection mode in node.

e.g.
node --expose-gc test.js

in code:
global.gc();

This helps you to find out how much memory is being used in different parts of code. Problem with my code was that engine.io-client in clients[] array did not close properly and garbage collection did not work.


function loop(i) {

  clients[i] = new eioc.Socket(address);
  clients[i].onopen = function() {
    opened++;

    clients[i].onmessage = function(data){
      messages++;>
    };

    clients[i].onclose = function() {
      closed++;
      delete clients[i];
    };
  };
};

Fix to this one was just to move delete statement before creating a new client into if-clause that checked if the type of the variable was not ‘undefined’

Hopefully I would find a bigger task for the next couple of weeks, now that I have more time to put into this project. One thing before going forward is to finish stress/load test cases.