Skip to content

CATROID-376: Integrate LeakCanary for Memory Leak Detection#5184

Open
harshsomankar123-tech wants to merge 1 commit intoCatrobat:developfrom
harshsomankar123-tech:CATROID-376-integrate-leakcanary
Open

CATROID-376: Integrate LeakCanary for Memory Leak Detection#5184
harshsomankar123-tech wants to merge 1 commit intoCatrobat:developfrom
harshsomankar123-tech:CATROID-376-integrate-leakcanary

Conversation

@harshsomankar123-tech
Copy link
Copy Markdown
Member

@harshsomankar123-tech harshsomankar123-tech commented Apr 3, 2026

JIRA TICKET - https://catrobat.atlassian.net/browse/CATROID-376

Overview

This PR integrates LeakCanary 2.14 into the project to automatically detect and help resolve memory leaks during development. LeakCanary identifies leaks in Activities, Fragments, ViewModels, and other objects, providing detailed leak traces via system notifications.

Changes Made

  • Dependency Integration (catroid/build.gradle): Added com.squareup.leakcanary:leakcanary-android:2.14 using debugImplementation. This ensures the library is only included in debug builds and has no impact on the release APK size or performance.
  • Okio Migration (CatrobatServerCalls.kt): LeakCanary 2.14 transitively upgrades Okio from version 1.x to 2.x. This required updating CatrobatServerCalls.kt to use Okio 2.x Kotlin extension functions (destination.sink().buffer()) instead of the deprecated static methods (Okio.buffer(Okio.sink(destination))).

Verification Results

  • Debug Build: Verified that LeakCanary is successfully resolved and the project compiles.
  • Release Build: Verified using ./gradlew catroid:dependencies that LeakCanary is completely excluded from the release classpath.
  • Functional Check: The app builds successfully with the updated Okio APIs.

How to use

Once a debug build is installed, LeakCanary will automatically monitor for leaks. If a leak is detected, a notification will appear. Tapping it will open the LeakCanary dashboard with a complete "leak trace" showing the path from a GC Root to the leaked object.

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

- build.gradle: Add LeakCanary 2.14 as debugImplementation
- CatrobatServerCalls.kt: Migrate to Okio 2.x extension functions
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 3, 2026

@harshsomankar123-tech harshsomankar123-tech added the Active Member Tickets that are assigned to members that are still currently active label Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Active Member Tickets that are assigned to members that are still currently active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant