nworbkcin
nworbkcin

Reputation: 13

Android Studio - New project uses over 20MB of memory

If I create a blank new project and run it, it uses 23MB of memory.

If I add one 540x960 png image to the background of the layout, it uses 47MB of memory.

If I add an image button with a background image on it, it uses 64MB of memory.

This continues to go on if I add things, and this is way too much. On the app I am currently working on, I have memory used at between 180-210MB of memory. I figured there was something wrong I was doing with loading the images, so I ended up putting them all on imgur, and loading them in with Glide. This reduced the memory by a small amount, and also doesn't explain why a new blank project would use 23MB.

I thought there might be some kind of setting, but I re-installed with default settings and am still getting the problem.

Upvotes: 1

Views: 188

Answers (1)

sled
sled

Reputation: 14625

I experienced a similar issue when I put the drawable in the wrong resolution folder, especially the standard "drawable" folder is a pitfall since it is assumed to contain the image in "mdpi" resolution, so the image gets upscaled like crazy on xxhdpi devices.

Here's a simple test to figure it out, move the images into a folder called "drawable-nodpi" and check for the memory consumption.

Then make sure to provide the image in the right resolution in their dedicated folders, and avoid the "drawable" folder for images, just use it for xml drawables.

What basically happens is if you put your "540x960" image in to the standard drawable folder, it is assumed to be mdpi, if you view it on a relatively modern "xxhdpi" devices the image gets upscaled by a factor of 3 e.g it will be "1620x2880" and therefore consume much more memory.

http://developer.android.com/guide/practices/screens_support.html

Upvotes: 1

Related Questions