btw^2

Rather than assigning the same literal in the constructor, create new
String each time around the same literal:

/*
 * My Class
 */

package com.gabysoft.memoryleak;

import android.util.Log;

public class MyClass extends Object
{
   String balast;

   MyClass()
   {
       balast = new String("some long text, just to make this class
consume more memory, so that the system has strong inclination to
regain it");
       Log.d("GabySoft", "MyClass::MyClass() " + this);
   }

   @Override
   protected void finalize()
   {
       try {
           Log.d("Gabysoft", "MyClass::finalize() " + this);
       } finally {
           super.finalize();
       }
   }

}

--
Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to