SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Использование debug утилит
  в разработке под Android



                     Антоненко Вячеслав
                            Android developer
                                     24.06.2011

                            1
Friday, July 1, 11
Утилиты


                     Memory Analyzer (MAT)
                          Traceview
                       Hierarchyviewer
                          Layoutopt
                            Logcat




Friday, July 1, 11
Поиск утечки памяти


                            Анализ логов
                        Причины утечки памяти
                           Memory Analyzer




Friday, July 1, 11
Анализ лога


            D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65%
             free 3571K/9991K, external 4703K/5261K, paused 2ms
                                    +2ms




Friday, July 1, 11
Анализ лога
          D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65%
          free 3571K/9991K, external 4703K/5261K, paused 2ms
          +2ms

          Причина GC
          •GC_CONCURRENT
          •GC_FOR_MALLOC
          •GC_EXTERNAL_ALLOC
          •GC_HPROF_DUMP_HEAP
          •GC_EXPLICIT




Friday, July 1, 11
Анализ лога
          D/dalvikvm( 3215): GC_CONCURRENT freed 2049K,
          65% free 3571K/9991K, external 4703K/5261K,
          paused 2ms+2ms

           Reason for GC
           Amount freed




Friday, July 1, 11
Анализ лога
          D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65%
          free 3571K/9991K, external 4703K/5261K, paused 2ms
          +2ms

           Reason for GC
           Amount freed
           Heap statistics




Friday, July 1, 11
Анализ лога
          D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65%
          free 3571K/9991K, external 4703K/5261K, paused 2ms
          +2ms

           Reason for GC
           Amount freed
           Heap statistics
           External memory statistics




Friday, July 1, 11
Анализ лога
          D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65%
          free 3571K/9991K, external 4703K/5261K, paused 2ms
          +2ms

           Reason for GC
           Amount freed
           Heap statistics
           External memory statistics
           Pause time




Friday, July 1, 11
Причины утечки памяти

                      Ссылки на не используемые объекты

                        Ссылки на Acitvity, Drawable, View

                     Долго живущие статические переменные

                       Не статические внутренние классы




Friday, July 1, 11
Получение дампа памяти

           Получение дампа
             –DDMS
             –android.os.Debug.dumpHprofData()
           Конвертация в стандартный HPROF
          формат
             –hprof-con dump.hprof converted_dump.hprof
           Анализ при помощи MAT



Friday, July 1, 11
Демонстрация примера
                         работы с MAT




Friday, July 1, 11
Friday, July 1, 11
Friday, July 1, 11
Оптимизация скорости
                      работы приложения


       Поиск узких мест в приложении

       Оптимизация пользовательских элементов управления




Friday, July 1, 11
Поиск «узких» мест в приложении



                         Утилиты:

                        Traceview
                     Режим StrictMode




Friday, July 1, 11
Использование Traceview
                            из Eclipse




Friday, July 1, 11
Использование Traceview
                             из кода

        android.os.Debug.startMethodTracing("trace_file_name");
            // your code is here
        android.os.Debug.stopMethodTracing();

        Необходимо установить разрешение на WRITE_EXTERNAL_STORAGE

        Получение trace из устройства

        adb pull /sdcard/trace_file_name.trace
        Traceview trace_file_name




Friday, July 1, 11
Режим StrictMode


        StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder().detectAll()
        .penaltyLog().build());

        StrictMode.setVmPolicy(
        new StrictMode.VmPolicy.Builder().detectAll().
        penaltyLog().build());




Friday, July 1, 11
Friday, July 1, 11
…
        StrictMode(13858):
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:758)
             …
        StrictMode(13858):
        at com.softtechnics.mobiletalk.traceview.MobileTalkOptTraceViewActivity
        .onCreate(MobileTalkOptTraceViewActivity.java:25)
             …




Friday, July 1, 11
Оптимизация пользовательских
              элементов


        Утилиты

         hierarchyviewer
         layoutopt




