I'm working on a small game; I decided that the best approach for my purposes was to use char[]s internally and I wrote my own simple int->char[] method. As an aside, I generate and cache a set of bitmaps for the digits 0-9 and render the score using these, rather than with the canvas drawText methods (one version of which takes a char[] which is useful in performance sensitive situations).
Tom. 2009/5/25 Robert Green <rbgrn....@gmail.com> > > Awesome! Those are the assumptions I've been working under for months > and I'm so happy that I wasn't way off on one of them! > > I found that the standalone DDMS has an allocation tracker which is > exactly the tool I needed. I immediately found my problem. Two > problems: > > 1) I keep a running score on screen. The StringBuffer I'm using to > build this is causing all types of char[] and String allocations. I'm > not sure what I can do about that. > 2) Calling Canvas.getMatrix() allocates a new matrix if one isn't > currently being used. Interesting. I'll be able to work around that. > > Any ideas on what I can do about those strings? Basically I need to > display #### Pts for the current score. > > On May 25, 3:34 pm, Mark Murphy <mmur...@commonsware.com> wrote: > > Robert Green wrote: > > > 1) Are local variables ever affected by GC if they never call new, > > > either explicitly or implicitly? > > > -- I'm asking if I have a field that is "private ArrayList<Dog> > > > dogList;" and in my method, I say "ArrayList<Dog> dogList = > > > this.dogList;" - that doesn't have any impact on GC, correct? It's > > > just a pointer on the stack, right? > > > > The pointer is on the stack. The ArrayList itself and its Dogs are on > > the heap. > > > > > 2) What about local variable arrays? Do those go in the heap (short > > > lived, GC) or on the stack? > > > > The array is on the stack. If the array is a primitive array (int[]), > > that covers everything. If the array is of objects (Dog[]), the Dog > > instances are from the heap. > > > > -- > > Mark Murphy (a Commons Guy)http://commonsware.com| > http://twitter.com/commonsguy > > > > Need help for your Android OSS project?http://wiki.andmob.org/hado > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---