-
-
Notifications
You must be signed in to change notification settings - Fork 468
feat(android): Parse memory and GC info from ANR thread dumps #5428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
markushi
wants to merge
2
commits into
main
Choose a base branch
from
feat/anr-thread-dump-memory-info
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...d-core/src/main/java/io/sentry/android/core/internal/threaddump/ThreadDumpMemoryInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| package io.sentry.android.core.internal.threaddump; | ||
|
|
||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Holds memory and GC metrics parsed from an ANRv2 thread dump. | ||
| * | ||
| * <p>Memory sizes are in bytes. GC times are in milliseconds. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public final class ThreadDumpMemoryInfo { | ||
|
|
||
| private @Nullable Long freeMemoryBytes; | ||
| private @Nullable Long freeMemoryUntilGcBytes; | ||
| private @Nullable Long freeMemoryUntilOOMEBytes; | ||
| private @Nullable Long totalMemoryBytes; | ||
| private @Nullable Long maxMemoryBytes; | ||
|
|
||
| private @Nullable Long totalGcCount; | ||
| private @Nullable Double totalGcTimeMs; | ||
| private @Nullable Long totalBlockingGcCount; | ||
| private @Nullable Double totalBlockingGcTimeMs; | ||
| private @Nullable Long totalPreOomeGcCount; | ||
| private @Nullable Double totalTimeWaitingForGcMs; | ||
|
|
||
| public @Nullable Long getFreeMemoryBytes() { | ||
| return freeMemoryBytes; | ||
| } | ||
|
|
||
| public void setFreeMemoryBytes(final @Nullable Long freeMemoryBytes) { | ||
| this.freeMemoryBytes = freeMemoryBytes; | ||
| } | ||
|
|
||
| public @Nullable Long getFreeMemoryUntilGcBytes() { | ||
| return freeMemoryUntilGcBytes; | ||
| } | ||
|
|
||
| public void setFreeMemoryUntilGcBytes(final @Nullable Long freeMemoryUntilGcBytes) { | ||
| this.freeMemoryUntilGcBytes = freeMemoryUntilGcBytes; | ||
| } | ||
|
|
||
| public @Nullable Long getFreeMemoryUntilOOMEBytes() { | ||
| return freeMemoryUntilOOMEBytes; | ||
| } | ||
|
|
||
| public void setFreeMemoryUntilOOMEBytes(final @Nullable Long freeMemoryUntilOOMEBytes) { | ||
| this.freeMemoryUntilOOMEBytes = freeMemoryUntilOOMEBytes; | ||
| } | ||
|
|
||
| public @Nullable Long getTotalMemoryBytes() { | ||
| return totalMemoryBytes; | ||
| } | ||
|
|
||
| public void setTotalMemoryBytes(final @Nullable Long totalMemoryBytes) { | ||
| this.totalMemoryBytes = totalMemoryBytes; | ||
| } | ||
|
|
||
| public @Nullable Long getMaxMemoryBytes() { | ||
| return maxMemoryBytes; | ||
| } | ||
|
|
||
| public void setMaxMemoryBytes(final @Nullable Long maxMemoryBytes) { | ||
| this.maxMemoryBytes = maxMemoryBytes; | ||
| } | ||
|
|
||
| public @Nullable Long getTotalGcCount() { | ||
| return totalGcCount; | ||
| } | ||
|
|
||
| public void setTotalGcCount(final @Nullable Long totalGcCount) { | ||
| this.totalGcCount = totalGcCount; | ||
| } | ||
|
|
||
| public @Nullable Double getTotalGcTimeMs() { | ||
| return totalGcTimeMs; | ||
| } | ||
|
|
||
| public void setTotalGcTimeMs(final @Nullable Double totalGcTimeMs) { | ||
| this.totalGcTimeMs = totalGcTimeMs; | ||
| } | ||
|
|
||
| public @Nullable Long getTotalBlockingGcCount() { | ||
| return totalBlockingGcCount; | ||
| } | ||
|
|
||
| public void setTotalBlockingGcCount(final @Nullable Long totalBlockingGcCount) { | ||
| this.totalBlockingGcCount = totalBlockingGcCount; | ||
| } | ||
|
|
||
| public @Nullable Double getTotalBlockingGcTimeMs() { | ||
| return totalBlockingGcTimeMs; | ||
| } | ||
|
|
||
| public void setTotalBlockingGcTimeMs(final @Nullable Double totalBlockingGcTimeMs) { | ||
| this.totalBlockingGcTimeMs = totalBlockingGcTimeMs; | ||
| } | ||
|
|
||
| public @Nullable Long getTotalPreOomeGcCount() { | ||
| return totalPreOomeGcCount; | ||
| } | ||
|
|
||
| public void setTotalPreOomeGcCount(final @Nullable Long totalPreOomeGcCount) { | ||
| this.totalPreOomeGcCount = totalPreOomeGcCount; | ||
| } | ||
|
|
||
| public @Nullable Double getTotalTimeWaitingForGcMs() { | ||
| return totalTimeWaitingForGcMs; | ||
| } | ||
|
|
||
| public void setTotalTimeWaitingForGcMs(final @Nullable Double totalTimeWaitingForGcMs) { | ||
| this.totalTimeWaitingForGcMs = totalTimeWaitingForGcMs; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The device's total physical RAM (
device.memorySize) is incorrectly overwritten with the app's maximum heap size from the ANR thread dump, leading to inaccurate memory reporting.Severity: MEDIUM
Suggested Fix
Remove the logic that overwrites the
device.memorySize. The value frommaxMemoryBytesparsed from the thread dump should not replace the device's total physical RAM. Consider storing the JVM heap max in a separate field or only setting the memory size if it hasn't been set already fromActivityManager.MemoryInfo.Prompt for AI Agent
Did we get this right? ๐ / ๐ to inform future reviews.