Skip to content
Permalink
Browse files

Pass resolver which specifies the key to be cached for the given agent

Not passing key to the memoize method will take object reference as key by default.
Whereas on each poll we create a new agent object, and the memoize treats the newly created agent object as a new agent and will cache it seperately.
This was causing memoize to cache all the objects leading to memory overflow.
  • Loading branch information...
GaneshSPatil authored and ketan committed Mar 1, 2017
1 parent 4db0550 commit 5d75f45c5229f48697beee3ec4e9d404c899e82f
Showing with 5 additions and 1 deletion.
  1. +5 −1 server/webapp/WEB-INF/rails.new/webpack/models/agents/agents.js
@@ -26,6 +26,10 @@ var CrudMixins = require('models/mixins/crud_mixins');

require('lodash-inflection');

var resolver = function (agent) {
return agent.uuid() + agent.status();
};

var statusComparator = _.memoize(function (agent) {
var rank = {
"Pending": 1,
@@ -39,7 +43,7 @@ var statusComparator = _.memoize(function (agent) {
"Disabled": 9
};
return rank[agent.status()];
});
}, resolver);

var sortByAttrName = function (attrName) {
return function (agent) {

0 comments on commit 5d75f45

Please sign in to comment.
You can’t perform that action at this time.