Skip to content

feat(android): Parse memory and GC info from ANR thread dumps#5428

Merged
markushi merged 8 commits into
mainfrom
feat/anr-thread-dump-memory-info
May 26, 2026
Merged

feat(android): Parse memory and GC info from ANR thread dumps#5428
markushi merged 8 commits into
mainfrom
feat/anr-thread-dump-memory-info

Conversation

@markushi
Copy link
Copy Markdown
Member

@markushi markushi commented May 13, 2026

📜 Description

Parses memory and GC metrics from ANRv2 dumps (ApplicationExitInfo traces) and attaches them as a new art context on ANR events.

New classes:

  • ArtContext — serializable context for ART runtime memory/GC fields (bytes and milliseconds), added to Contexts
  • ArtContextParser — parses lines like Free memory 3107KB, Total GC time: 11.807ms using simple suffix-based parsing (counterpart to Android's PrettySize and PrettyDuration output)

The parsed data is attached as event.contexts.art with attribute names aligned to sentry-conventions#382.

Resolves: #2801

💡 Motivation and Context

ANR thread dumps from ART contain memory and GC statistics that are currently ignored. This information is valuable for diagnosing memory pressure-related ANRs.

💚 How did you test it?

  • Unit tests
  • Integration tests

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

markushi and others added 2 commits May 13, 2026 10:25
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 1493734

@sentry
Copy link
Copy Markdown

sentry Bot commented May 13, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.41.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 307.83 ms 356.17 ms 48.34 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
8558cac 306.16 ms 355.24 ms 49.09 ms
8687935 332.52 ms 362.23 ms 29.71 ms
9054d65 330.94 ms 403.24 ms 72.30 ms
fc5ccaf 322.49 ms 405.25 ms 82.76 ms
8c1fb22 316.62 ms 352.78 ms 36.16 ms
d8912da 329.94 ms 389.68 ms 59.74 ms
d15471f 315.61 ms 360.22 ms 44.61 ms
b6702b0 395.86 ms 409.98 ms 14.12 ms
62b579c 318.48 ms 367.71 ms 49.24 ms
ed33deb 312.34 ms 369.71 ms 57.37 ms

App size

Revision Plain With Sentry Diff
8558cac 0 B 0 B 0 B
8687935 1.58 MiB 2.19 MiB 619.17 KiB
9054d65 1.58 MiB 2.29 MiB 723.38 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
8c1fb22 0 B 0 B 0 B
d8912da 0 B 0 B 0 B
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
b6702b0 1.58 MiB 2.12 MiB 551.79 KiB
62b579c 0 B 0 B 0 B
ed33deb 1.58 MiB 2.13 MiB 559.52 KiB

Previous results on branch: feat/anr-thread-dump-memory-info

Startup times

Revision Plain With Sentry Diff
976a904 315.40 ms 352.60 ms 37.20 ms
e24f273 348.98 ms 407.75 ms 58.77 ms
fc3a862 316.67 ms 394.40 ms 77.73 ms

App size

Revision Plain With Sentry Diff
976a904 0 B 0 B 0 B
e24f273 0 B 0 B 0 B
fc3a862 0 B 0 B 0 B

@markushi
Copy link
Copy Markdown
Member Author

@sentry review

@markushi markushi marked this pull request as ready for review May 15, 2026 07:54
Copy link
Copy Markdown
Member

@0xadam-brown 0xadam-brown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice. Just a few comments; none have to block us.

Comment thread sentry/src/test/resources/json/art_context.json
Comment thread sentry/src/main/java/io/sentry/protocol/ArtContext.java
Comment thread sentry/src/main/java/io/sentry/protocol/ArtContext.java
markushi and others added 3 commits May 15, 2026 15:41
Copy link
Copy Markdown
Member

@0xadam-brown 0xadam-brown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates – lgtm 👍

Copy link
Copy Markdown
Contributor

@runningcode runningcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can avoid having the ArtContext in the java sdk?

@markushi
Copy link
Copy Markdown
Member Author

Is there a way we can avoid having the ArtContext in the java sdk?

As of now we keep all protocol definitions within the core module, as the core SDK could be used as a proxy and end up parsing / sending envelope files produced by other SDKs (like sentry-native)

@markushi markushi merged commit 9669c2d into main May 26, 2026
69 checks passed
@markushi markushi deleted the feat/anr-thread-dump-memory-info branch May 26, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parse currently available memory from ANRv2 thread dump

4 participants