Hi,
I am analysing ember to use in one of my project. Memory is one of the key concern for final selection.
To validate it, I have created a test application with two routes and without templates.
Chrome profile tools (heap snap shots & memory timeline) indicate that we have continuous memory leaks.
I am attaching the code snippet below for your reference and would appreciate your help if you could indicate whether the issue is with ember or in the way I have created the test application.
Thanks & Regards,
Suresh Gopathy
App.JS
var MyApp = null;
var favView = null;
var blockView = null;
console.log("SGO: App Main Invoked");
MyApp = Ember.Application.create(
{
ready: appInit,
LOG_TRANSITIONS: true
}
);
MyApp.ApplicationController = Ember.Controller.extend(
{
init: function ()
{
this._super();
}
}
);
MyApp.ApplicationView = Ember.View.extend(
{
init : function()
{
this._super();
}
}
);
MyApp.Router.map(routerInit);
document.addEventListener("keydown", eventHandler, true);
var idTimer = null;
function eventHandler(event)
{
if (event.which == 65)
{
idTimer = setInterval(runFunction, 300);
}
}
function appInit()
{
console.log("SGO: AppInit Invoked");
}
function routerInit()
{
console.log("SGO: Router Init Invoked");
this.route('fav', {path: '/'});
this.route('block', {path: '/block'});
}
var routeName = "block";
var iCnt = 50; // Change this value to increase the no of transition.
function runFunction()
{
MyApp.Router.router.transitionTo(routeName);
if (routeName === "block")
{
routeName = "fav";
}
else
{
routeName = "block";
}
if (iCnt <= 0)
{
clearInterval(idTimer);
}
else
{
iCnt--;
}
}
MyApp.FavRoute = Ember.Route.extend(
{
enter : function()
{
this._super();
},
exit : function()
{
this._super();
favView.destroy();
}
}
)
MyApp.FavController = Ember.Controller.extend(
{
init: function ()
{
this._super();
}
}
)
MyApp.FavView = Ember.View.extend(
{
init: function()
{
this._super();
favView = this;
},
destroy : function()
{
this._super();
}
}
)
MyApp.BlockRoute = Ember.Route.extend(
{
enter : function()
{
this._super();
blockView = this;
},
exit : function()
{
this._super();
blockView.destroy();
}
}
)
MyApp.BlockController = Ember.Controller.extend(
{
init: function ()
{
this._super();
}
}
)
MyApp.BlockView = Ember.View.extend(
{
init: function()
{
this._super();
},
destroy : function()
{
this._super();
}
}
)
MyEmberApp.html
My Ember App<script src="libs/jquery-1.9.1.js"></script>
<script src="libs/handlebars-1.0.0-rc.3.js"></script>
<script src="libs/ember-1.0.0-rc.3.js"></script>
<script src="libs/ember-data-latest.js"></script>
<script src="App.js"></script>
This is My Ember App to validate Memory Leeks in Ember