Cordova plugin to dispatch memory warnings to javascript.
cordova-plugin-memory-warning-ios-android is compatible with Cordova Plugman, compatible with PhoneGap 3.0 CLI, here's how it works with the CLI:
phonegap local plugin add https://github.com/RahulCV/cordova-plugin-memory-warning cordova plugin add cordova-plugin-memory-warning-ios-android cordova prepare ionic cordova plugin add cordova-plugin-memory-warning-ios-android ionic cordova prepare// listen for 'memorywarning' events document.addEventListener('memorywarning', function () { // release memory }); // because iOS has app specific memory warnings // isMemoryUsageUnsafe method always returns false on iOSNOTE: on Android, your app's MainActivity.java file will be modified to add hooks into Android memory warning events!
// listen for 'memorywarning' events // on android these are only dispatched for system level memory pressure // see below for app specific memory pressure handling document.addEventListener('memorywarning', function () { // release memory }); // because android does not have app specific memory warnings // you should manually check memory state before performing memory intensive operations // executes a callback that resolves with boolean true when memory usage is at an unsafe level // optionally pass a second callback for error handling cordova.plugins.CordovaPluginMemoryWarning.isMemoryUsageUnsafe(function (result) { if (result) { // release memory } }, function (error) { // handle errors });Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.