Friday, July 1, 11
<?xml version="1.0" encoding="utf-8"?>
        <FrameLayout
             xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="match_parent"
             android:layout_height="match_parent">
             <View
                    android:layout_width="fill_parent"
                    android:layout_height="120dip"
                    android:background="@drawable/gradient_ligh_perfor_bg_bmp" />
             <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:paddingLeft="20dip"
                    android:paddingRight="20dip"
                    android:paddingTop="55dip">
             <EditText
                    android:id="@+id/email"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:inputType="textEmailAddress"
                    android:background="@drawable/reg_pole"
                    android:hint="@string/hint_email"
                    android:textColorHint="#545353"
                    android:lines="1" />
                    //some code ...
             </RelativeLayout>
        </FrameLayout>




Friday, July 1, 11
Friday, July 1, 11
<?xml version="1.0" encoding="utf-8"?>
        <merge
             xmlns:android="http://schemas.android.com/apk/res/android">
             <View
                    android:layout_width="fill_parent"
                    android:layout_height="120dip"
                    android:background="@drawable/gradient_ligh_perfor_bg_bmp" />
             <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:paddingLeft="20dip"
                    android:paddingRight="20dip"
                    android:paddingTop="55dip">
             <EditText
                    android:id="@+id/email"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:inputType="textEmailAddress"
                    android:background="@drawable/reg_pole"
                    android:hint="@string/hint_email"
                    android:textColorHint="#545353"
                    android:lines="1" />
                    //some code ...
             </RelativeLayout>
        </merge>




Friday, July 1, 11
Friday, July 1, 11
Использование Layoutopt

        layoutopt MobileTalkOptUI/res/layout/

        MobileTalkOptUI/res/layout/pay.xml
        31:607 This ScrollView layout or its LinearLayout parent is possibly useless
        36:606 This LinearLayout tag should use android:layout_height="wrap_content«
        78:91 This tag and its children can be replaced by one <TextView/> and a compound drawable
        118:130 This LinearLayout layout or its LinearLayout parent is useless
        129:129 Use an android:layout_height of 0dip instead of wrap_content for better performance
        148:161 This LinearLayout layout or its LinearLayout parent is useless
        160:160 Use an android:layout_height of 0dip instead of wrap_content for better performance

        MobileTalkOptUI/res/layout/main.xml




Friday, July 1, 11
Спасибо за внимание!




                                     ул. Михайловская 25
                                     Одесса 65005, Украина
                                     www.softtechnics.biz


Friday, July 1, 11

Contenu connexe

En vedette

Rassegna bibliografica su Michelstaedter
Rassegna bibliografica su MichelstaedterRassegna bibliografica su Michelstaedter
Rassegna bibliografica su MichelstaedterGabriella Giudici
 
Le trasformazioni di internet dopo la nascita del file sharing
Le trasformazioni di internet dopo la nascita del file sharingLe trasformazioni di internet dopo la nascita del file sharing
Le trasformazioni di internet dopo la nascita del file sharingGabriella Giudici
 
Cap17parr127 131 causa, generazione e definizione dello stato
Cap17parr127 131 causa, generazione e definizione dello statoCap17parr127 131 causa, generazione e definizione dello stato
Cap17parr127 131 causa, generazione e definizione dello statoGabriella Giudici
 
Jervis, Introduzione a Adorno et al, La Personalità autoritaria
Jervis, Introduzione a Adorno et al, La Personalità autoritaria Jervis, Introduzione a Adorno et al, La Personalità autoritaria
Jervis, Introduzione a Adorno et al, La Personalità autoritaria Gabriella Giudici
 
Getting Started Appendices may 14_2010
Getting Started Appendices may 14_2010Getting Started Appendices may 14_2010
Getting Started Appendices may 14_2010i4ppis
 
Introduction to descriptive writing
Introduction to descriptive writingIntroduction to descriptive writing
Introduction to descriptive writingenglishteacher-tnt
 

En vedette (10)

About this course final show
About this course final showAbout this course final show
About this course final show
 
Intervista a pablo pineda
Intervista a pablo pinedaIntervista a pablo pineda
Intervista a pablo pineda
 
Rassegna bibliografica su Michelstaedter
Rassegna bibliografica su MichelstaedterRassegna bibliografica su Michelstaedter
Rassegna bibliografica su Michelstaedter
 
Le trasformazioni di internet dopo la nascita del file sharing
Le trasformazioni di internet dopo la nascita del file sharingLe trasformazioni di internet dopo la nascita del file sharing
Le trasformazioni di internet dopo la nascita del file sharing
 
