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

[feature request] Optimize RAM usage of Microsoft Devices SDK #1676

Closed
taraspaliy opened this issue Nov 19, 2020 · 10 comments · Fixed by #1679
Closed

[feature request] Optimize RAM usage of Microsoft Devices SDK #1676

taraspaliy opened this issue Nov 19, 2020 · 10 comments · Fixed by #1679
Assignees
Labels
enhancement New feature or request. IoTSDK Tracks all IoT SDK issues across the board

Comments

@taraspaliy
Copy link

We use Devices SDK v.1.32.0 (https://github.com/Azure/azure-iot-sdk-csharp/releases/tag/2020-10-15) for connecting with Microsoft IoT Hub on the low-end edge device armel based device with limited RAM.

In our solution we use Microsoft IoT Hub SDK for secure MQTT / Websockets connectivity with our cloud. Currently we are experiencing a high RAM usage by IoT Hub SDK libraries, especially for ensuring the secured connection. Using a profiler we found that the certificate manager class uses around 60MB of RAM. Also, an important note is that most of these 60MB are unmanaged memory that can't be cleared by GC.

Can you please advise on optimizing RAM usage of Microsoft IoT Hub SDK libraries? Also please let us know if there are some more light-weight versions of Microsoft libraries for IoT Hub related features.

@taraspaliy taraspaliy added the enhancement New feature or request. label Nov 19, 2020
@github-actions github-actions bot added the IoTSDK Tracks all IoT SDK issues across the board label Nov 19, 2020
@drwill-ms
Copy link
Contributor

I'm afraid there is not another lightweight option to offer.

We can try to find time to do a thorough analysis of object lifetime and frugality of memory. Unfortunately, this code base supports many customers and we cannot make breaking changes, so that will limit us to some degree.

In the interest of finding some quick wins, if you'd share your profile results with us, we'd be happy to look at the top offenders. You mentioned a certificate manager class, but I don't find one by that name. Can you refer me to the specific file?

@drwill-ms drwill-ms linked a pull request Nov 21, 2020 that will close this issue
@az-iot-builder-01
Copy link
Contributor

@taraspaliy, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

@drwill-ms drwill-ms reopened this Nov 23, 2020
@drwill-ms
Copy link
Contributor

I didn't want this issue to be closed, just because I associated 1 PR with it that was merged.

@sharmasejal
Copy link
Contributor

Hey @taraspaliy
We recently checked in a fix (linked here) which might've improved the memory management. Could you advice us on what your RAM requirement is?

@taraspaliy
Copy link
Author

Hi @drwill-ms , @sharmasejal
Many thanks for your support and follow up on this.
At the moment our application consumes ~65MB and the target is to reach 40MB.
We will check internally the impact of this change on the RAM. I will keep you posted.

@drwill-ms
Copy link
Contributor

@taraspaliy I don't know for sure if the change I made was the one requested, but based on the description it seems about right. It was holding a HashSet of all the thumbprints in the personal cert store in a static field on a static class which was only used during initialization. In your initial report it was mentioned that used 60MB of RAM, although it seems that would entirely depend on how many certificates were installed on your local system and it would take an awful lot of certificates' thumbprints to reach 60MB, so I do worry I didn't get the specific issue reported.

We haven't released a new version yet with this change. If you are able to validate by doing a local build, that's great. Otherwise let me know and I'll inform you here when a new version with this change is available.

@taraspaliy
Copy link
Author

@drwill-ms Thanks for your support and for explanation. At least we can try and see what is the result. Would it be possible to get an unofficial build from CI/CD? There are too many dependancies so we have issues with building the solution

@drwill-ms
Copy link
Contributor

drwill-ms commented Dec 3, 2020

I can provide a private drop to you over email. Send me your details to email you at <redacted>

@drwill-ms
Copy link
Contributor

@taraspaliy we've published a release of our latest, including the specific fix I made. The details of version numbers and changes can be found at https://github.com/Azure/azure-iot-sdk-csharp/releases/tag/2021-01-21.

@drwill-ms
Copy link
Contributor

I'm going to close this issue, as it has been a while since I've heard from you, but please do check out the latest release and LMK if you find any specific issues you'd like addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request. IoTSDK Tracks all IoT SDK issues across the board
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants