So somehow I made a memory leak in JS. Well I only continously resized a window of my page, and then buum, 86% memory usage. out of 16gbs of memory. After I shut everything down I had to restart my pc because it still said 72% usage. System takes only 17%.
So I don't really understand whats happening there, all I wanted to somehow react when the user resizes the window because then I'd change the layout if the width is less than 640px for instance.
But yea here is my code.
Index.html:
<div id="wrapper" ng-controller="AppCtrl" resize>
<div class="left-side" ng-class="{ fullw: smallR }">random content</div>
<div class="right-side" ng-class"={ fullw: smallR }">random content2</div>
</div>
The idea was , I have the left and right side, after the screen width below 640px, I push them under each other by attaching a .fullw { width: 100% } style to them.
My directive:
.directive('resize', function ($window) {
return function (scope, element, attr) {
var w = angular.element($window);
scope.$watch(function () {
return {
'h': w.height(),
'w': w.width()
};
}, function (newValue, oldValue) {
if(newValue.w <= 640) {
scope.smallR = 1;
} else {
scope.smallR = 0;
}
}, true);
w.bind('resize', function () {
scope.$apply();
});
};
})
Its eventually working however if I start to play with it by resizing all day long, it starts to use tremendeous amount of RAM...
Thanks in advance
$watchhere, you already haveresizeevent. And you should not use Javascript here at all, user media queries.