xamarin/Xamarin.Forms

EditText native object was not disposed in Android

Aperta

#3784 aperta il 14 set 2018

 (5 commenti) (0 reazioni) (0 assegnatari)C# (1926 fork)batch import
e/5 :clock5:help wantedinactivep/Androidt/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor