ngx-device-detector
ngx-device-detector copied to clipboard
Memory leak and performance
Hi,
I found issue with your library. It causes memory leaks. https://github.com/KoderLabs/ngx-device-detector/blob/master/projects/ngx-device-detector/src/lib/device-detector.constants.ts here you create regex objects. Those objects cannot be handled by garbage collector. Regex should be created if needed and destroy after check. Keep them like that make them unavailable for garbage collector.
Furthermore, why don't you cache result of checking? Each time I call isMobile/Tablet/Desktop regexes are checked. In my opinion it should be checked on first method call, then result should be kept in memory. User Agent won't change so checking each time is redundant.
@KamilPuczka good points. Will get on it.
hi, first thank you for your cooperation for this lib, but need know if update lib with respect in the question old.
Any updates on this?