saraf
saraf

Reputation: 646

Blackberry Memory Low issue on Phonegap application

I am developing a JQM + Phonegap application for BlackBerry 6.0+ devices. In the application I need to upload an image to the server in the Base64 encoded format.

I am doing this using the HTML5 canvas element. I get a low memory error when the application tries to do the above operation,immediately after this the application quits.The application icon also changes after this. I am using WebWorks SDK 2.3 and phonegap version 1.7.

I have gone through blackberry forums and the memory issue seems to be a known one. Is there any other way I can do this operation to avoid this error?

This problem is specific to 6.0 BB devices. The same application is working fine on 7.0 devices.

Upvotes: 0

Views: 377

Answers (1)

Try

  1. Removing this code from your configuration file (including opening and closing tags)

    rim: navigation mode= "focus"

    feature id="blackberry.ui.dialog"

  2. Loading your scripts dynamically and executing the callback function to upload the image when the script loads and is ready, the most probable reason for this behavior is that the resources that you include in your html page are not released when the application closes. Also the cordons plugin for blackberry is a huge resource, so it should take up a lot of memory.

    function loadScript(url, callback)
    {
        // adding the script tag to the head as suggested before
        var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src=url;
        // then bind the event to the callback function 
        // there are several events for cross browser compatibility
        script.onreadystatechange = callback;  // not working on OS5
        script.onload = callback;  // not working on OS5
        // fire the loading
        head.appendChild(script);
    }
    
  3. If your app is not clearing the device storage or local storage or the device storage when the app is installed or uninstalled, you will have to code this (automatically done for iOS and android apps).

The above three reduce the probability of a low device memory error.

From the end-user's perspective, if the app does not use embedded media, untick or deselect "use embedded media"

If there is communication with a server, you might want to refactor your code to reduce the average time used to execute code and employ some compression algorithms to reduce network overload.

Upvotes: 1

Related Questions