Need a special offer?Find out if your project fits.
+

Memory leak

Answered
Sohan asked on July 3, 2017

I am creating the flex pivot as below:
 

$scope.mainPivot = $(pivotGridSelector).flexmonster({
global: {
localization: $scope.flexPivot.LocaleData //localeJsonpath
},
customizeCell: customizeCellFunction,
licenseKey: response.licenseKey,
beforetoolbarcreated: customizeToolbar,
componentFolder: "libs/flexmonster/",
toolbar: true,
height: "100%",
width: "100%",
report: flexReport
});

 
and on angular scope destroy, I have following code:
 

$scope.$on("$destroy", function() {

    $scope.mainPivot.dispose();
});

 
But I still see detached dom tree and they are pointing to flex nodes. What am I missing?
My application is leaking around 30MB everytime, when I open the page with flex and close it every time.
Please suggest.

23 answers

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster July 3, 2017

Hello Sohan,
Thank you for your question. Could you please provide us with the sample project so we can make some tests and reproduce the issue on our side? It will help us a lot in our further investigation.
Best regards,
Dmytro.

Public
Sohan July 4, 2017

Here is the fiddle for the same. I have not included angular code here,just flex pivot.
https://jsfiddle.net/sohansoni/qae2sxzk/3/
Observe the memory usage when this page is launched. Then do the create and dispose several times.
Observe the memory usage, It has gone up. Now in chrome dev tools take a heap snapshot.
I see lot of Detached DOM Tree related to flex

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster July 4, 2017

Hello Sohan,
Thank you for providing us with the example. We need to take some time on the investigation. The fix will be presented in the 2.4 major update which is going to be released in a month.
Best regards,
Dmytro.

Public
Sohan July 6, 2017

Thanks Dmytro, But were you able to reproduce it ?

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster July 6, 2017

Hello Sohan,
Yes, we have reproduced the issue.
Best regards,
Dmytro.

Public
Sohan July 6, 2017

Thank you for the confirmation !

Public
Sohan September 13, 2017

Hello,
I see new major upgrade 2.403 released on 11th Sep 17, does it include memory leak fix ?
 

Public
Ian Sadovy Ian Sadovy Flexmonster September 13, 2017

Hello Sohan,
 
Yes, we have optimized memory usage in the version 2.4. 
So you are welcome to download the latest 2.403 release and try it. 
 
Please let us know if it helps to resolve the memory leak.
 
Regards,
Ian

Public
Sohan September 25, 2017

I am afraid to say this but this is still not resolved. Can you please look into it ?
While analyzing on chrome dev tools if I disable customizeCell and toolbar, then memory leak is reduced.
However with no toolbar and no custom customizeCell function, memory is still getting leaked, and I still see customizecell function taking lot of memory, even updateLabels function.

Public
Ian Sadovy Ian Sadovy Flexmonster October 4, 2017

Hi Sohan!
Could you please send us a sample with the memory leak issue? We've made some tests but they show only small leaks but I think in your case, it should be several megabytes per update. 
Thanks

Public
Sohan November 9, 2017

Apologies for the delay on replying on this one.
 
I have created the fiddle which demonstrates memory leak. 
Fiddle : https://jsfiddle.net/6rLqgvce/4/
 
Steps:

  1. Observe the memory usage when this page is launched.
  2. Take a memory heap snapshot in chrome dev tools.
  3. Then do the create and dispose 3-4 times. Observe the memory usage, It has gone up.
  4. Now take another heap snapshot, you will see the difference between two heap snapshots is more than 10 MB just for creating and disposing the pivot 3-4 times.
    Now in comparison view, I see lot of Detached DOM Tree related to flex
Public
Ian Sadovy Ian Sadovy Flexmonster November 10, 2017

Hello Sohan,
 
Thank you for such detailed description.
I see the difference in memory usage. We will try to fix the leak and will update you with our findings (approximately on Dec 04). Does it work for you?
 
Regards,
Ian

Public
Sohan November 10, 2017

Yes, it works for me

Public
Sohan December 5, 2017

Is this fixed in 2.409 ?

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster December 5, 2017

Hello Sohan,
Thank you for writing.
The fix is available in the version 2.409, you are welcome to download it from our website. Please note that the fix was added only to 2.4 version.
Let us know if everything works fine for you.
Regards,
Dmytro.

Public
Sohan December 5, 2017

Dymtro,
 
I have tested with 2.409 and looks like there is still huge memory leak. 
Please refer this fiddle http://jsfiddle.net/sohansoni/rkprvhhs/228/

take heap dump before creating pivot, create pivot and dispose it. Now take heap dump again.
The difference is around 6.5 MB !!! 
I can walk you through with where exactly are the leaks if you want. But please fix these. We really need them to be fixed.

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster December 5, 2017

Hello Sohan,
Thank you for the update.
Could you please provide us with the jsfiddle example? It is seemed to be missing in your previous post.
Waiting for the example to clarify the issue.
Regards,
Dmytro.

Public
Sohan December 5, 2017
Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster December 5, 2017

Hello Sohan,
Thank you for providing us with the jsfiddle example. We will increase the priority of this issue and will notify you as soon as it is ready.
Regards,
Dmytro.

Public
Iryna Kulchytska Iryna Kulchytska Flexmonster December 6, 2017

Hello Sohan,
 
Thank you for giving us some time for making further investigation.
 
We followed the steps you provided and we see the difference is around 6.5MB between the newly loaded page and the page after one create() and one dispose(). Also, we measured the memory usage between each consecutive create() call. It is increasing approximately by 100KB after each consecutive create(). Here is the video - https://www.screencast.com/t/uGGk73HwPcy. Thus, 6.5MB is a one-time increase. We agree that ideally there should not be any increase at all, but at the same time after the previous rounds of improvements we consider the current increase as an acceptable. Please let us know your thoughts.
 
Also, we'd like to mention that each time a new instance of the component is created, the dispose() API call is triggered automatically for the previous one, thus, there is no need to call dispose() before the creation explicitly.
 
Kind regards,
Iryna

Public
Sohan December 7, 2017

Iryna, unfortunately each consecutive create is leaking almost 1MB of memory. I can show you that. 100KB would be perfectly fine but it's not the case right now. I want to help you on this so that we can further reduce the leak. 
Lets have a call where we can do webex.

Public
Iryna Kulchytska Iryna Kulchytska Flexmonster December 7, 2017

Hello Sohan,
 
Thank you for your willingness to help us on this issue.
Olena will contact you to arrange further steps.
 
Kind regards,
Iryna

Public
Sohan January 10, 2018

Looks like memory leak is finally resolved in 2.411.  Thanks for all the hard work.
I am sure memory leak reduction help all of us.
 

Please login or Register to Submit Answer