Share
Embed
Getting Control Over Your Unit Tests and Build Memory Footprint
As mobile apps developers we usually care about the app’s memory footprint at runtime but we don’t feel the need to do the same for build and unit tests!
In this talk we will be doing a deep dive into how unit tests use JVM memory and how it may impact their stability and how it's related to the Gradle build... Yes, lots of hows to be answered 😄
Oussama Hafferssas
April 12, 2023
Transcript
87 slides
-
Getting Control Memory Footprint Unit Tests and Build Oussama Hafferssas
Senior Android Engineer at Trainline Over Your 12 April 2023 -
Getting Control Memory Footprint Unit Tests and Build Oussama Hafferssas
Over Your 12 April 2023 -
Getting Control Unit Tests and Build Oussama Hafferssas 12 April
2023 Memory Footprint -
Getting Control Oussama Hafferssas 12 April 2023 Understand Unit Tests
and Build Memory Footprint -
Getting Control Oussama Hafferssas 12 April 2023 Understand Unit Tests
and Build Memory Footprint -
Getting Control Oussama Hafferssas 12 April 2023 Understand Unit Tests
and Build Memory Footprint Not on device/AVD -
Getting Control Oussama Hafferssas 12 April 2023 Understand Unit Tests
and Build Memory Footprint Computer / CI -
Getting Control Oussama Hafferssas 12 April 2023 Understand Unit Tests
and Build Memory Footprint Dev Environment -
Getting Control Oussama Hafferssas 12 April 2023 Understand Unit Tests
and Build Memory Footprint Dev Environment -
Getting Control Oussama Hafferssas 12 April 2023 Understand Unit Tests
and Build Memory Footprint JVM Dev Environment -
Oussama Hafferssas 12 April 2023 Understand Dev Environment JVM Getting
Control Memory Footprint Unit Tests and Build Over Your how the handles memory on -
Oussama Hafferssas 12 April 2023 Understand Dev Environment JVM Getting
Control Memory Footprint Unit Tests and Build Over Your how the handles memory on … during unit tests and build -
Oussama Hafferssas 12 April 2023 Understand Dev Environment JVM Getting
Control Memory Footprint Unit Tests and Build Over Your how the handles memory on … during unit tests and build Naming things Finding talk titles is hard… -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your WHY? -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your WHY? Features / Fixes Dev team Unit tests on CI -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your WHY? Features / Fixes Dev team Unit tests on CI -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your WHY? Features / Fixes Dev team Unit tests on CI -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your WHY? Features / Fixes Dev team Unit tests on CI -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your WHY? OutOfMemory Exception JVM Crashed because of an OutOfMemory Exception -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest !" gradle.properties file org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest !" gradle.properties file org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests Demo time! https://github.com/duckduckgo/Android Gradle Workers -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 Building/compiling sources of unit tests Running unit tests -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your OutOfMemory Exception during unit tests ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 Building/compiling sources of unit tests Running unit tests -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 Building/compiling sources of unit tests Running unit tests OutOfMemory Exception during unit tests -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 Building/compiling sources of unit tests Running unit tests OutOfMemory Exception during unit tests -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 Building/compiling sources of unit tests Running unit tests OutOfMemory Exception during unit tests -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 Building/compiling sources of unit tests Running unit tests OutOfMemory Exception during unit tests build.gradle gradle.properties android { testOptions { unitTests.all { maxHeapSize = "768m" } } -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your Demo time! https://github.com/duckduckgo/Android Heap size change -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your ./gradlew testDebugUnitTest Daemon :assemble :compileDebugUnitTestSources org.gradle.jvmargs=-Xmx6136m GradleWorker #1 GradleWorker #2 GradleWorker #3 GradleWorker #4 Building/compiling sources of unit tests Running unit tests OutOfMemory Exception during unit tests build.gradle gradle.properties android { testOptions { unitTests.all { maxHeapSize = "768m" } } -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Daemon Gradle Worker #1 build.gradle Gradle Worker #4 Gradle Worker #2 Gradle Worker #3 Getting Control android { testOptions { unitTests.all { maxHeapSize = "768m" } } -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Daemon Gradle Worker #1 build.gradle Gradle Worker #4 Gradle Worker #2 Gradle Worker #3 Getting Control OOM android { testOptions { unitTests.all { maxHeapSize = "768m" } } -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Daemon Gradle Worker #1 build.gradle Gradle Worker #4 Gradle Worker #2 Gradle Worker #3 Getting Control OOM android { testOptions { unitTests.all { maxHeapSize = "768m" jvmArgs '-XX:+HeapDumpOnOutOfMemoryError' } } -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Daemon Gradle Worker #1 build.gradle Gradle Worker #4 Gradle Worker #2 Gradle Worker #3 Getting Control OOM android { testOptions { unitTests.all { maxHeapSize = "768m" jvmArgs '-XX:+HeapDumpOnOutOfMemoryError' } } ! Memory consumption evolution " Heap dump inspection -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control ! Memory consumption evolution " Heap dump inspection Next: -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control ! Memory consumption evolution " Heap dump inspection Next: -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control " Heap dump inspection ! Memory consumption evolution Previously: -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your Demo time! https://github.com/duckduckgo/Android IntelliJ IDEA profiler -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control " Heap dump inspection ! Memory consumption evolution Previously: -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control " Heap dump inspection ! Memory consumption evolution Previously: -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control " Heap dump inspection ! Memory consumption evolution Previously: -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control " Heap dump inspection ! Memory consumption evolution Previously: class ClearInlineMocksRule : TestWatcher() { override fun finished(description: Description) { Mockito.framework().clearInlineMocks() } } -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control " Heap dump inspection ! Memory consumption evolution class ClearInlineMocksRule : TestWatcher() { override fun finished(description: Description) { Mockito.framework().clearInlineMocks() } } + ➡ ➡ -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control OutOfMemory Exception JVM Crashed because of an OutOfMemory Exception -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control OutOfMemory Exception JVM Crashed because of an OutOfMemory Exception -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Daemon Gradle Worker #1 Gradle Worker #4 Gradle Worker #2 Gradle Worker #3 Getting Control OOM android { testOptions { unitTests.all { maxHeapSize = "768m" jvmArgs '-XX:+HeapDumpOnOutOfMemoryError' } } JVM Crashed because of an OutOfMemory Exception org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Daemon Gradle Worker #1 Gradle Worker #4 Gradle Worker #2 Gradle Worker #3 Getting Control OOM android { testOptions { unitTests.all { maxHeapSize = "768m" jvmArgs '-XX:+HeapDumpOnOutOfMemoryError' } } JVM Crashed because of an OutOfMemory Exception org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Daemon Gradle Worker #1 Gradle Worker #4 Gradle Worker #2 Gradle Worker #3 Getting Control OOM android { testOptions { unitTests.all { maxHeapSize = "768m" jvmArgs '-XX:+HeapDumpOnOutOfMemoryError' } } JVM Crashed because of an OutOfMemory Exception org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control OOM android { testOptions { unitTests.all { maxHeapSize = "768m" jvmArgs '-XX:+HeapDumpOnOutOfMemoryError' } } JVM Crashed because of an OutOfMemory Exception org.gradle.jvmargs=-Xmx6136m -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control OOM JVM Crashed because of an OutOfMemory Exception JVM Heap Memory -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception JVM Heap Memory NON Heap Memory -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception JVM Heap Memory NON Heap Memory Up to 10% of heap! -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception JVM Heap Memory NON Heap Memory Up to 10% of heap! 768 MB -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception JVM Heap Memory NON Heap Memory Up to 10% of heap! 768 MB 768 MB -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception JVM Heap Memory NON Heap Memory Up to 10% of heap! 768 MB 768 MB 4 GB -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception 768 MB 768 MB 4 GB $ -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception 768 MB 768 MB 4 GB $ The solution: JVM tuning The process of adjusting the default parameters to match our application needs -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception 768 MB 768 MB 4 GB $ The solution: JVM tuning The process of adjusting the default parameters to match our application needs -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception 768 MB 768 MB 4 GB $ The solution: JVM tuning The process of adjusting the default parameters to match our application needs -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control JVM Crashed because of an OutOfMemory Exception 768 MB 768 MB 4 GB The solution: JVM tuning The process of adjusting the default parameters to match our application needs -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control 768 MB 768 MB 4 GB The solution: JVM tuning The process of adjusting the default parameters to match our application needs How: JPS Java Process Tools JVM Crashed because of an OutOfMemory Exception -
Oussama Hafferssas 12 April 2023 Getting Control Memory Footprint Unit
Tests and Build Over Your Demo time! https://github.com/duckduckgo/Android JPS -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your 6 GB 768 MB 768 MB 768 MB 768 MB Getting Control 768 MB 768 MB 4 GB The solution: JVM tuning The process of adjusting the default parameters to match our application needs How: JPS Java Process Tools JVM Crashed because of an OutOfMemory Exception -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control Takeaways • Memory issues are hard! -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control Takeaways • Memory issues are hard! • Choose your tools -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control Takeaways • Memory issues are hard! • Choose your tools • Profiler • Scripts -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control Takeaways • Memory issues are hard! • Choose your tools • Profiler • Scripts • Look everywhere (codebase + libraries) -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control Takeaways • Memory issues are hard! • Choose your tools • Profiler • Scripts • Look everywhere (codebase + libraries) • Think holistically -
Oussama Hafferssas 12 April 2023 Memory Footprint Unit Tests and
Build Over Your Getting Control Takeaways • Memory issues are hard! • Choose your tools • Profiler • Scripts • Try to be patient • Look everywhere (codebase + libraries) • Think holistically -
Getting Control And Build Memory Footprint Unit Tests Oussama Hafferssas
Over Your Thank you