[android-developers] Re: any tool in android to find memory leak and code optimization
I believe DDMS has much of what you need. For code profiling, search for 'TraceView' * you will want to add some UI to your app to let you toggle tracing on and off, so you can capture samples while your code is doing the thing you're interested in improving. For memory leak checking, you need to run the full DDMS (not the DDMS panel in eclipse), and you ideally should use that full DDMS to launch the app (either on a emulator or a real phone). If you let eclipse launch it, it will probably grab the access port and then the full DDMS won't be able to connect and you will scratch your head wondering why. You might start here: http://developer.android.com/guide/developing/tools/traceview.html http://developer.android.com/resources/articles/avoiding-memory-leaks.html http://developer.android.com/resources/articles/track-mem.html Note that TraceView might have a memory limit preventing you from capturing enough data. You can get around that by editing your copy of traceview.bat (in the sdk/tools folder I recall)... there is a line near the end that you change to look something like this: call %java_exe% -Xmx1024m -Djava.ext.dirs=%javaextdirs% - Dcom.android.traceview.toolsdir= -jar %jarpath% %* it's that "-Xmx1024m" that you change (it defaults to something smaller) And if you trace on a real phone, don't forget to give your app permission to write to the SDCARD. I believe the instructions imply you (in the emulator) can toggle tracing with F9 without needing to formally call: Debug.startMethodTracing("calc");// Debug.stopMethodTracing();// But that has not worked for me.So I always call those functions (at run time) to start/stop my sampling. On Sep 12, 1:09 pm, Sohan badaya wrote: > Hi All, > > I would like to know is there any tool in android to find memory leak > and code optimization. > > Thanks, > Sohan Badaya -- 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
[android-developers] Re: any tool in android to find memory leak and code optimization
You can also PMD for code analysis/optimization. -E On Sep 13, 12:20 pm, Xavier Ducrohet wrote: > On Sun, Sep 12, 2010 at 1:22 PM, Samsyn wrote: > > I believe DDMS has much of what you need. > > > For code profiling, search for 'TraceView' > > > * you will want to add some UI to your app to let you toggle tracing > > on and off, so you can capture samples while your code is doing the > > thing you're interested in improving. > > there's also a toggle in the DeviceView of DDMS that start/stops the > trace recording. Upon stopping it, it'll launch Traceview too. > > > For memory leak checking, you need to run the full DDMS (not the DDMS > > panel in eclipse), and you ideally should use that full DDMS to launch > > the app (either on a emulator or a real phone). If you let eclipse > > launch it, it will probably grab the access port and then the full > > DDMS won't be able to connect and you will scratch your head wondering > > why. > > Actually AllocationTracker is in the DDMS plug-in too now. > > Also DDMS has a dump hprof button. If you use from Eclipse it'll open > the .hprof in Eclipse. Install MAT (http://eclipse.org/mat/) which is > able to identify possible leaks. > > > And if you trace on a real phone, don't forget to give your app > > permission to write to the SDCARD. > > Unless you're running froyo. Starting with froyo (2.2), if you use the > "dump hprof" or "start/stop tracing" buttons in DDMS, the VM is able > to record the files locally and send them to DDMs through JDWP instead > of storing them on the SD Card (and then have DDMS pull them with > adb). > > For older VMs you will need to have your app use the SD Card permission > > Xav > -- > Xavier Ducrohet > Android SDK Tech Lead > Google Inc. > > Please do not send me questions directly. Thanks! -- 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
[android-developers] Re: any tool in android to find memory leak and code optimization
I found DDMS not sufficiently detailed to find memory leaks, so I use MAT. For full step-by-step instructions on finding memory leaks and using MAT, I suggest this post: http://ttlnews.blogspot.com/2010/01/attacking-memory-problems-on-android.html On Sep 12, 10:09 pm, Sohan badaya wrote: > Hi All, > > I would like to know is there any tool in android to find memory leak > and code optimization. > > Thanks, > Sohan Badaya -- 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
[android-developers] Re: any tool in android to find memory leak and code optimization
Just wanted to add my vote for MAT being a life-saver. but hmm, I still don't see allocation tracker in the Eclipse DDMS plugin... and I *feeel* like I have the latest version.. but obviously I must not. Or I'm looking in the wrong place... or both.. :-) On Sep 13, 10:54 am, Xavier Ducrohet wrote: > I agree that MAT is best but that blog post makes it really > complicated to dump an hprof file. DDMS now takes care of most of it. > See my post earlier in this thread. > > > > > > On Mon, Sep 13, 2010 at 1:41 AM, MarcoAndroid wrote: > > I found DDMS not sufficiently detailed to find memory leaks, so I use > > MAT. > > For full step-by-step instructions on finding memory leaks and using > > MAT, I suggest this > > post:http://ttlnews.blogspot.com/2010/01/attacking-memory-problems-on-andr... > > > On Sep 12, 10:09 pm, Sohan badaya wrote: > >> Hi All, > > >> I would like to know is there any tool in android to find memory leak > >> and code optimization. > > >> Thanks, > >> Sohan Badaya > > > -- > > 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 > > -- > Xavier Ducrohet > Android SDK Tech Lead > Google Inc. > > Please do not send me questions directly. Thanks!- Hide quoted text - > > - Show quoted text - -- 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
[android-developers] Re: any tool in android to find memory leak and code optimization
Its not exactly what you want, but may provide you *some* help: There is a plugin called CodePro Tools that audits code and acts as a pedantic helper. Best regards, Daniel Monteiro On Sep 26, 6:53 pm, Samsyn wrote: > Just wanted to add my vote for MAT being a life-saver. > > but hmm, I still don't see allocation tracker in the Eclipse DDMS > plugin... and I *feeel* like I have the latest version.. but > obviously I must not. Or I'm looking in the wrong place... or > both.. :-) > > On Sep 13, 10:54 am, Xavier Ducrohet wrote:> I agree that > MAT is best but that blog post makes it really > > complicated to dump an hprof file. DDMS now takes care of most of it. > > See my post earlier in this thread. > > > On Mon, Sep 13, 2010 at 1:41 AM, MarcoAndroid wrote: > > > I found DDMS not sufficiently detailed to find memory leaks, so I use > > > MAT. > > > For full step-by-step instructions on finding memory leaks and using > > > MAT, I suggest this > > > post:http://ttlnews.blogspot.com/2010/01/attacking-memory-problems-on-andr... > > > > On Sep 12, 10:09 pm, Sohan badaya wrote: > > >> Hi All, > > > >> I would like to know is there any tool in android to find memory leak > > >> and code optimization. > > > >> Thanks, > > >> Sohan Badaya > > > > -- > > > 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 > > > -- > > Xavier Ducrohet > > Android SDK Tech Lead > > Google Inc. > > > Please do not send me questions directly. Thanks!- Hide quoted text - > > > - Show quoted text - -- 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
Re: [android-developers] Re: any tool in android to find memory leak and code optimization
On Sun, Sep 12, 2010 at 1:22 PM, Samsyn wrote: > I believe DDMS has much of what you need. > > For code profiling, search for 'TraceView' > > * you will want to add some UI to your app to let you toggle tracing > on and off, so you can capture samples while your code is doing the > thing you're interested in improving. there's also a toggle in the DeviceView of DDMS that start/stops the trace recording. Upon stopping it, it'll launch Traceview too. > For memory leak checking, you need to run the full DDMS (not the DDMS > panel in eclipse), and you ideally should use that full DDMS to launch > the app (either on a emulator or a real phone). If you let eclipse > launch it, it will probably grab the access port and then the full > DDMS won't be able to connect and you will scratch your head wondering > why. Actually AllocationTracker is in the DDMS plug-in too now. Also DDMS has a dump hprof button. If you use from Eclipse it'll open the .hprof in Eclipse. Install MAT (http://eclipse.org/mat/) which is able to identify possible leaks. > And if you trace on a real phone, don't forget to give your app > permission to write to the SDCARD. Unless you're running froyo. Starting with froyo (2.2), if you use the "dump hprof" or "start/stop tracing" buttons in DDMS, the VM is able to record the files locally and send them to DDMs through JDWP instead of storing them on the SD Card (and then have DDMS pull them with adb). For older VMs you will need to have your app use the SD Card permission Xav -- Xavier Ducrohet Android SDK Tech Lead Google Inc. Please do not send me questions directly. Thanks! -- 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
Re: [android-developers] Re: any tool in android to find memory leak and code optimization
I agree that MAT is best but that blog post makes it really complicated to dump an hprof file. DDMS now takes care of most of it. See my post earlier in this thread. On Mon, Sep 13, 2010 at 1:41 AM, MarcoAndroid wrote: > I found DDMS not sufficiently detailed to find memory leaks, so I use > MAT. > For full step-by-step instructions on finding memory leaks and using > MAT, I suggest this post: > http://ttlnews.blogspot.com/2010/01/attacking-memory-problems-on-android.html > > > On Sep 12, 10:09 pm, Sohan badaya wrote: >> Hi All, >> >> I would like to know is there any tool in android to find memory leak >> and code optimization. >> >> Thanks, >> Sohan Badaya > > -- > 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 > -- Xavier Ducrohet Android SDK Tech Lead Google Inc. Please do not send me questions directly. Thanks! -- 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