Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8957917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:06:19+00:00 2026-06-15T15:06:19+00:00

When starting my Application, the heap is at about 15M. After calling setContentView in

  • 0

When starting my Application, the heap is at about 15M. After calling setContentView in MainActivity it raises to about 30M. There isn’t much in that layout. That’s why I’m wondering if that’s normal. When starting another Acticity, it again raises to about 40M and won’t go down again.

That’s what main.xml looks like:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:background="@drawable/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/LinLAdMain"
        android:layout_width="match_parent"
        android:layout_height="88dp"
        android:layout_weight="0.70"
        android:orientation="vertical" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.70"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:contentDescription="@string/logo_description"
            android:src="@drawable/logo" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="0.14"
        android:orientation="vertical" >

        <Button
            android:id="@+id/button1"
            style="@style/StartButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:onClick="onClick"
            android:layout_margin="8dp" />

        <Button
            android:id="@+id/button2"
            style="@style/HighscoreButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:onClick="onClick"
            android:layout_margin="8dp" />

        <Button
            android:id="@+id/button3"
            style="@style/SettingsButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:onClick="onClick"
            android:layout_margin="8dp" />

    </LinearLayout>
</LinearLayout>

As you can see, I’m using a background-drawable. But the file is about 60K big..

And that’s what the MAT-default-report looks like right after setContentView():

screenshot

This is what the paths to GC look like (excluding weak references):

screenshot
screenshot

These “nexts” end in head class java.lang.ref.FinalizerReference, which is telling me nothing.

As I said, it’s getting worse with every Activity. For example after
Main->Highscore->GlobalHighscore it’s no more possible to start the Activity “ingame”.
Hope you guys can help me :).

If you need more Information / Code, tell me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:06:20+00:00Added an answer on June 15, 2026 at 3:06 pm

    Image file formats like PNG and JPG are using a compression algorithm to reduce the used disk space. However when images are loaded in android app these files are decompressed and may become much bigger then the original file.

    The space used after decompression would be similar to the disk space used if you convert your PNG or JPG file to BMP 32 bits color.

    An example

    A very simple full white draw with size 1024 x 1024 pixels, saved as PNG will use a few Kb.

    After decompression into a ARGB_8888 it becomes an array of 1024 x 1024 x 4 bytes (the last 4 stands for the 4 bytes used per pixel, one for each basic color RGB and one for Alpha)

    1024 x 1024 x 4 = 4,194,304 = 4 MB
    

    so the memory used will be 4 MB for this simple image.

    What to do

    Reduce de memory used by image:

    • Use the smallest size (width and height) that still meet your
      requirements for the different screen sizes you want to support
    • Use different sizes for different screens (mdpi, hdpi, etc.). However, this increases your application size.
    • Use Draw 9 Patch to create small size images that will extend to large screen in a predictable and controlled way.

    Find the memory leak that keeps memory aloocation increasing.

    Probably you are using some reference to your activity Context that is preventing GC to collect the memory. The most probable reasons are objects that have reference to Context/Activity:

    • Threads
    • Handlers
    • Views

    Try nulling them when no longer required, or on activity OnDestroy()

    Regards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting a web application project that will have an Adobe Flex front-end
Is there a way with WebSphere 6.1.0.25 to prevent an enterprise application from starting
I'm developing a graphics-intensive application for Android 2.2 and above. I know that starting
I have a new application starting that's using Rails 2.3.8 for stability concerns and
I am starting an application that I would like to build quickly and will
My question is actually about starting an application with MVVM : My main screen
On my application starting I need to get list of libraries that are linked
Before starting my application (on Form Load) I want to check and ensure that
Since the last update, after starting the Application the FTP-Server-Connections in Project Explorer are
It's my first time writting there but after reading and searching a lot about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.