Answer the question
In order to leave comments, you need to log in
Why is memory leaking in Android in a newly created application template?
A question based on a topic on Habré What are memory leaks in android, how to check p... .
Using MAT, in my application I found a memory leak in mContext, but I did not find where exactly. For the experiment, I created a new project in Eclipse, without changing anything in it, launched it as is, and MAT also finds the same memory leak in it! How so?
Freshly created application code:
package com.example.test_mat;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Answer the question
In order to leave comments, you need to log in
Try just
public class MainActivity extends Activity
See if the memory leak persists?
Choate your tasks (as well as their solutions) one more beautiful than the other.
ideone.com/VkmZZx
If it is fundamental to use recursion, and if you need one line, then you do not need to do "echo" inside the function, but fasten the lines. More or less like this:
function number_string ($n = 5)
{
return $n>1 ? number_string($n-1) . $n : $n;
}
echo number_string();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question