dotnet / dotnet/android-libraries

Memory leak when Xamarin.AndroidX.ConstraintLayout package is installed in source

Open
#970 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
317
Forks
73
Avg merge
1d 8h
Merged PRs (30d)
17

Description

### Android application type

Android for .NET (net6.0-android, etc.)

### Affected platform version

VS 17.11.2 dotnet 7.0 and dotnet 8.0

### Description

Upon installing Xamarin.AndroidX.ConstraintLayout in the application's source code, a memory leak related to ReportFragment from the androidx.lifecycle library is observed when navigating to a new activity and subsequently returning to the previous activity. This issue was replicated in a new .NET Android solution where only Xamarin.AndroidX.ConstraintLayout was installed. The memory leak was detected using the Android Studio profiler after navigating back to the previous activity. An attachment has been provided for reference.
![memory leak](https://github.com/user-attachments/assets/6c45621f-271e-4a5a-b610-125a8dab5275)

### Steps to Reproduce

1. Begin by creating a new .NET Android project.
2. Within the main activity page, add a button to facilitate the creation of a new activity.
3. Implement functionality to navigate to the new activity upon clicking the button.
4. Enable navigation back to the previous page by pressing the back button.
5. Repeat this process multiple times.
6. Capture a heap dump using the Android Studio profiler to identify any memory leaks.
7. After iterating the process x times, you should be able to identify x instances of memory leaks.

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.