xamarin/Xamarin.Forms

EditText native object was not disposed in Android

Open

#3,784 opened on Sep 14, 2018

 (5 comments) (0 reactions) (0 assignees)C# (1,926 forks)batch import
e/5 :clock5:help wantedinactivep/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

I have created a simple custom control in Android. I have inherits the native EditText. I have hooked only TextChanged event in the source. In the disposing method, I have unhooked the TextChanged event. Unfortunately, the memory of the native control was not cleared. If I commented on the TextChanged event, the native memory was cleared in Android.

Steps to Reproduce

  1. Run the attached sample
  2. Go to the Custom Control page and return back main page
  3. Check the Memory consumption on Android profiler
  4. The EditText object was not disposed in Android

Expected Behavior

The native EditText Object was disposed of if we return to the main page

Actual Behavior

The native EditText object was not disposed of if we hook the text changed event and retun back to the mainpage in Android

Basic Information

  • Version with issue: Xamarin Forms version 3.0
  • Last known good version:
  • IDE: VS 2017
  • Platform Target Frameworks:
    • Android: 7.0
  • Android Support Library Version: No
  • Nuget Packages: No
  • Affected Devices: Moto G4 plus

Screenshots

image

Reproduction Link

Reproduction Sample link: MemoryLeakSample.zip

Contributor guide