Skip to content

Conversation

klutvott123
Copy link
Member

During some operations there are some pretty large memory usage peaks.
When reloading a page from the menu there is a peak, but not when switching to another page. When reloading a page, invalidatePages() is called but there is no collectgarbage() as in incPage(). Then we might have two copies of the same page loaded for a brief moment.
Added collectgarbage() to invalidatePages() to deal with this.

The second case is when selecting a page from the main menu. Here we also end up with two pages in memory. The script will load a page in the background and the main menu code will load a page when pressing enter.
Removed the page loading in the main menu code and replaced it with invalidatePages() which now also collects garbage. Then the page can be loaded by the code that is already in place to do it.

I have done multiple tests with and without these changes. Now I'm seeing dips in memory use when selecting a page from the main menu. When reloading a page it's the same as when switching between pages. Opentx shows that free memory has increased by over 10kb

@mikeller mikeller added this to the 1.5 milestone Oct 29, 2019
@mikeller mikeller merged commit 340bb39 into betaflight:master Oct 31, 2019
@klutvott123 klutvott123 deleted the reduce-peak-memory-use branch November 15, 2019 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants