App randomly crashes when phone comes back from IDLE

Hello, My app is working fine on my phone (HTC 510 desire android 4.4.2) as long as the phone is UP, but when the phone goes to IDLE and next to ACTIVE, the app crash randomly.

The crash comes from an out of memory.

Here after the error message:

FATAL EXCEPTION: Thread-88714 Process: processing.test.sketch_171102a, PID: 24348 java.lang.OutOfMemoryError: (Heap Size=65536KB, Allocated=61546KB) at Method) at

Questions: 1>How can I log the amount of memory allocated? 2>What can be the problem?

Thanks in advance /Pascal


  • when the phone goes to IDLE and next to ACTIVE

    You mean that your app works fine until you press the back button and then try to run the app again either b searching for your app in your device's application manager or when running your application again?

    Are you managing you application's life cycle?


  • Hi kfrajer that's correct, same problem also if I switch off the screen....No I don't manage the life cycle...How is it managed by processing?Thanks for your help

  • This document will give you the background:

    Check examples in the forum:

    Depending on the resources you use, implementing life cycle could be straight forward or potentially not supported. However if you stick to Android tools and resources, you could get a potentially more stable app.

    Please note most of the examples in the forum are based on a previous Android mode. With the later Android mode ( >4.0) you might need to tweak the code to make it work.


  • Thanks! I'm going to read the document. Can you just confirm that if I want to manage the life cycle I have to export my android project to ecplise or android studio. Many Thanks for your help

  • edited November 2017


    you can manage the life cycle inside p5: no needs to use as or eclipse for that; yet, what you get is a memory heap error and probably are you using a lot of images; if it is right perhaps have you to create a thread for loading them with an asyncTask...

  • Akenaton that's correct I use a lot of images! Do you have an exemple? Thanks!

  • @paco06===

    it is easy to give you an example of asyncTask for loading bitmaps; yet for your problem there is a lot of questions:

    • are the images all loaded in setup()??? Are they loaded in draw()??? are they put in an Array???

    • how big are these images??? - Can the size be reduced???

    -are they loaded from an URL??? Are they loaded from URI???

    • can you put some snippet from your code?

    • According to answers you can a) load your images out of the main UI with an asyncTask or an handler b) create a memory cache c) create a method used in onResume() in order to verify that the images are ok....

Sign In or Register to comment.