zefoy / ngx-color-picker

Color picker widget for the Angular (version 2 and newer)
MIT License
456 stars 142 forks source link

Memory leak #208

Open sz274071580 opened 5 years ago

sz274071580 commented 5 years ago

Hello, when I use the ngx-color-picker component, I find that the memory can't be released, so the module that references the component can't release the memory. Is there any way to release the ngx-color-picker component memory? Ngx-color-picker version 8.1.0 Angular version 8.1.0 I saw it through the memory monitor in the Chrome browser. There are two variables: ColorPickerComponent and ColorPickerDirective (4).

sconix commented 5 years ago

The dialog component is created when its opened for the first time, it is not destroyed after that for faster displaying of the dialog. I can not see the dialog using that much memory that destroying it after closing would make that much sense. I.e. I prefer usability over the tiny bit of memory it needs. Of course PR is accepted if there really is a need for option destroying the dialog component after closing.

sz274071580 commented 5 years ago

The dialog component is created when its opened for the first time, it is not destroyed after that for faster displaying of the dialog. I can not see the dialog using that much memory that destroying it after closing would make that much sense. I.e. I prefer usability over the tiny bit of memory it needs. Of course PR is accepted if there really is a need for option destroying the dialog component after closing.

Now the ngx-color-picker component does not release the memory, affecting the entire module that calls it can not be released, which is not a small memory overhead, how to release the memory?

sconix commented 5 years ago

I guess you can not without adding such feature. Of couse hard to say since I am not familiar with your setup. Never seen a setup where modules are released from the memory with Angular.

sconix commented 5 years ago

I think I only now understand what you are after :) I guess the issues is that the created component is not destroyed when the directive is destroyed. I will add destroying of the dialog component when the directive is destroyed for the next release.

sz274071580 commented 5 years ago

I think I only now understand what you are after :) I guess the issues is that the created component is not destroyed when the directive is destroyed. I will add destroying of the dialog component when the directive is destroyed for the next release.

That is what I mean, I look forward to the next version coming soon! thank you very much!

sz274071580 commented 5 years ago

1 To add one more point, these two variables cannot be destroyed when switching navigation, so that the parent component can not be destroyed, eventually leading to memory leaks! I remove the color component from the parent component, the parent component can be destroyed normally

sconix commented 4 years ago

I finally had time to look into this and the directive actually will destroy the component so I am not sure why this happens. Could be bug with the Angular even since at least I can not find any reason from this library since everything gets destroyed when directive onDestroy is called so everything should be fine.