What will happen if we run startActivity in a loop?

Suppose there are two apps:

  1. Tracker ( Which I am developing)
  2. SomeApplicaiton (For reference we will say this is youtube app)

Now, I want the SomeApplicaiton.apk app to always keep running even if due to some reason SomeApplicaiton crashes, I want the Tracker app to relaunch it. I have found a solution using the below code. This is working too, I want to know what will happen if I let it run for 2 to 3 days. will it make the tracker app consume more memory?

public class MainActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {
        Timer t = new Timer();
        startService(new Intent(getBaseContext(), OnClearFromRecentService.class));

        TimerTask tt = new TimerTask() {
            public void run() {
                try {
                    Intent intent = getPackageManager().getLaunchIntentForPackage("");
                    startActivity( intent );
                    Log.d("status","tryin to start yt");

                }catch (Exception e ){



        t.scheduleAtFixedRate(tt,500,5000); // try to start after 5 sec.




a simple Streamlit component that allows users to select a single item from a list of options in a menu

I was programming a car simulator but whenever it comes to a ramp it suddenly stops? Code is here: