Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak and performance #187

Open
KamilPuczka opened this issue Dec 3, 2020 · 3 comments
Open

Memory leak and performance #187

KamilPuczka opened this issue Dec 3, 2020 · 3 comments
Assignees

Comments

@KamilPuczka
Copy link

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.

@AhsanAyaz
Copy link
Owner

@KamilPuczka good points. Will get on it.

@AhsanAyaz AhsanAyaz self-assigned this Jan 26, 2021
@avargas26
Copy link

hi, first thank you for your cooperation for this lib, but need know if update lib with respect in the question old.

@AhsanAyaz AhsanAyaz assigned mohsinayaz and unassigned AhsanAyaz Apr 28, 2021
mohsinayaz added a commit that referenced this issue May 6, 2021
#187
1:- create a class for device contants because we want to destroy regexes after it checked
2:- apply the condition when user check its device first time it will work but when same useragent and device check another time we return the store data which is stored when user check is first time
@rvalitov
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants