Note that there are some explanatory texts on larger screens.

plurals
  1. POOut of memory on X-byte allocation
    primarykey
    data
    text
    <p>I suspect I'm facing a memory management issue which is an Out of memory on a X-byte alocation causing my app to crash (specifically on the Samsung S3) after the calling of several activities. </p> <p>So just explain my screen flow: </p> <p>splash screen -> log in screen -> menu screen (from menu screen user can call three different activities) -> user calls activity 1 and the app crashes here OR works -> user calls activity 2 and app definitely crashes. </p> <p>All the above activities have very low sized images (~44kb) as backgrounds (this is a specification/requirement of the app)</p> <p>Below is how I've essentially created each progrmatically activity and set the backgrounds (the image R.drawable.bgnd is of size 44kb and so are the other images):</p> <pre><code> public class FincCalcScreenNormal extends Activity { @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Main RL params RelativeLayout.LayoutParams rllayoutParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); // Create main relative layout RelativeLayout rlMain = new RelativeLayout(this); rlMain.setBackgroundResource(R.drawable.bgnd); rlMain.setLayoutParams(rllayoutParams); // Set the activity content to an explicit view. setContentView(rlMain); } } </code></pre> <p>The image below shows the stacktrace of the app on the S3 when it crashes. From the stacktrace at the bottom of the image you will notice the area I've circled in red. This is the line in code where by the crashes.</p> <p><img src="https://i.stack.imgur.com/otqVd.png" alt="enter image description here"></p> <p>I've read through the android documentation specifically this <a href="http://developer.android.com/training/articles/memory.html#ReleaseMemoryAsUiGone" rel="nofollow noreferrer">http://developer.android.com/training/articles/memory.html#ReleaseMemoryAsUiGone</a> and attempted to use the onTrimMemory() method to release memory when the UI becomes hidden but it didnt make a difference.</p> <p>Below is a list of all the images i utilise in the app with regards to file size: </p> <p>A JPEG backgroundimage for activity -> 110kb</p> <p>A JPEG backgroundimage for activity -> 80kb</p> <p>A JPEG backgroundimage for activity -> 76kb</p> <p>A JPEG backgroundimage for activity -> 68kb</p> <p>A JPEG backgroundimage for activity -> 59kb</p> <p>A JPEG backgroundimage for activity -> 51kb</p> <p>A JPEG backgroundimage for activity -> 44kb</p> <p>A JPEG backgroundimage for activity -> 42kb</p> <p>A png image for a button background -> 38kb</p> <p>A png image for a button background -> 35kb</p> <p>A png image for a button background -> 31kb</p> <p>A JPEG backgroundimage for activity -> 31kb</p> <p>A JPEG backgroundimage for activity -> 30kb</p> <p>A JPEG backgroundimage for activity -> 29kb</p> <p>A png image for a button background -> 28kb</p> <p>A png image for a button background -> 27kb</p> <p>A png image for a button background -> 18kb</p> <p>A png image for a button background -> 16kb</p> <p>A png image for a button background -> 16kb</p> <p>A png image for a button background -> 13kb</p> <p>A png image for a button background -> 6kb</p> <p>A png image for a button background -> 6kb</p> <p>A png image for a button background -> 5kb</p> <p>A png image for a button background -> 4kb</p> <p>A png image for a button background -> 3kb</p> <p>A png image for a button background -> 2kb</p> <p>A png image for a button background -> 2kb</p> <p>A png image for a button background -> 2kb</p> <p>A png image for a button background -> 2kb</p> <p>A png image for a button background -> 2kb</p> <p>A png image for a button background -> 1kb</p> <p>The above amounts to a total of 880K and compared to the allocated memory of the app based on the stacktrace I posted which is ~14mb then I don't get why I'm having this problem.</p> <p>Any ideas are appreciated as I've been stuck on the issue for several days.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload