The Problem of Memory Leakage in AngularJS While Navigating Pages

I am currently working on an AngularJs App with 3 screens. The app is set up to route between these 3 screens every X seconds using the ui-router component.

$stateProvider
    .state("page", {
        url: "/:pageId/:pageType",
        template: pageTemplate,
        controller: "contentCtrl",
        resolve: {
            contentSolver: function (resolveService, $stateParams) {
                resolveService.solveData($stateParams.pageId, $stateParams.pageType);
            }
        }
    })

Additionally,

  $state.go('page', {
                    pageId: $stateParams.pageId,
                    pageType: pageType
                });

In order to retrieve page content from the server and pass it to the controller, I have implemented a service called resolveService.

However, I have noticed that memory leaks occur with every screen change. This issue does not arise if I do not switch between pages.

Upon investigating further, I discovered that when making multiple switches on the same page, identical images are requested each time.

Is there a way to address this and remove the old images?

https://i.sstatic.net/U9fOC.png

When analyzing the Performance tab in Chrome Dev tools, I observed a rapid increase in the number of nodes. What should I focus on in this scenario?

https://i.sstatic.net/BEJSm.png

Are there any effective tools available for identifying memory leaks? I have tried various Chrome extensions and Dynatrace, but they seem to lack support for my specific setup. Any suggestions would be greatly appreciated :)

Answer №1

When redirecting your pages within a certain time frame, it is important to disable the function responsible for the transition once it has been initiated. This will prevent the function from continuously listening for transitions and causing repeated responses.

$scope.$on('$destroy', stopFunction);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Integrating the angular-datepicker into a Rails application using bower-rails

Despite Bower-rails being designed for popular libraries like angular and angular-resource, adding a less well-known, bower enabled library can be challenging. For example, how does one incorporate libraries such as https://github.com/g00fy-/angular-datepi ...

Using Typescript to change a JSON array of objects into a string array

I'm currently working with the latest version of Angular 2. My goal is to take a JSON array like this: jsonObject = [ {"name": "Bill Gates"}, {"name": "Max Payne"}, {"name": "Trump"}, {"name": "Obama"} ]; and convert it into a st ...

Utilizing various AngularJS filters with multiple input sources

Looking to enhance my user array filtering process with two input boxes. Here's how the array is structured: $scope.users = [{ id: 1, fname: 'Sophia', lname: 'Smith', email: '<a href="/cdn-cgi/l/email ...

React Native: error - unhandled action to navigate with payload detected by the navigator

Having trouble navigating from the login screen to the profile screen after email and password authentication. All other functions are working fine - I can retrieve and store the token from the auth API. However, when trying to navigate to the next screen, ...

How can I incorporate popups in React using mapbox-gl?

Currently utilizing mapbox-gl within React, everything seems to be functioning properly except for the integration of mapbox-gl's Popups. I have the function let Popup, but I am uncertain about how to incorporate it. renderMap() { if (this.props. ...

Swap out all hyperlinks on the webpage with a different URL

I am looking to update all links in a specific style with new ones. I want to streamline the download process for Google Drive links. https://drive.google.com/file/d/1cCIWJMBOX-NvzYVTQajaVo5lNknYA2E8/view?usp=sharing My plan is to extract '1cCIWJMBO ...

Combining three.js geometry and selecting objects with an octree

I have been utilizing Three.js to showcase a variety of custom geometries in different positions and rotations. These geometries are static and do not change frequently, but users have the ability to manipulate them by adding, deleting, or altering the sha ...

choose courses using jQuery

<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <p class="myChild">one</p> <p class="myChild">two</p> <p class="myChild">th ...

Seeking help on modfiying div content with AJAX - any tips for showing navigation using hash or anchor?

Looking to create a dynamic page that updates content within a div asynchronously while also providing users with direct access to specific content within the div by using anchors (e.g. www.website.co.uk/#page1). I've successfully implemented the upd ...

Is it possible to implement validation for the 4th digit of a number before submitting the page by using a combination of ajax and JavaScript

Currently, I am working on a scenario where a postal code needs to be saved and it is a mandatory requirement. I have implemented an AJAX call triggered by the keyup event after entering 4 digits in the postal code field. The AJAX functionality works corre ...

What is the reason behind only the initial option showing up in the selection when utilizing ng-options?

When using ng-repeat to populate a select element and adding two options below it, only the first option appears. What could be causing this issue? For example: <select id="dropDownSelect", ng-model="chosenDash.id", ng-options="dashboard._id as ...

Utilize the power of Bootstrap Modals to enhance your form validation with a seamless integration of Jquery

I have a few questions about JQuery syntax: 1) The modal is not showing up. Could this be related to an operator (&&) issue? How can I fix it? It should only appear if the input is valid. 2) How do I combine preventDefault with valid classes when submitt ...

The ng-controller directive is not functioning accurately

I attempted to execute the following basic HTML: <!DOCTYPE html> <html ng-app="tempApp"> <head> <script src="js_libs/angular/angular.min.js"></script> <script src="js_libs/angular/bootstrap.js"></script&g ...

The challenge of handling multiple save conflicts in asynchronous Mongoose operations

My Node/Mongoose/Socket.io setup is presenting a challenging logic issue. Imagine a scenario where the Server model is frequently accessed and updated simultaneously in my application. db.Server.findOne({_id: reference.server}).exec(function(error, se ...

Unable to locate the Promise variable in iOS 7

iOS 7 Safari is displaying the error Can't find variable: Promise: new Promise(function(resolve, reject) { . . . While other browsers do not encounter this issue, I came across a similar question where Robert suggested using new Ember.RSVP.Promise i ...

The getMonthlyBalances function is providing inaccurate results when calculating stock balances

One of my functions is called getMonthlyBalances, which takes in two arrays - stocks and trades. It calculates the monthly balance of a user's stock holdings based on their trade history. The stocks array includes objects with stock ID, prices, and da ...

Sending Multiple Checkbox Values to PHP Using jQuery's Ajax Function

Using jQuery to retrieve values from multiple checkboxes is simple and effective. To see a demonstration, check out this link The jQuery function works well; when a checkbox is checked, we can see the selection based on the data-id after clicking btnUpda ...

Javascript text validation is malfunctioning as the alert message fails to appear

Looking for a simple form validation script: <script language=”javascript”> function checkForm(register) { if (""==document.forms.register.FNAME.value){ alert("Please fill out this field!"); document.forms.register.FNAME.focus( ...

Ways to incorporate the point count divided by a specified value onto a map

I am working with Mapbox GL JS and I have a specific requirement to display the number of markers in a cluster divided by 10 on the map. To achieve this, I am utilizing the point_count and point_count_abbreviated attributes in the code snippet below: map ...

The extensive magnetic scrolling functionality in Ionic 2 sets it apart from other frameworks

Hi everyone, I could really use some assistance! I've been working on developing an Ionic 2 App and my navigation setup is not too complex. I have a main menu where clicking on an item opens another menu with a submenu. From there, if I click on an i ...