-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Sharpdisplay: reuse supervisor heap #3498
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
Sharpdisplay: reuse supervisor heap #3498
Conversation
I investigated why #3482 causes a problem with framebuffer displays. It’s not a bug in #3482 (phew), but as you say it’s actually the double call of The first commit of this PR has no bearing on that, the framebuffer is always handled correctly (before #3482, between #3482 and this PR, with this PR). The second commit of this PR seems to be a correct fix for the terminal issue, but as you say, it would probably be even better to avoid the double call (and either keep this or make sure there can be no other way of getting two calls in a row). |
This is enabled by adafruit#3482 I was unable to determine why previously I had added sizeof(void*) to the GC heap allocation, so I removed that code as a mistake.
63c3c01
to
b520498
Compare
I think this can go in now. I didn't do any re-testing today, though. |
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.
Code looks good to me and I’ve given it a quick test now that I have a Sharp display (thanks to @deshipu), it works fine and is effective in saving memory on the second and subsequent runs.
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.
Thank you!
Due to an existing limitation of being unable to re-allocate a freed supervisor heap entry, framebuffer displays used more memory than necessary, particularly on the second and subsequent runs: The preserved-over-soft-reset display has its framebuffer moved to the supervisor heap, but we release that display with release_displays() and then create a fresh one which places its framebuffer on the GC heap.
A newly exposed problem, where framebuffer displays would cause a leak of the terminal grid storage, was also found and fixed.
With this change, sharp displays will re-use the same supervisor allocation as long as the WxH of the display matches.
A similar change should be made for RGBMatrix, however at this moment I did not want to take the time to implement and test it. It consists of switching the order of preference for allocation to try supervisor first and gc second, then fixing whatever breaks.
This requires #3482 + #3497 in order to be fully effective, so it should be merged only after those go in.