Memory Leak Switching Activities
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 579
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 252
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
```shell
```
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
- Tech stack
- android, csharp
- Domain
- mobile, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100