Mick
Mick

Reputation: 7947

Interpereting the output of eclipse's memory analyser

I am attempting to trace a memory leak in my game app. The program runs fine once, but if it is run and closed repeatedly then eventually it will run into some kind of not enough memory error. After much floundering with trying to install and understand eclipse's memory analyser, I finally produced the data shown in the screengrab below.

My app is based on a single Application called SD_globals like so:

public class SD_Globals extends Application
{
    int example_global_data = 99;
    // stuff
}

and five separate activities, each of which has access to a variety of global data declared in SD_Globals. One of the activities for example is SD_gameplay like so:

public class SD_GamePlay extends Activity implements View.OnClickListener
{
    SD_Globals gs; // gs stands for global state

    gs = ((SD_Globals)getApplicationContext());

    // now I can access global variable using code like this:
    int x = gs.example_global_data;
}

Looking at the data in the screengrab, the repeated instances of GamePlay looks odd. My guess is that perhaps somehow new activities are being created afresh each time the activity executes without being garbage collected (am I right?)... And if so, what kind of thing could cause that?

EDIT: If I'm completely off track about my interpretation, is there anything else that looks suspicious in the image?

enter image description here

Upvotes: 3

Views: 200

Answers (1)

Sergey Glotov
Sergey Glotov

Reputation: 20346

SD_GamePlay$1, SD_GamePlay$2 and others aren't instances of SD_GamePlay class. It is just anonymous inner classes in SD_GamePlay class. SD_GamePlay$MicksPanelThing and SD_GamePlay$MicksThreadThing are non-anonymous inner classes in SD_GamePlay class.

Explanation of $ in name: https://stackoverflow.com/a/7484241/436938

Upvotes: 1

Related Questions