What's best for garbage collection in Android.

 

Secnario#1

While (true)

{

  Class_Master_Main main = new  Class_Master_Main();

  main.doSomething();

   

   .... do other stuff

   ...Sleep() for an hour

}

 

Secnario#2

Class_Master_Main main = new  Class_Master_Main();

While (true)

{

    main.doSomething();

   

   .... do other stuff

    ...Sleep() for an hour

}

 

Secnario#3

Class_Master_Main main = null;

While (true)

{

    main = new  Class_Master_Main();

    main.doSomething();

    main = null;

   .... do other stuff

    ...Sleep() for an hour

}

 

 

 

Now these are Service loops that never end while the program is running.
Secnario#1 makes a new instance on each loop but would release resources
(I'm assuming) and cause garbage collection.  But, would allow more
memory for '.... do other stuff'.  GC isn't an issue because of the
sleep time.  Why keep the main object around while sleeping is my
thoughts?  Scenario #3 makes the most sense to me.  Dang, everyone of
the programmers here has a opinion so why not ask for more.

 

Tim

 

_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to