Describe the bug
When navigating the old fragments are still being referenced in the HashMap so the Garbage Collector doesn't collect them causing a memory leak.
When the navigation's 'clearHistory: true' the backstack is emptied properly but the memory leak remains.
When 'clearHistory: false' you can see all the old pages still in the backstack with different Id names even if they are the same page.
To Reproduce
ns create my-drawer-js --template @nativescript/template-drawer-navigation
Open up the profiler in Android Studio
Go to Memory and start a new profiling session
Navigate to a different page in the template app
Go back to profiler and Dump Java Heap
Click the Leaks link
Click the FragmentClass
Click the Instance
Click the References Tab and check the 'Show nearest GC root only' Option
The FragmentClass instance can't be released because of the references in the HashMap I believe.
This leak is also caught using leak canary
Expected behavior
Fragments should be getting completely removed from memory
Environment
Describe the bug When navigating the old fragments are still being referenced in the HashMap so the Garbage Collector doesn't collect them causing a memory leak.
When the navigation's 'clearHistory: true' the backstack is emptied properly but the memory leak remains. When 'clearHistory: false' you can see all the old pages still in the backstack with different Id names even if they are the same page.
To Reproduce ns create my-drawer-js --template @nativescript/template-drawer-navigation Open up the profiler in Android Studio Go to Memory and start a new profiling session Navigate to a different page in the template app Go back to profiler and Dump Java Heap![image](https://user-images.githubusercontent.com/16808752/126538134-1bae10d2-6d2c-48e7-9bff-b39831d59469.png)
Click the Leaks link![image](https://user-images.githubusercontent.com/16808752/126538058-5d74a7de-6a0c-4eec-8ddb-8da221ee10dc.png)
Click the FragmentClass![image](https://user-images.githubusercontent.com/16808752/126538229-3be4f94e-6bcf-4acf-b768-3586c97ff43a.png)
Click the Instance![image](https://user-images.githubusercontent.com/16808752/126538273-6e65a095-7e5f-43c0-bb3c-1f58433f1456.png)
Click the References Tab and check the 'Show nearest GC root only' Option![image](https://user-images.githubusercontent.com/16808752/126538409-a4a25dc8-5e20-4bbe-b195-1a8c7ee015a8.png)
The FragmentClass instance can't be released because of the references in the HashMap I believe.
This leak is also caught using leak canary![image](https://user-images.githubusercontent.com/16808752/126539776-a3a2232a-1867-402b-a8c9-9177ec944aa5.png)
Expected behavior Fragments should be getting completely removed from memory
Sample project I used the most vanilla template I could to make sure issues weren't coming from frameworks or plugins https://www.npmjs.com/package/@nativescript/template-drawer-navigation
Additional context