Skip to content

[BUG] Memory leak on sample sumup-android-sdk #279

Description

@TechnoprepaySolutions

Summary

I have been debugging a memory leak problem when using Sumup, I thought it was a problem in my code but to my surprize the problem also happens when running the sample com.sumup.sdksampleapp app.

Steps to Reproduce

Added Square canary and tried a transaction using Samsung Galaxy S22 and Android tablet (Fire 7 from Amazon), after connecting to the reader and cancel the transaction, a memory leak error report is created. Because of the Android terminal having 2GB it will run but eventually the app crashes when run out of memory

Add this line in dependencies
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")

Expected Behavior

Should not trigger a memory leak

Actual Behavior

Android device eventually runs out of memory and crashes the app

Android Version(s)

Which Android version(s) are affected? tested in Android 14 and 16)

Impacted Devices

Are there specific devices where you observe this problem? Samsung S22 and Amazon Fire 7 (12th generation)

Impacted Readers

Are there specific readers where you observe this problem? Tested in Solo lite and older Sumup readers

Firmware Version(s)

Are there specific firmware version(s) where you observe this problem? (This is typically the number on the front of the card reader screen when idle) tested in v2.2.1.29

Crash Log

If the issue is a crash, please paste the full crash log here inside code blocks.

Dependency Versions

Please provide the versions of the following dependencies:

  • SumUp SDK: 7.0
  • Kotlin:
  • Android Gradle Plugin:
  • Gradle:
  • Build: AI-251.26094.121.2513.14007798, 202508272258
    AS: Narwhal 3 Feature Drop | 2025.1.3
    AI-251.26094.121.2513.14007798, JRE 21.0.7+-13880790-b1038.58x64 JetBrains s.r.o., OS Windows 11(amd64) v10.0 , screens 1920x1080 (125%), 1920x1080 (100%)
    Android Gradle Plugin: 8.9.1
    Gradle: 8.14.4
    Gradle JDK: JetBrains Runtime 21.0.7
    NDK: from local.properties: (not specified), latest from SDK: (not found)
    CMake: from local.properties: (not specified), latest from SDK: 4.1.1, from PATH: (not found)

dependencies {
implementation(platform("androidx.compose:compose-bom:2025.04.01"))
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.activity:activity-compose:1.9.3")
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")

implementation("androidx.navigation:navigation-compose:2.8.5")

implementation("io.insert-koin:koin-android:3.5.6")
implementation("io.insert-koin:koin-androidx-compose:3.5.6")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")

implementation("com.sumup:merchant-sdk:7.0.0")
implementation("com.google.android.gms:play-services-location:21.3.0")

coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")
debugImplementation("androidx.compose.ui:ui-tooling")

}

Video / Screenshot

If available, please attach a video or screenshot demonstrating the issue.

Other Information

Any additional context that might help us investigate the issue.
Memory leak report:

HEAP ANALYSIS RESULT

2 APPLICATION LEAKS
References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.
549634 bytes retained by leaking objects
Signature: de955df14a17a58298886c138b7716d76cec6122
┬───
│ GC Root: System class

