I have been coding this application that shows images of bus lines schedules. There are currently 32 lines and each of them has it's own image (can't use text due to the formatting and lack of data, had to do a compromise). I made it fetch an echo from a PHP file on my server and it retrieves data regarding bus lines and their images, then it downloads that data and images to the internal storage and loads the buttons for each line (dynamic layout).
ImageViews are set to null when they are created and they are only populated once you click on the button. I have noticed that my app uses around 20MB of RAM just as it starts. Opening 10-15 lines (10-15 images are loaded into ImageViews), RAM usage climbs up to 60MB and then it crashes (reaches my device's heap size limit). I know that image intensive applications tend to use a lot of RAM and my plan is to limit it to only one image per time (so once the user clicks on some other bus line, the others are closed and their imageviews are set back to null), but what is wondering me, can empty ImageViews cause RAM to be around 20MBs? My images are 320px in width and ranging from 200 to 1500px in height (I know, it's a lot), but I have set them to grayscale and compressed them (Size of the images is from 50kb up to 150kb).
My application's APK is 710kb in size, app when installed is around 3MB and with data it totals to 7.5MB.
So, to clarify, my questions are:
*1) Can empty ImageViews cause high RAM usage as well?
2) If yes, should I dynamically create an ImageView and populate it once the user clicks on the button, instead of the current approach when they are all created at startup?
3) Can multidimensional variables (mostly strings, 6 strings with 35 dimensions) cause high RAM usage as well? Most of them are around 10 characters long.
4) Are there any tools which I could use on Android Studio which could help me to locate possible memory leaks?
5) Do non-global variables get automatically destroyed once the ie. function has returned a value or do I need to manually set them to null after I'm done with them?
6) What are generally some good practices to reduce RAM usage on Android when developing an app?*
Sorry for not being very technical here, I'm not a professional programmer or anything, this is more of a hobby of mine and I'm trying to learn a bit more here. Thank you for reading.
Image that shows what my app does:
All bus lines are collapsed
Once you click on the button, it shows the bus schedule for that line