|
Replies:
3
-
Last Post:
Sep 29, 2008 8:28 AM
by: kutzi
|
|
|
|
|
|
|
Does system.gc() really help your app to get more efficient?
Posted:
Sep 29, 2008 1:04 AM
|
|
|
Hi,
although i develop mobile apps using J2ME everyday, i still want to know real truth of pros/cons of calling system.gc(). I know some of it like it will do the garbage collection ... >> avoid outOfMemoryError... but My friends told me it will make your app slower..
Anyone who got this knowledge (based on J2ME or any others platform if you want to add..) ... please share to me and the others who want to know....
Regards, Sub7
|
|
|
|
|
|
|
Re: Does system.gc() really help your app to get more efficient?
Posted:
Sep 29, 2008 1:16 AM
in response to: sub7
|
|
|
Any j2me experienced programmer/guru will tell you not to use gc() as the kvm is wise enough to know when it needs to call gc.
In many MIDlets I've done I used System.gc() a lot, just in places such as after loading a big amount of images, data, or after performing any operation that would leave _a lot_ of objects that were ready to being collected. It will probably make the app slower, but you can avoid OutOfMemoryExceptions (for a larger period of time at least :P)
Regards
|
|
|
|
|
|
|
|
Re: Does system.gc() really help your app to get more efficient?
Posted:
Sep 29, 2008 8:28 AM
in response to: kawaiimomo
|
|
|
> In many MIDlets I've done I used System.gc() a lot, > just in places such as after loading a big amount of > images, data, or after performing any operation that > would leave _a lot_ of objects that were ready to > being collected. It will probably make the app > slower, but you can avoid OutOfMemoryExceptions (for > a larger period of time at least :P)
As long as the garbage collector in your JVM is not broken, you should never get an OOME only because you 'forgot' to call System.gc()! Either objects are still referenced and cannot be GCed or they are not referenced and can be GCed - no matter if you call gc() yourself or let the VM decide when to do it.
So the plain advice is: don't call System.gc() unless in very very very rare cases
|
|
|
|
|
|
|
|
Re: Does system.gc() really help your app to get more efficient?
Posted:
Sep 29, 2008 4:37 AM
in response to: sub7
|
|
|
|
|
Hi, don't use System.gc(): http://lwuit.blogspot.com/2008/06/memory-leaks-in-lwuit-and- tracking.html http://lwuit.blogspot.com/2008/06/is-device-fragmentation-still- relevant.html
> Hi, > > although i develop mobile apps using J2ME everyday, i still want to > know real truth of pros/cons of calling system.gc(). I know some > of it like it will do the garbage collection ... >> avoid > outOfMemoryError... but My friends told me it will make your app > slower.. > > Anyone who got this knowledge (based on J2ME or any others platform > if you want to add..) ... please share to me and the others who > want to know.... > > Regards, > Sub7 > [Message sent by forum member 'sub7' (sub7)] > > http://forums.java.net/jive/thread.jspa?messageID=302289 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net > For additional commands, e-mail: users-help@lwuit.dev.java.net >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|