One line causing lots of garbage collection. String.format with float. Help?

by Marco Nelissen » Tue, 14 Apr 2009 11:40:38 GMT


Sponsored Links
 Don't use String.format(). It creates all kinds of temporary objects
every time you call it.
Instead, create a single StringBuilder and Formatter, and then reuse
those every time you need to format a string.





--~--~---------~--~----~------------~-------~--~----~



One line causing lots of garbage collection. String.format with float. Help?

by Raphael » Tue, 14 Apr 2009 13:04:32 GMT


 First you should try to use StringBuilder, which is the
non-synchronized version of StringBuffer.

Next you could just write:

String price = String.format("$ %.2f",pricef);

which saves you a temporary StringBuffer allocation.

R/





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. video player - native application

Hi,
I'm looking for a native video player application, which can be run in
background (like command line), when other applications launched by
ActivityManager are active in foreground.,

My requirement is - to launch video playback in a auxiliary display
device, while regular display panel will be active with regular
android apps (menu/lock screen/browser/...)

Closest i've come across is stagefright app, but its not complete
video player usecase.
any open core native test app, which can substitute Android media player?

Thanks,
Deva

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. OOT; Kenapa yah ?

Suka terima email isinya gini :

=))..:p..:p.=))K...:p....K:p=))€€
:D:pDlt;=-PD=))

--
Jus* || cupcake,donut,eclair or froyo sama2 enak and its android-google || ~ http://jus2005.multiply.com ~ -- "Indonesian Android Community [id-android]"

3. Why do I get "XmlPullParserException: attr value delimiter missing!" when use XmlPullParser to parse page in Android

4. Cannot Write file into SDCard

5. Inject flexi di moto droid

6. Developer Console - update "Total" download count

7. the problem of Geocoder.getFromLocationName()