Background
Back in May I reported an issue on WebKit regarding a memory retention issue. It looks as though the problem could be due to the Web Inspector itself, but I'm not convinced yet.
Problem
A problem surfaced whereby my JavaScript application implements a "Polling Consumer" pattern for obtaining data as it becomes available. The problem is that memory is being retained and grows throughout the day. The JavaScript logic goes like this:
- Get the data and call me back
- When I'm called back process the data and then perform step 1
Is this a reasonable way of implementing a polling consumer in JavaScript? Incidentally I'm using jQuery's ajax function which of course may have its own problems. In addition I'm using a jQuery proxy as the success handler so I would have thought that retention through scope should not be an issue. I have also observed the problem without using proxies. Some code:
FidsDataController.prototype.getFids = function() {
var self = this;
$.ajax({
...
success: function(data) {
// Do some processing
// Call back in a short while...
setTimeout($.proxy(self.getFids, self), 100);
},
...
});
);