Layout memory leak (Android Studio)

I found a strange memory leak in one of the XML layout files in my application and I don't know how to fix it. Here is my layout code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context="com.deliciouslymad.tsukasa.critterbytes.screen.EnteredDungeonActivity">

    <ImageView
        android:id="@+id/background"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/background"/>

    <Button
        android:id="@+id/next_room"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@drawable/scanbtn"
        android:text="Next Room"/>

    <Button
        android:id="@+id/menu_button"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="75dp"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="5dp"
        android:background="@drawable/button"
        android:text="Exit"/>

    <TextView
        android:id="@+id/room_number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/next_room"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="57dp"
        android:text="#"/>

    <TextView
        android:id="@+id/dungeon_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:text="dungeon name"
        android:textSize="16sp"/>

    <TextView
        android:id="@+id/dungeon_loot"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="25dp"
        android:layout_marginTop="225dp"
        android:textIsSelectable="true"/>

    <Button
        android:id="@+id/loot_ok_btn"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="60dp"
        android:layout_height="50dp"
        android:layout_below="@+id/dungeon_loot"
        android:layout_centerHorizontal="true"
        android:background="@drawable/button"
        android:text="OK"
        android:visibility="invisible"/>

    <ImageView
        android:id="@+id/fieldView"
        android:layout_width="350dp"
        android:layout_height="wrap_content"
        android:layout_above="@+id/next_room"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="140dp"
        android:layout_marginTop="50dp"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:background="@drawable/forest_field"/>

    <ImageView
        android:id="@+id/transition"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/transition"
        android:visibility="invisible"/>

    <ImageView
        android:id="@+id/battleWarning"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/battle_warning"
        android:visibility="invisible"/>

</RelativeLayout>

      

It's ok until I add the last three elements: Field, Transition, and Battle. As far as I can tell, they are set up similar to the ImageView background (making them the same doesn't matter). The background ImageView only adds a few kilobytes to memory, while the other three add 25MB ~ to my memory. The drawings themselves are really small (less than 5 kb).

I have fully commented everything related to these three ImageViews in my java files, so it has nothing to do with it. The memory spike only happens when I add ImageViews to the XML file.

Any help would be greatly appreciated.

+3
performance android-layout xml android-studio memory-leaks


source to share


No one has answered this question yet

Check out similar questions:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
3044
Making a memory leak with Java
1345
Where can I put the "assets" folder in Android Studio?
1214
Rename package in Android Studio
1206
What is Gradle in Android Studio?
1146
performSelector may leak because its selector is unknown
1112
What should my Android Studio .gitignore project be?
1005
How to "select Android SDK" in Android Studio?
862
What are the "tools: context" in android layout files?



All Articles
Loading...
X
Show
Funny
Dev
Pics