The easiest way to find out what is being allocated is to use DDMS'
allocations tracker. Launch DDMS (the *stand alone* version, not the
one in Eclipse), swtich to the Allocation Track tab, select your
process, hit "Start tracking", play with your app, then hit "Get
allocations." Each allocation will be shown with the stack trace to
its origin.

On Mon, May 25, 2009 at 1:13 PM, Robert Green <[email protected]> wrote:
>
> Yes, I've done an HPROF and have it open in Eclipse Memory Analyzer
> but it doesn't appear to be telling me what is being GCed.  It looks
> like it's the result post-GC and is more suitable for memory usage and
> leak detection.  I could be missing something, though.  Anyone?
>
> On May 25, 3:08 pm, Marco Nelissen <[email protected]> wrote:
>> Have you tried using hprof/jhat ?
>> Seehttp://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=d...
>>
>> On Mon, May 25, 2009 at 1:02 PM, Robert Green <[email protected]> wrote:
>>
>> > For the past 2 months of development, I've followed the android
>> > performance guidelines here -
>> >http://developer.android.com/guide/practices/design/performance.html
>> > - to the tee.
>>
>> > I always cache field lookups if the field is referenced more than once
>> > in a method.  I was under the assumption that since the local variable
>> > is simply a pointer to the field, that it will be on the stack and
>> > will not need to be "cleaned" up, just like a local variable that is a
>> > primitive.  Is this correct?
>>
>> > I'm very, very careful not to not allocate, that is, declare new
>> > objects in my main loop.  With that said, I'm having a problem where
>> > I'm having about 54200 objects GCed every 55 seconds while the game is
>> > running.  That translates to about 1000 objects per second, or at
>> > 60FPS (which my game runs at on the emulator), about 16 short-life
>> > objects per loop.
>>
>> > I have absolutely scoured my code to make sure that I'm not creating
>> > anything.  I must be missing something though.  Here are my questions:
>>
>> > 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?
>> > -- I understand that the word "new" doesn't need to be obvious because
>> > really any method can create something new and return it.
>>
>> > 2)  What about local variable arrays?  Do those go in the heap (short
>> > lived, GC) or on the stack?
>>
>> > 3)  I did an hprof dump but it's not giving me the information I
>> > need.  I'd really like to profile what is being GCed so I can figure
>> > out what's being allocated 16 times per tick.
>>
>> > Thanks for all your help!
>>
>>
> >
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to