SlideShare a Scribd company logo
Android App Performance
Altaf ur Rehman
Avoid Creating
Unnecessary objects
• Generally speaking, avoid creating short-term
temporary objects if you can. Fewer objects created
mean less-frequent garbage collection, which has a
direct impact on user experience.
Avoid Internal Getter/Setter
• Android uses Indexing mechanism for methods.
• Direct field access is about 7x faster than invoking a getter
• Moral of story don’t create unnecessary methods.
Prefer Static Over Virtual
• If you don't need to access an object's fields,
make your method static. Invocations will be
about 15%-20% faster. It's also good practice,
because you can tell from the method signature
that calling the method can't alter the object's
state.
Use Static Final For Constants
• Consider the following declaration.
• static int intVal = 42;
• static String strVal = "Hello, world!”;
• We can improve matters with the "final" keyword
• static final int intVal = 42;
• static final String strVal = "Hello, world!";
Use Enhanced For Loop Syntax
• Use enhanced for loop(sometimes called for-each)
• 3x times faster than Iterable interface.
Recycle Complex Java objects
• We have a GC, but usually better to just create
less garbage that it has to clean up.
• BitmapFactory.recyle()
• Matcher.reset(newString)
• StringBuilder.setLength(0)
Avoid Using Floating-Point
• As a rule of thumb, floating-point is about 2x slower than
integer on Android-powered devices.
• In speed terms, there's no difference between float and
double on the more modern hardware. Space-wise,
double is 2x larger. As with desktop machines, assuming
space isn't an issue, you should prefer double to float.
Know and Use the Libraries
• Don’t re-invent the wheel.
• System.arrayCopy() is 9x faster then hand-coded
looped copy.
• It is not applied to third party libraries
• Moral of the story “Know your resources”
Myths
• On devices without a JIT, it is true that invoking methods
via a variable with an exact type rather than an interface is
slightly more efficient. (So, for example, it was cheaper to
invoke methods on a HashMap map than a Map map,
even though in both cases the map was a HashMap.) It
was not the case that this was 2x slower; the actual
difference was more like 6% slower. Furthermore, the JIT
makes the two effectively indistinguishable.
Use ViewHolder Pattern
Use Native Methods Carefully
• Developing your app with native code using the
Android NDK isn't necessarily more efficient than
programming with the Java language.
• Native code is primarily useful when you have an
existing native codebase that you want to port to
Android, not for "speeding up" parts of your Android
app written with the Java language.
Background continuous
processing
• Threads
• Handler.
• BroadcastReceiver
• User AlarmManager for continuous running task.
Re-using Layout
• Use <include> Tag
• Use <merge> Tag

More Related Content

PPTX
Coding Best Practices For Memory Management
PPTX
Chronicles Of Garbage Collection (GC)
PPT
Optimizing Java Performance
PDF
Tips for Using The Maxiscan MS509 | VtoolShop
PPT
Task 13 tv listings magazine front cover
PPT
Task 2 cost grid
PPTX
PPT
Task 9 block design
Coding Best Practices For Memory Management
Chronicles Of Garbage Collection (GC)
Optimizing Java Performance
Tips for Using The Maxiscan MS509 | VtoolShop
Task 13 tv listings magazine front cover
Task 2 cost grid
Task 9 block design

Similar to Android App Performance (20)

