Closed philipabbey closed 9 months ago
On some devices it looks like removing the System.println() statements from inside an 'if' clause whose condition is a constant (static constant Globals.scDebug) makes a memory saving. This would suggest the compiler does not propagate constants and prune unreachable code. However in the device of greatest interest debug removal has made no difference to the memory usage. Here the conditional clauses have been turned into comments that can be removed on a case-by-case basis otherwise the debug printing is too voluminous anyway.
It is the menu construction with mHaMenu = new HomeAssistantView(menu, null);
that causes the widget to crash due to an "out of memory" error. The HTTP GET request just before it returns just fine, and the memory usage before the crash is 80% of 60 kB.
Before menu construction: used = 49144, total = 61376, 80.070389%
Removing RezStrings.mc and inlining the code can save 1,096 bytes from the application.
Stating the obvious perhaps, but we must also remember that caching a menu also takes up memory, so increasing the risk that the Widget version crashes out of memory.
Anything else?