1
In an application Xamarin.Android
, it is important to remove the Event Handlers
when leaving the screen to avoid memory consumption? It would be a good practice?
For example, in the OnCreate()
of one of the screens of my app, I have the following statement:
_btnStartExam.Click += ShowStartExamConfirmation;
When leaving the screen, for example on OnDestroy()
, it is recommended that the following be done?
_btnStartExam.Click -= ShowStartExamConfirmation;
I read in some American OS posts that same as the Garbage Collector
do this kind of work, it is recommended to avoid cyclical references and memory consumption.
However, I would still like more information about this and if it is good for the application lifecycle to make use of this type of technique.
Note that the application is open all day on the device and the user has no option to quit for other applications.
you can use Ondestroy for this, but everything done in Oncreate will be undone in Ondestroy on its own when the screen is closed .
– Marco Souza