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

Developer

resources

Use of callbacks

One of the common application defects that results in the device crashing is lingering callbacks registered by an application that are invoked when the application is no longer in the proper state to handle it (for example, callbacks may reference memory that has already been released). This issue is particularly prominent in the following scenarios:

  1. When the applet releases an object and returns control to the system without cancelling the callbacks registered for that object (callbacks created with the object's RegisterNotify() method)
  2. When the applet exits without having properly cancelled the callbacks registered for the applet (for example, timer callbacks)

A rule of thumb is for the applet, or any Brew MP class, to keep track of all the callbacks it has registered and cancel them before releasing the corresponding objects or the memory referenced by the callbacks, or before the applet gets freed.