PDF
Java performance
PDF
Android, the life of your app
PDF
Ask the expert - App performance on Series 40 phones
PDF
Android Best Practices - Thoughts from the Trenches
PPTX
Performance #5 cpu and battery
PDF
Android memory and performance optimization
PDF
Android memory and performance optimization
PDF
Android memory and performance optimization
PDF
How can JAVA Performance tuning speed up applications.pdf
PPTX
Android Performance Tips & Tricks
PPTX
Сергей Жук "Android Performance Tips & Tricks"
PPTX
How to create Great App
PDF
Droid con
PDF
The Good, the Bad and the Ugly things to do with android
PDF
O sucesso do seu app está nos detalhes!
PDF
Android UI Tips, Tricks and Techniques
PDF
Android UI Development: Tips, Tricks, and Techniques
PDF
Java Performance Tuning
PPTX
Evaluating the Impact of Android Best Practices on Energy Consumption
PDF
Profiling tools and Android Performance patterns
Java performance
Android, the life of your app
Ask the expert - App performance on Series 40 phones
Android Best Practices - Thoughts from the Trenches
Performance #5 cpu and battery
Android memory and performance optimization
Android memory and performance optimization
Android memory and performance optimization
How can JAVA Performance tuning speed up applications.pdf
Android Performance Tips & Tricks
Сергей Жук "Android Performance Tips & Tricks"
How to create Great App
Droid con
The Good, the Bad and the Ugly things to do with android
O sucesso do seu app está nos detalhes!
Android UI Tips, Tricks and Techniques
Android UI Development: Tips, Tricks, and Techniques
Java Performance Tuning
Evaluating the Impact of Android Best Practices on Energy Consumption
Profiling tools and Android Performance patterns
Ad

Recently uploaded (20)

PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
cuic standard and advanced reporting.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
Dropbox Q2 2025 Financial Results & Investor Presentation
cuic standard and advanced reporting.pdf
Spectroscopy.pptx food analysis technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
Diabetes mellitus diagnosis method based random forest with bat algorithm
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Ad

Android App Performance

  • 2. Avoid Creating Unnecessary objects • Generally speaking, avoid creating short-term temporary objects if you can. Fewer objects created mean less-frequent garbage collection, which has a direct impact on user experience.
  • 3. Avoid Internal Getter/Setter • Android uses Indexing mechanism for methods. • Direct field access is about 7x faster than invoking a getter • Moral of story don’t create unnecessary methods.
  • 4. Prefer Static Over Virtual • If you don't need to access an object's fields, make your method static. Invocations will be about 15%-20% faster. It's also good practice, because you can tell from the method signature that calling the method can't alter the object's state.
  • 5. Use Static Final For Constants • Consider the following declaration. • static int intVal = 42; • static String strVal = "Hello, world!”; • We can improve matters with the "final" keyword • static final int intVal = 42; • static final String strVal = "Hello, world!";
  • 6. Use Enhanced For Loop Syntax • Use enhanced for loop(sometimes called for-each) • 3x times faster than Iterable interface.
  • 7. Recycle Complex Java objects • We have a GC, but usually better to just create less garbage that it has to clean up. • BitmapFactory.recyle() • Matcher.reset(newString) • StringBuilder.setLength(0)
  • 8. Avoid Using Floating-Point • As a rule of thumb, floating-point is about 2x slower than integer on Android-powered devices. • In speed terms, there's no difference between float and double on the more modern hardware. Space-wise, double is 2x larger. As with desktop machines, assuming space isn't an issue, you should prefer double to float.
  • 9. Know and Use the Libraries • Don’t re-invent the wheel. • System.arrayCopy() is 9x faster then hand-coded looped copy. • It is not applied to third party libraries • Moral of the story “Know your resources”
  • 10. Myths • On devices without a JIT, it is true that invoking methods via a variable with an exact type rather than an interface is slightly more efficient. (So, for example, it was cheaper to invoke methods on a HashMap map than a Map map, even though in both cases the map was a HashMap.) It was not the case that this was 2x slower; the actual difference was more like 6% slower. Furthermore, the JIT makes the two effectively indistinguishable.
  • 12. Use Native Methods Carefully • Developing your app with native code using the Android NDK isn't necessarily more efficient than programming with the Java language. • Native code is primarily useful when you have an existing native codebase that you want to port to Android, not for "speeding up" parts of your Android app written with the Java language.
  • 13. Background continuous processing • Threads • Handler. • BroadcastReceiver • User AlarmManager for continuous running task.
  • 14. Re-using Layout • Use <include> Tag • Use <merge> Tag