-
Notifications
You must be signed in to change notification settings - Fork 13
Change from library dependency to code to save 37K of memory #12
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Doing this removes a dependency on Adafruit_hashlib saving 18K in memory usage
I'm still testing everything works, just wanted to raise this for visibility. |
Closed
Memory usage testing was done with this code: gc.collect()
free_memory = gc.mem_free()
from adafruit_azureiot import IoTCentralDevice
gc.collect()
print("Used memory", free_memory - gc.mem_free()) |
All tested and ready for review. |
Note that the gc.collect() is redundant because CircuitPython will automatically collect after every import. |
brentru
approved these changes
May 26, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed, lgtm!
adafruit-adabot
added a commit
to adafruit/Adafruit_CircuitPython_Bundle
that referenced
this pull request
May 27, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_IRRemote to 4.0.0 from 3.5.1: > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#38 from Flameeyes/fix Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.2.0 from 2.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#12 from jimbobbennett/master Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_ICM20X
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Adafruit_hashlib library uses a lot of memory, 26K. The Azure IoT library uses the CircuitPython HMAC library, which uses this library, eating a total of 29K.
These libraries handle a number of different hashing sizes, but the Azure IoT library only needs 256. By bringing in the code for just this, we can save 18K in memory usage, which is substantial!
Also removed dependencies on Parse and Base64, importing just the bare minimum code needed.
Saves 37K in total.