Performance improvement in UAParser
Describe the bug The UAParser implementation seems to consume a lot of unnecessary memory, putting the ua yaml parse definition multiple times into memory.
What area is it related to UAParser
To Reproduce Steps to reproduce the behavior:
- Run any instance of activelogin
- Make sure you have a large amount of requests
- Perform a memory dump in VS with Managed heap Summary
- Observe many instances of 390.1 KB strings containing a YAML definition file for UAParser (problem)
Expected behavior Single read of parse definition
Screenshots
NuGet package version 8.0.0
Runtime version .NET Core 8.0
Desktop (please complete the following information): N/A
Smartphone (please complete the following information): N/A
Additional context Parser uses Parser.GetDefault() for each detect which in turns reads manifest resource. Seems like this could easily be optimized by making the parser a static/singleton.
Activelogin https://github.com/ActiveLogin/ActiveLogin.Authentication/blob/main/src/ActiveLogin.Authentication.BankId.UAParser/UAParserDeviceDetector.cs
UaParser. https://github.com/ua-parser/uap-csharp/blob/master/UAParser/UAParser.cs
Thanks for reporting this! Will reproduce and have a look.
This issue was fixed in release in v 10.1.1.