0

when I am starting my app I am setting a few Texts and Fonts in some TextViews and I am setting the Content View. When I am looking at the RAM Usage it grows linear: enter image description here

The allocation Shows many same Threads which cause a huge RAM usage: enter image description hereenter image description here

Could anyone please tell me why the RAM usage grows linear and what is going on in the Threads. This is the Code which is called when the app starts.

@Override
protected void onCreate(Bundle savedInstanceState) {

    // remove title
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_menu);

    setTypeface(R.id.rl_root_main_menu);

    if(levelPattern!=null)
        load();    // converts data from Json String

    TextView tvScore =(TextView)(findViewById(R.id.text_score_points));
    tvScore.setText(String.valueOf(score));

}

public void setTypeface(int layout) {

    final Typeface font = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/ikaros_light.otf");
    for (int i = 0; i < getTextViews(layout).size(); i++) {
        getTextViews(layout).get(i).setTypeface(font);
    }
}


public  ArrayList<TextView> getTextViews(int layout) {
    RelativeLayout rl = (RelativeLayout) (findViewById(layout));

    ArrayList<TextView> textViewList = new ArrayList<TextView>();
    ArrayList<Integer> RelativeLayoutList = new ArrayList<Integer>();

    for (int i = 0; i < rl.getChildCount(); i++) {
        if (rl.getChildAt(i) instanceof TextView)
            textViewList.add((TextView) rl.getChildAt(i));
    }
    return textViewList;

}

Thanks in advance.

Chinaedu Onwukwe
  • 437
  • 1
  • 7
  • 20
  • Need to see your code – Oleg Vladimirov Jun 03 '16 at 08:30
  • Yes, we need to see your code, but I will say, the only time I've encountered this was when I had a do while loop that I forgot to increment... – Nerdy Bunz Jun 03 '16 at 08:31
  • are you using custom font ? if yes . try to use hash map for caching fonts – Ali mohammadi Jun 03 '16 at 08:43
  • Are you actually having any problems? If you don't get `OutOfMemoryError` exceptions or your app continually gets slower and slower until it is completely unusable then I wouldn't worry about it. What you are seeing on the memory monitor may easily be completely normal behavior. Don't try to fix a memory problem unless there actually is one, premature optimization is bad. – Xaver Kapeller Jun 03 '16 at 08:44
  • And especially if you don't interact with your app and the memory still grows then there is most certainly no problem. – Xaver Kapeller Jun 03 '16 at 08:45
  • @XaverKapeller but when I am starting to interact with the app, the Memory still grows faster and faster although I am not editing more data. Is it not possible that at any time the app crashes because it goes out of Memory? – Chinaedu Onwukwe Jun 03 '16 at 08:49
  • @ChinaeduOnwukwe Does it crash? Does the performance drop? Do you see very frequent GC pauses? Maybe even to the point that it impacts the performance of your app? If yes, then you might actually have a problem. Otherwise not. Your app uses 10-11 MB of RAM and it on the chart you posted it seems to only grow by KB every seconds. Nothing about that indicates any problem. If you want then use your app continually for some time, let it run, switch around the screens and use all your features. If your app doesn't crash and performance doesn't drop then you have no problem at all. – Xaver Kapeller Jun 03 '16 at 09:03

0 Answers0