Memory profiling: Heap size increases with navigation push and pop


#1

Hi,

I am working on ionic 2 app and below are my setup details for android application:-

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
OS: Windows 7 SP1
Node Version: v6.3.1

While profiling application using chrome snapshot feature, I have noticed that with every push the component count increases and with pop the component is not been released for garbage collector.

Due to this lots of object are getting created inside memory heap which are not getting released during application life span. I had tried to release property by assigning null to properties of components using
ionViewDidUnload() and ngOnDestroy() methods but still heap size keep on increasing with object getting created inside heap. Number of count of component object keeps on increasing with every time you push a view component on navigation stack.

I have also tried below option:-
ionViewDidUnload() {
this.nav.getByIndex(this.viewCtrl.index).destroy();
}

ngOnDestroy() {
this.nav.getByIndex(this.viewCtrl.index).destroy();
}

Please suggested a way to release memory of an component after its been poped out from navigation stack and release all its properties and objects (Arrays) from heap stack.

Thank you in advance :slight_smile:


#2

Hey @rhtrathod, have you found any solution yet? We also have problems with our application getting slow after longer usage.


#3

This should be taken care of. Any suggestion guys?


#4

You firstly need to confirm you’re on ionic v2 rc1.

The jump to the production version of angular 2 means that production mode is generally on by default (enableProdMode, previously set in config when starting your app) which reduces allocations/change detection sweeps etc which were there for debug purposes.


#5

Have you found a solution to this problem? Experiencing something similar.