Memory Leak Switching Activities
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- android, csharp
- Domain
- mobile, performance
Research direction
Start with the linked LeakTest application and reproduce the activity switching on an Android device while watching native memory in Android Studio Live Telemetry. Compare behavior with and without GC.Collect() in OnDestroy() or OnCreate(), then trace the activity lifecycle and native allocation path implicated by the reproduction. Done means repeated switching no longer causes unbounded native-memory growth or an application crash.
Written by the indexing model from the issue text.
Description
Android framework version
net11.0-android (Preview)
Affected platform version
Visual Studio 2026 v18.7.3
Description
Having experienced the same issue as https://github.com/dotnet/android/issues/10989 I tested the fix in .NET11 Preview 6 but it still seems to be present.
Created a small app which auto switches between 2 activities the native memory increases until the application crashes. Memory viewed in Android Studio Live Telemetry.
Steps to Reproduce
Install application on an Android device from https://github.com/dodgei/android_leak/tree/main/LeakTest
Witness the climbing native memory in a profiler.
Did you find any workaround?
I found that calling GC.Collect(); in OnDestroy(); or OnCreate(); keeps the memory stable
Relevant log output
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 581
- Avg merge
- 2d 33m
- Merged PRs (30d)
- 204
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/android
-
Area: App+Library Build
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Area: Mono.Android
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotnet/android#9192 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
enhancement needs-triage
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
automated needs-triage skill-runner
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
MicrosoftLearning/PL-400_Microsoft-Power-Platform-Developer#231 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
joinrpg/joinrpg-net#5313 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day