×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    159

    please help ,how we can remove out of memory exception in my app

    I am wroking on nokia sdk20. using lwuit1.5.When i use the aap so much then an exception occur of out of memory "Uncaught exception java/lang/OutOfMemoryError".It can happen any instant of time.Size of zar file of my app is 2880 kb .so please tell me how i can remove the exception from my app .Please suggest me all possible ways to remove this exception
    Please help me

  2. #2
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: please help ,how we can remove out of memory exception in my app

    That is a big Jar file.Even though it will run in some of the latest devices, I suggest you to take steps to reduce the size of JAR file for maximum compatibility

    1.) Reduce the size of PNGs in your JAR using PNG Compression softwares
    2.) Obfuscate your code to reduce the size of your JAR
    3.) Enclose only absolutely essential files with your JAR.Downloading extra files from a server on first launch can be a good strategy to reduce JAR size.
    4.) If you have text files in your JAR, you can try compressing them using any standard compression technique like Huffman Encoding and decode them as need be.

    Regarding the out of memory Error, See if you can trace any pattern on exactly when this is happening..Does it happen during a network call ? Does it happen when you are trying to open images ? Have you loaded too many images into memory ?

    Based on your previous questions in the Dibo, if you have vectors containing lot of data, see if making them null helps prevent the error.If the vectors contain crucial data which cannot be set to null, then try offloading some portion of it to RMS or memory card and dynamically loading it when needed.

  3. #3
    Registered User
    Join Date
    May 2013
    Posts
    159

    Re: please help ,how we can remove out of memory exception in my app

    i am using 7 to 8 images in each form and also using resurce file 13 to 15 for changing font size and font style.For example if i change font on one form and switch back and forth between two three forms then i am getting out of memory exception and size of res folder is 2.73 mb.

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    683

    Re: please help ,how we can remove out of memory exception in my app

    You cant "remove" out of memory (OOM) exception because
    its not an exception its an Error (Exception are ment to be handle by the apps Errors are usually not ment to be handle by the app in most cases)
    what you can do is you need to optimize your app behaviour to be more efficiant in terms of memory.
    Dont save reference to old forms if you dont need them, dont use Bitmap fonts a lot in your app, if you use images in your app make sure to lazy load them and nullify them when they are not in use, etc.
    Heard of DVLUP? Join here

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: please help ,how we can remove out of memory exception in my app

    Please check the size if the images you have used. If this seems big for you, then you can reduce the size of the images and load them. As a short cut you can download the pngout and drag your images on this and this will reduce the size. Try to reuse the code in the form of the java files and remove the replicated code base.

    As far as OOM is concern, this can only be removed by managing the heap of the your app which is current taking too much. Try to call the garbage collector on some of the screens, as mentioned in the below posts follow some of the suggestion.

    Please do all this stuff and revert if you still face the issue.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Registered User
    Join Date
    May 2013
    Posts
    159

    Re: please help ,how we can remove out of memory exception in my app

    Thanks for response.i'll follow these ideas

  7. #7
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: please help ,how we can remove out of memory exception in my app

    Additionally, look at this article for understanding how much space images take up in memory

    http://developer.nokia.com/Community...ges_in_Java_ME

  8. #8
    Registered User
    Join Date
    May 2013
    Posts
    159

    Re: please help ,how we can remove out of memory exception in my app

    @shai ,thanks Now i am facing the problem out of memory.i am not able to manage the run time memory when i use the app for some time then runtime memory is over .i get the free memory at that instant
    approximately 3000-4000 bytes that time out of memroy occur and my app is crash . When i use xml parsing of xml file which stores in my res folder during parsing i get the data and save it in vector but during parsing runtime free memory is over.
    Please tell me how can managae the run time memory this is a big issue for my aap

  9. #9
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: please help ,how we can remove out of memory exception in my app

    Just to be clear,Does OOM occur during the parsing ?

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: please help ,how we can remove out of memory exception in my app

    Be careful Arunkam, while vikranttanwar@ will happily discuss about his issues with you, actually he has a large amount of similar threads, some of them contains comments from you too.
    The one about vector and RMS: http://developer.nokia.com/Community...-data-from-RMS from August
    The one about XML parsing: http://developer.nokia.com/Community...xtfile-in-j2me from 2 weeks ago
    The one about variables and OOM: http://developer.nokia.com/Community...-quot-exeption from August

  11. #11
    Registered User
    Join Date
    May 2013
    Posts
    159

    Re: please help ,how we can remove out of memory exception in my app

    yes during parsing OOM occur.i have 12 xml files in res folder and when my app start then parsing occur but when aap is used for some time and further if i parsing xml file then OOM occur. i want to tell you one thing that during parsing i save data in vector.
    Last edited by vikranttanwar@; 2013-12-13 at 05:25.

  12. #12
    Registered User
    Join Date
    May 2013
    Posts
    159

    Re: please help ,how we can remove out of memory exception in my app

    @wizard_hu_.i ask question only when i face some problem and till now it is not solved that is why i making question

  13. #13
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: please help ,how we can remove out of memory exception in my app

    Quote Originally Posted by vikranttanwar@ View Post
    yes during parsing OOM occur.i have 12 xml files in res folder and when my app start then parsing occur but when aap is used for some time and further if i parsing xml file then OOM occur. i want to tell you one thing that during parsing i save data in vector.
    1. You should not parse all the XML file at the time when the app is getting launched, if you are.
    2. Are you parsing the same XML file if you have parsed it already, if yes then at least clear the older ones reference from the heap.
    3. JSON for the same instead of XML, can help you if its not taking too much from your efforts.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. how to remove exception occur on device dubugging
    By vikranttanwar@ in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2013-08-14, 15:57
  2. out of memory exception
    By tvgece in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2012-03-12, 07:14
  3. Out of Memory Exception in
    By honest_success in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2009-09-10, 20:14
  4. How to remove this memory leak from TRAPD
    By ranjeet raj in forum Symbian
    Replies: 20
    Last Post: 2008-11-10, 11:01
  5. memory out exception
    By knawaz in forum Mobile Java General
    Replies: 6
    Last Post: 2008-07-18, 06:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×