Search code examples
cordovamemory-managementcrashwindows-phonecordova-plugins

Crashing my app when normal exit is not working - effect on memory


I am using Cordova in my Windows Phone application.

The Cordova API for exiting the application - navigator.app.exitApp(); - is not defined for WP unlike for Android and iOS.

So in order to exit normally I would need a plugin for wrapping my native code that exits the app.

If I let my app to crash by executing something wrong, the result is the same because my app exits anyway.

I know it is a bad practice but what is the effect on my device in terms of memory?


Solution

  • Modern OS such as Windows Phone tend to keep track of the memory allocated for the app and therefore can automatically release the memory when application exits. This exit happens in this case due to unhandled exception which leads to the forcefully killing the application by OS. The OS still has the control and can re-use the memory previously used for the crashed app.

    So, you don't really need to worry about the memory consumption when exiting by crashing intentionally. Only thing that it does is it generates the dump file for each crash (which might allocate some storage space) and increases the crash count for your app which makes your app look like unstable as a consequence.

    You could also use the this already existing plugin that adds the standard navigator.app.exitApp() for WP8.