Handle ApplicationExitInfo.REASON_MEMORY_LIMITER in MemoryLimiterIntegration

Open
#6,134 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, kotlin
Domain
mobile

Research direction

Start in sentry-android-core/src/main/java/io/sentry/android/core/MemoryLimiterIntegration.java by reading MemoryLimiterPolicy.matches(...), then inspect sentry-android-core/src/test/java/io/sentry/android/core/MemoryLimiterIntegrationTest.kt. Add coverage for ApplicationExitInfo.REASON_MEMORY_LIMITER while preserving the REASON_OTHER plus MemoryLimiter: behavior, and verify compatibility with older SDK stubs and the existing tests.

Written by the indexing model from the issue text.

Description

Android Platform: Java

Summary

MemoryLimiterIntegration currently recognizes MemoryLimiter process deaths only when ApplicationExitInfo.getReason() == REASON_OTHER and the description contains the MemoryLimiter: prefix.

Android 17 / API 37.2 added ApplicationExitInfo.REASON_MEMORY_LIMITER, and our integration does not account for it yet. That means newer platform versions can report a dedicated MemoryLimiter reason that we may fail to capture.

Relevant code:

  • sentry-android-core/src/main/java/io/sentry/android/core/MemoryLimiterIntegration.java
  • sentry-android-core/src/test/java/io/sentry/android/core/MemoryLimiterIntegrationTest.kt

Android reference:

Current Behavior

MemoryLimiterPolicy.matches(...) currently returns true only when:

  • exitInfo.getReason() == ApplicationExitInfo.REASON_OTHER
  • exitInfo.getDescription() contains MemoryLimiter:

Expected Behavior

MemoryLimiterIntegration should also recognize exits reported with ApplicationExitInfo.REASON_MEMORY_LIMITER.

We should preserve current behavior for existing REASON_OTHER + MemoryLimiter: records, since older platform behavior may still surface that combination.

Acceptance Criteria

  • Update MemoryLimiterPolicy.matches(...) to handle REASON_MEMORY_LIMITER in addition to the existing legacy path.
  • Keep backward compatibility for older Android versions / SDK stubs where the new constant may not be available at compile or runtime.
  • Add regression tests covering the dedicated MemoryLimiter reason.
  • Verify existing tests around the legacy REASON_OTHER path still pass.

Notes

The implementation may need to avoid directly referencing the new constant from older compile targets if that creates compatibility issues with our current Android SDK setup.

Dominant language
Kotlin
Stars
1.4k
Forks
478
Avg merge
3d 2h
Merged PRs (30d)
70

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-java

All issues in getsentry/sentry-java

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.