Cap17parr127 131 causa, generazione e definizione dello stato
Cap17parr127 131 causa, generazione e definizione dello statoCap17parr127 131 causa, generazione e definizione dello stato
Cap17parr127 131 causa, generazione e definizione dello stato
 
Jervis, Introduzione a Adorno et al, La Personalità autoritaria
Jervis, Introduzione a Adorno et al, La Personalità autoritaria Jervis, Introduzione a Adorno et al, La Personalità autoritaria
Jervis, Introduzione a Adorno et al, La Personalità autoritaria
 
Stella, DSA un'introduzione
Stella, DSA un'introduzioneStella, DSA un'introduzione
Stella, DSA un'introduzione
 
About this course
About this courseAbout this course
About this course
 
Getting Started Appendices may 14_2010
Getting Started Appendices may 14_2010Getting Started Appendices may 14_2010
Getting Started Appendices may 14_2010
 
Introduction to descriptive writing
Introduction to descriptive writingIntroduction to descriptive writing
Introduction to descriptive writing
 

Similaire à Использование Debug утилит в разработке под Android

Google I/O 2021 Recap
Google I/O 2021 RecapGoogle I/O 2021 Recap
Google I/O 2021 Recapfurusin
 
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android AppsUsing Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android AppsLuis Cruz
 
Play Framework vs Grails Smackdown - JavaOne 2013
Play Framework vs Grails Smackdown - JavaOne 2013Play Framework vs Grails Smackdown - JavaOne 2013
Play Framework vs Grails Smackdown - JavaOne 2013Matt Raible
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Matt Raible
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 
XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>Arun Gupta
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android JetpackAhmad Arif Faizin
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
 
Step by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts ApplicationStep by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts Applicationelliando dias
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data scienceKenichi Sonoda
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?Brenda Cook
 
Optimizing Apps for Better Performance
Optimizing Apps for Better PerformanceOptimizing Apps for Better Performance
Optimizing Apps for Better PerformanceElif Boncuk
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog ArtifactoryTsuyoshi Miyake
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleJames Bayer
 
Compile ahead of time. It's fine?
Compile ahead of time. It's fine?Compile ahead of time. It's fine?
Compile ahead of time. It's fine?Dmitry Chuyko
 

Similaire à Использование Debug утилит в разработке под Android (20)

Google I/O 2021 Recap
Google I/O 2021 RecapGoogle I/O 2021 Recap
Google I/O 2021 Recap
 
Core Android
Core AndroidCore Android
Core Android
 
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android AppsUsing Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
 
Play Framework vs Grails Smackdown - JavaOne 2013
Play Framework vs Grails Smackdown - JavaOne 2013Play Framework vs Grails Smackdown - JavaOne 2013
Play Framework vs Grails Smackdown - JavaOne 2013
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Step by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts ApplicationStep by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts Application
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?
 
Optimizing Apps for Better Performance
Optimizing Apps for Better PerformanceOptimizing Apps for Better Performance
Optimizing Apps for Better Performance
 
Droidcon Paris 2015
Droidcon Paris 2015Droidcon Paris 2015
Droidcon Paris 2015
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog Artifactory
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
 
Compile ahead of time. It's fine?
Compile ahead of time. It's fine?Compile ahead of time. It's fine?
Compile ahead of time. It's fine?
 

Dernier

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Dernier (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Использование Debug утилит в разработке под Android

  • 1. Использование debug утилит в разработке под Android Антоненко Вячеслав Android developer 24.06.2011 1 Friday, July 1, 11
  • 2. Утилиты Memory Analyzer (MAT) Traceview Hierarchyviewer Layoutopt Logcat Friday, July 1, 11
  • 3. Поиск утечки памяти  Анализ логов  Причины утечки памяти  Memory Analyzer Friday, July 1, 11
  • 4. Анализ лога D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms +2ms Friday, July 1, 11
  • 5. Анализ лога D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms +2ms Причина GC •GC_CONCURRENT •GC_FOR_MALLOC •GC_EXTERNAL_ALLOC •GC_HPROF_DUMP_HEAP •GC_EXPLICIT Friday, July 1, 11
  • 6. Анализ лога D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms+2ms  Reason for GC  Amount freed Friday, July 1, 11
  • 7. Анализ лога D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms +2ms  Reason for GC  Amount freed  Heap statistics Friday, July 1, 11
  • 8. Анализ лога D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms +2ms  Reason for GC  Amount freed  Heap statistics  External memory statistics Friday, July 1, 11
  • 9. Анализ лога D/dalvikvm( 3215): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external 4703K/5261K, paused 2ms +2ms  Reason for GC  Amount freed  Heap statistics  External memory statistics  Pause time Friday, July 1, 11
  • 10. Причины утечки памяти  Ссылки на не используемые объекты  Ссылки на Acitvity, Drawable, View  Долго живущие статические переменные  Не статические внутренние классы Friday, July 1, 11
  • 11. Получение дампа памяти  Получение дампа –DDMS –android.os.Debug.dumpHprofData()  Конвертация в стандартный HPROF формат –hprof-con dump.hprof converted_dump.hprof  Анализ при помощи MAT Friday, July 1, 11
  • 12. Демонстрация примера работы с MAT Friday, July 1, 11
  • 15. Оптимизация скорости работы приложения  Поиск узких мест в приложении  Оптимизация пользовательских элементов управления Friday, July 1, 11
  • 16. Поиск «узких» мест в приложении Утилиты:  Traceview Режим StrictMode Friday, July 1, 11
  • 17. Использование Traceview из Eclipse Friday, July 1, 11
  • 18. Использование Traceview из кода android.os.Debug.startMethodTracing("trace_file_name"); // your code is here android.os.Debug.stopMethodTracing(); Необходимо установить разрешение на WRITE_EXTERNAL_STORAGE Получение trace из устройства adb pull /sdcard/trace_file_name.trace Traceview trace_file_name Friday, July 1, 11
  • 19. Режим StrictMode StrictMode.setThreadPolicy( new StrictMode.ThreadPolicy.Builder().detectAll() .penaltyLog().build()); StrictMode.setVmPolicy( new StrictMode.VmPolicy.Builder().detectAll(). penaltyLog().build()); Friday, July 1, 11
  • 21. StrictMode(13858): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:758) … StrictMode(13858): at com.softtechnics.mobiletalk.traceview.MobileTalkOptTraceViewActivity .onCreate(MobileTalkOptTraceViewActivity.java:25) … Friday, July 1, 11
  • 22. Оптимизация пользовательских элементов Утилиты  hierarchyviewer  layoutopt Friday, July 1, 11
  • 23. <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <View android:layout_width="fill_parent" android:layout_height="120dip" android:background="@drawable/gradient_ligh_perfor_bg_bmp" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="20dip" android:paddingRight="20dip" android:paddingTop="55dip"> <EditText android:id="@+id/email" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:inputType="textEmailAddress" android:background="@drawable/reg_pole" android:hint="@string/hint_email" android:textColorHint="#545353" android:lines="1" /> //some code ... </RelativeLayout> </FrameLayout> Friday, July 1, 11
  • 25. <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android"> <View android:layout_width="fill_parent" android:layout_height="120dip" android:background="@drawable/gradient_ligh_perfor_bg_bmp" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="20dip" android:paddingRight="20dip" android:paddingTop="55dip"> <EditText android:id="@+id/email" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:inputType="textEmailAddress" android:background="@drawable/reg_pole" android:hint="@string/hint_email" android:textColorHint="#545353" android:lines="1" /> //some code ... </RelativeLayout> </merge> Friday, July 1, 11
  • 27. Использование Layoutopt layoutopt MobileTalkOptUI/res/layout/ MobileTalkOptUI/res/layout/pay.xml 31:607 This ScrollView layout or its LinearLayout parent is possibly useless 36:606 This LinearLayout tag should use android:layout_height="wrap_content« 78:91 This tag and its children can be replaced by one <TextView/> and a compound drawable 118:130 This LinearLayout layout or its LinearLayout parent is useless 129:129 Use an android:layout_height of 0dip instead of wrap_content for better performance 148:161 This LinearLayout layout or its LinearLayout parent is useless 160:160 Use an android:layout_height of 0dip instead of wrap_content for better performance MobileTalkOptUI/res/layout/main.xml Friday, July 1, 11
  • 28. Спасибо за внимание! ул. Михайловская 25 Одесса 65005, Украина www.softtechnics.biz Friday, July 1, 11