Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Low memory notifications

Brwe MP applications can register for low memory notifications and customize the behavior of freeing up memory. Low memory notifications are generated when a running application’s call to MALLOC() fails and encounters insufficient memory.

Applications can call ISHELL_OnLowRam() or ISHELL_RegisterSystemCallback() with nSCBType as AEE_SCB_LOW_RAM to register a callback function that will be called when the system reaches a low memory condition. This allows the application to perform memory cleanup to free memory for the system.

Applications can also call ISHELL_OnLowRAMCritical() or ISHELL_RegisterSystemCallback() with nSCBType as AEE_SCB_LOW_RAM_CRITICAL to register for a callback to be invoked when the system reaches a low memory condition and sufficient RAM has not been gathered by AEE_SCB_LOW_RAM callback. This allows the application to perform more memory clean-up. The calling application must belong to the AEEGROUPID_LOW_RAM group to successfully register for the callback.

On devices with applications registered to receive low RAM notifications, Brew MP will first send a low RAM notification to the applications that have registered for this condition. The expectation is that the registered application would then free resources to make more heap available. After this notification, Brew MP checks the available heap space again. If the required memory is still not available, then Brew MP will send out a critical low RAM notification to the applications that have registered for this condition. The expectation is that the registered application would then free resources and memory to make more heap available.

The callback associated with AEE_SCB_LOW_RAM or AEE_SCB_LOW_RAM_CRITICAL is a one-shot callback. The application may re-register the notification during the callback.