Repository: flutter
Issue: ubuntu desktop app leaks memory
Labels: engine,c: performance,platform-linux,a: desktop,perf: memory,has reproducible steps,P2,found in release: 3.19,found in release: 3.22,team-linux,triaged-linux

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a performance problem, then fill out the template below.
     Please read our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Details

<!--
1.  Please tell us exactly how to reproduce the problem you are running into, and how you measured the performance.

2.  Please attach a small application (ideally just one main.dart file) that
     reproduces the problem. You could use https://gist.github.com/ for this.

3.  Switch flutter to master channel and run this app on a physical device
     using profile or release mode. Verify that the performance issue can be
     reproduced there.

     The bleeding edge master channel is encouraged here because Flutter is
     constantly fixing bugs and improving its performance. Your problem in an
     older Flutter version may have already been solved in the master channel.
-->

<!--
     Please tell us which target platform(s) the problem occurs (Android / iOS / Web / macOS / Linux / Windows)
     Which target OS version, for Web, browser, is the test system running?
     Does the problem occur on an emulator/simulator as well as on physical devices?
-->

**Target Platform: linux
**Target OS version/browser: ubuntu18.04
**Devices: 

flutter doctor:

```
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.26.0-2.0.pre.179, on Linux, locale en_US.UTF-8)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] VS Code (version 1.51.1)
[✓] Proxy Configuration
[✓] Connected device (2 available)

! Doctor found issues in 2 categories.

```

flutter ubuntu desktop app comsumes too much memory, and may leaks memory.

build a profile app, and run it.

```
flutter create app1
cd app1
flutter build linux --profile
./build/linux/profile/bundle/app1
```

use `top` to watch this app.

```
top -p pid
```

![image](https://user-images.githubusercontent.com/10678931/103749571-a1f13280-5040-11eb-96fc-02bb0a3f42ce.png)

RES: ~80M

open the Observatory's allocation-profiler:

![image](https://user-images.githubusercontent.com/10678931/103749770-e4b30a80-5040-11eb-8b83-4e8dbb626efc.png)

click the btn in flutter app:

![image](https://user-images.githubusercontent.com/10678931/103749894-1035f500-5041-11eb-9034-697c360320a4.png)


the `top` shows:

![image](https://user-images.githubusercontent.com/10678931/103750023-35c2fe80-5041-11eb-808a-dc9031a3bb0d.png)

RES: ~100M

 the Observatory's allocation-profiler:

![image](https://user-images.githubusercontent.com/10678931/103750087-45424780-5041-11eb-9649-a4dfdf5fdcd9.png)

trigger gc in Observatory's allocation-profiler:

![image](https://user-images.githubusercontent.com/10678931/103750162-57bc8100-5041-11eb-8240-77e7d5ffbf38.png)

the `top` shows:

![image](https://user-images.githubusercontent.com/10678931/103753971-ad475c80-5046-11eb-84f7-87982b3b915c.png)


RES: ~100M


The above demonstrates that flutter app's RES grows and never decrease.

## Logs

<details>
<summary>Logs</summary>

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
```

<!-- Finally, paste the output of running `flutter doctor -v` here, with your device plugged in. -->

```
```

</details>