Memory Leak for .Showsphysics

Memory leak in jQuery UI Draggable with MeteorJS?

For anyone suffering from this issue I've designed a temporary fix(this runs for every template re-render).

(function () {
var oldRender = Spark.renderToRange;
Spark.renderToRange = function (range, htmlFunc) {
var oldFunc = htmlFunc;
htmlFunc = function () {

// put in clean up code here Example:
if(range._start === $('#myTemplate')[0]) {
$('#myTemplate').find('.ui-draggable').draggable('destroy');
}
// end clean up code

return oldFunc.apply(this, arguments);
};
return oldRender.apply(this, arguments);
};
})();

One of the Meteor Core developers on the Google Groups forum informed me(link) that they are re-writing the templating package and this will address this issue.

How do i release allocated memory for array?

You don't want to use a weak reference. If you do that your array will get released immediately.

weak var weakArray: [[String:Any]]? = []

Will contain nil as soon as you create it.

Instead, you should set the array to nil (or empty) once you're done with the contents:

You could use `menuDetails.removeAll() to delete all the entries in the array, or you could change your declaration to make it an Optional

var menuDetails:[[String:Any]]? = []//this my global array object

And then set it to nil when you're done with it:

menuDetails = nil

How do i release allocated memory for array?

You don't want to use a weak reference. If you do that your array will get released immediately.

weak var weakArray: [[String:Any]]? = []

Will contain nil as soon as you create it.

Instead, you should set the array to nil (or empty) once you're done with the contents:

You could use `menuDetails.removeAll() to delete all the entries in the array, or you could change your declaration to make it an Optional

var menuDetails:[[String:Any]]? = []//this my global array object

And then set it to nil when you're done with it:

menuDetails = nil


Related Topics



Leave a reply



Submit