├─ android.provider.FontsContract class
│ Leaking: NO (SampleApplication↓ is not leaking and a class is never leaking)
│ ↓ static FontsContract.sContext
├─ com.sumup.app.SampleApplication instance
│ Leaking: NO (Application is a singleton)
│ mBase instance of android.app.ContextImpl
│ ↓ Application.mLoadedApk
│ ~~~~~~~~~~
├─ android.app.LoadedApk instance
│ Leaking: UNKNOWN
│ Retaining 15.6 MB in 12448 objects
│ mApplication instance of com.sumup.app.SampleApplication
│ Receivers
│ ..SampleApplication@33693824
│ ....VisibilityTracker@33789720
│ ..CardReaderPaymentAPIDrivenPageActivity@40430800
│ ....ReadCardFragment$4@41199040
│ ↓ LoadedApk.mReceivers
│ ~~~~~~~~~~
├─ android.util.ArrayMap instance
│ Leaking: UNKNOWN
│ Retaining 15.5 MB in 12429 objects
│ ↓ ArrayMap.mArray
│ ~~~~~~
├─ java.lang.Object[] array
│ Leaking: UNKNOWN
│ Retaining 15.5 MB in 12427 objects
│ ↓ Object[2]
│ ~~~
╰→ com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity instance
​ Leaking: YES (ObjectWatcher was watching this because com.sumup.merchant.reader.ui.activities.
​ CardReaderPaymentAPIDrivenPageActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
​ Retaining 549.6 kB in 3977 objects
​ key = 2e353509-2811-4e4a-b6c9-861944b1197d
​ watchDurationMillis = 8173
​ retainedDurationMillis = 3171
​ mApplication instance of com.sumup.app.SampleApplication
​ mBase instance of androidx.appcompat.view.ContextThemeWrapper
14747498 bytes retained by leaking objects
Signature: 7f375de2f98d5d0371beb618eaab0ac3272eb0af
┬───
│ GC Root: System class

├─ android.provider.FontsContract class
│ Leaking: NO (SampleApplication↓ is not leaking and a class is never leaking)
│ ↓ static FontsContract.sContext
├─ com.sumup.app.SampleApplication instance
│ Leaking: NO (Application is a singleton)
│ mBase instance of android.app.ContextImpl
│ ↓ Application.mLoadedApk
│ ~~~~~~~~~~
├─ android.app.LoadedApk instance
│ Leaking: UNKNOWN
│ Retaining 15.6 MB in 12448 objects
│ mApplication instance of com.sumup.app.SampleApplication
│ Receivers
│ ..SampleApplication@33693824
│ ....VisibilityTracker@33789720
│ ..CardReaderPaymentAPIDrivenPageActivity@40430800
│ ....ReadCardFragment$4@41199040
│ ↓ LoadedApk.mReceivers
│ ~~~~~~~~~~
├─ android.util.ArrayMap instance
│ Leaking: UNKNOWN
│ Retaining 15.5 MB in 12429 objects
│ ↓ ArrayMap.mArray
│ ~~~~~~
├─ java.lang.Object[] array
│ Leaking: UNKNOWN
│ Retaining 15.5 MB in 12427 objects
│ ↓ Object[3]
│ ~~~
├─ android.util.ArrayMap instance
│ Leaking: UNKNOWN
│ Retaining 727 B in 8 objects
│ ↓ ArrayMap.mArray
│ ~~~~~~
├─ java.lang.Object[] array
│ Leaking: UNKNOWN
│ Retaining 686 B in 6 objects
│ ↓ Object[0]
│ ~~~
├─ com.sumup.merchant.reader.ui.fragments.ReadCardFragment$4 instance
│ Leaking: UNKNOWN
│ Retaining 20 B in 1 objects
│ Anonymous subclass of android.content.BroadcastReceiver
│ ↓ ReadCardFragment$4.this$0
│ ~~~~~~
╰→ com.sumup.merchant.reader.ui.fragments.ReadCardFragment instance
​ Leaking: YES (ObjectWatcher was watching this because com.sumup.merchant.reader.ui.fragments.ReadCardFragment
​ received Fragment#onDestroy() callback. Conflicts with Fragment.mLifecycleRegistry.state is INITIALIZED)
​ Retaining 14.7 MB in 1822 objects
​ key = ebde43e2-fbe0-4b32-a210-b2a3b4d3042c
​ watchDurationMillis = 8172
​ retainedDurationMillis = 3171

0 LIBRARY LEAKS
A Library Leak is a leak caused by a known bug in 3rd party code that you do not have control over.
See https://square.github.io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks

0 UNREACHABLE OBJECTS
An unreachable object is still in memory but LeakCanary could not find a strong reference path
from GC roots.

METADATA
Please include this in bug reports and Stack Overflow questions.
Build.VERSION.SDK_INT: 36
Build.MANUFACTURER: samsung
LeakCanary version: 2.14
App process name: com.sumup.sdksampleapp
Class count: 31438
Instance count: 296694
Primitive array count: 178797
Object array count: 37734
Thread count: 65
Heap total bytes: 41699537
Bitmap count: 5
Bitmap total bytes: 14977220
Large bitmap count: 0
Large bitmap total bytes: 0
Db 1: open /data/user/0/com.sumup.sdksampleapp/no_backup/androidx.work.workdb
Count of retained yet cleared: 7 KeyedWeakReference instances
Stats: LruCache[maxSize=3000,hits=141826,misses=265134,hitRate=34%]
RandomAccess[bytes=13268698,reads=265134,travel=120475937590,range=41521616,size=59535115]
Analysis duration: 14263 ms
Heap dump file path: /storage/emulated/0/Download/leakcanary-com.sumup.sdksampleapp/2026-06-16_08-39-57_603.hprof
Heap dump timestamp: 1781624418054
Heap dump duration: Unknown

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions