views:

673

answers:

2

when i run my program, logcat shows a lot of activity with GC

like

GC freed 10324 objects/ 510376 bytes in 103 ms
GC freed 10324 objects/ 510376 bytes in 103 ms
GC freed 10324 objects/ 510376 bytes in 103 ms
GC freed 10324 objects/ 510376 bytes in 103 ms
GC freed 10324 objects/ 510376 bytes in 103 ms

with diff in obj, bytes and ms values...

is it because of some bad practice of coding ?

+2  A: 

If your program dont necessarily needs to dispose of that many objects, then yes. Otherwise, no. If your program needs to run faster or is for example a game that needs to run smooth at all times, then you might try re-using objects to a greater extent.

sandis
@sandis is there any way for us to know which of our objects are getting garbage collected, for us to re arrange its creation and use.
Sumit M Asok
Sorry, not to my knowledge. Make a new question out of it and maybe someone will help.
sandis
+2  A: 

Use the standalone DDMS program and its Allocation Tracker tab to check where/what is being allocated. The DDMS program ships with the sdk. (This is not the same as the ddms tab in Eclipse.)

Al