Ember memory consumption


#1

Hi everybody,

My team and I are currently working on a second Ember application and I’m starting to get worried by our (and/or Ember’s) memory consumption. Our previous project (using 0.9.8) didn’t end very well because of that (our users are mainly using IE 8/9 and our app basically becomes unusable because of RAM consumption after 1 hour). Of course we tried to profile our code using Chrome Dev Tools but we were unable to find obvious leaks… So you may understand why I’m being cautious about that issue right now :wink:

When you compare memory consumption of the various TodoMVC implementations using Chrome Dev Tools snapshots, you can see that Ember’s one is the worst (~ 15 MB after adding some todos, vs ~ 9 MB for Angular or CanJS). Try to browse a few topics on Discourse, and suddenly 20 more MB are gone… Of course Chrome eventually manages to garbage collect, but Firefox and IE seem to be less lucky…

Be assured that I really love working with Ember, I love the concepts and it makes me infinitely more productive, but I’d appreciate to get core team members point of view about memory consumption :

  • Do you think Ember’s memory consumption is an actual problem or do you think that it’s normal for an advanced framework ? To put it differently, is that memory consumption the result of a tradeoff between ease of use/productivity and hardware resources usage ?
  • Is that memory consumption the result of a technical tradeoff (i.e. CPU vs RAM, potentially related to the choice of change listeners against dirty checking) ?
  • If you think it’s a problem, do you plan to work on it before 1.0 release ?
  • Are you aware of bad practices that could result in an abnormal memory consumption ?
  • Is IE/low-end hardware support one of your goal or do you think that Ember and Single-page-apps in general should only be used if you are sure that your users have modern browsers and plenty of RAM ?

PS : as you may have guessed, english is not my primary language, sorry for that :wink:


#2

Just a note about our experience with pre-1.0 releases (December-ish and previously) and the latest from master: Back in November and December I also noticed that I needed to close my tab every hour or so, since Chrome simply became slower and slower.

This issue is completely gone. I can have the same tab with our Ember.js app open for days, and I don’t see any performance degradation.

I don’t know if this is something that was fixed by Chrome or the Ember source code (or something we did terribly wrong at that time). But no matter what, it’s gone, and I’m happy about that.

I wouldn’t worry too much about a difference of 6MB in memory consumption. The important thing is that there are no memory leaks, so people can use your app for hours.

A nice thing to remember, is that you are responsible for calling destroy() on all objects that you created. Ember.js will do the same internally for everything that was created behind the scenes.


#3

I agree that the majority of memory leaks have been fixed in recent versions, but I think there’s still problems : I was investigating our memory issues and I think I found something interesting : Github issue.

Nevertheless, I’m still an Ember fan :wink:


#4

Does anyone have any other good tips or tutorials on common things that can easily lead to memory consumption in Ember? Maybe it’s something that should go in the guides? cc/ @tom @trek