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

  • Home
  • SEARCH
  • 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 8964201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:32:01+00:00 2026-06-15T16:32:01+00:00

Can somebody tell me why am I having these memory leaks? It happens when

  • 0

Can somebody tell me why am I having these memory leaks?
It happens when splash screen needs to finish itself (basically call a new activity)
And again it happens when I’m opening a new page (new activity) on a button click in the menu.

Log cat memory leaks :

Splash screen to main menu :

12-07 19:35:58.037: D/dalvikvm(2167): GC_CONCURRENT freed 499K, 21% free 4138K/5228K, paused 8ms+8ms, total 397ms
12-07 19:35:58.045: D/dalvikvm(2167): WAIT_FOR_CONCURRENT_GC blocked 170ms
12-07 19:35:58.116: I/dalvikvm-heap(2167): Grow heap (frag case) to 5.208MB for 1106044-byte allocation
12-07 19:35:58.365: D/dalvikvm(2167): GC_CONCURRENT freed 3K, 18% free 5215K/6312K, paused 8ms+33ms, total 246ms

Main menu to a new page :

12-07 19:38:30.974: D/dalvikvm(2167): GC_FOR_ALLOC freed 512K, 17% free 5272K/6304K, paused 119ms, total 151ms
12-07 19:38:31.034: I/dalvikvm-heap(2167): Grow heap (frag case) to 6.316MB for 1106044-byte allocation
12-07 19:38:31.376: D/dalvikvm(2167): GC_CONCURRENT freed 1129K, 30% free 5224K/7388K, paused 89ms+5ms, total 332ms

Here is my main :

package com.example.prva;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MotionEvent;


public class MainActivity extends Activity {

    MediaPlayer MPlayer; //da MPlayer mozemo koristiti bilo gdje
    protected boolean splashactive = true;
    protected int splashtime = 0;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);        

        MPlayer = MediaPlayer.create(this, R.raw.splash); //dodavanje zvuka MPlayeru
        MPlayer.start();        //play

        Thread tajmer = new Thread(){
            public void run(){
                try{        
                    while(splashactive && splashtime<3000)
                        {
                            sleep(50);
                            splashtime=splashtime+50;
                        }
                    }
                 catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }               
                finally{
                    finish();                   
                    MPlayer.release();
                    startActivity(new Intent(MainActivity.this, Meni_Splash.class));                
                }       
            }           
        };
        tajmer.start(); 
    }       

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            splashactive = false;           

        }       
        return true;
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        MPlayer.release();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        MPlayer.pause();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        MPlayer.start();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

Meni_Splash :

package com.example.prva;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Meni_Splash extends Activity{  


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);     

        Button btnv = (Button) findViewById(R.id.buttonv);
        btnv.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent(Meni_Splash.this, button.class));              
            }
        });         
    }
}

I can’t figure out where is the problem?
Please don’t tell me to increase the heap size.
Thank you all in advance!

  • 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-15T16:32:03+00:00Added an answer on June 15, 2026 at 4:32 pm

    I don’t see any leak here unless you hold a reference to one of these activity somewhere else.
    For example MPlayer is not private or protected so if you hold a reference to it in another instance you might have a leak.

    It is normal to have garbage collection when the MediaPlayer is involved. It can take a lot of memory

    Your MainActivity stays in memory even if a new Activity is started. If you don’t want that call finish(); after startActivity();

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

Sidebar

Related Questions

I am having problems using a LoginView for what I need. Can somebody tell
can somebody tell me how to call checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) function? i tried:
Can somebody tell me what is the meaning of Installs: 100-500. What Google Play
Can somebody tell me how I can find out how many threads are in
can somebody tell me why my code is not working? class Connection { public
Can somebody tell me why compiler thinks that break is necessary after yield return
Can somebody tell me what does this mean? I'm going trough Java book and
can somebody tell me what is jQuery plugin? I have used the jQuery library
Can somebody tell me what lazy-loading policy NHibernate uses? Various sources provides contradictory information
TO_CHAR(( TO_DATE(calendar_key,'YYYYMMDD' )+ 1),'IW') week Can somebody tell me what's happening in this query?

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.