flutter / devtools

Performance tools for Flutter
https://flutter.dev/docs/development/tools/devtools/
BSD 3-Clause "New" or "Revised" License
1.54k stars 314 forks source link

How to get the memory usage information in release mode? #3348

Open makesimple opened 2 years ago

makesimple commented 2 years ago

Hi,My flutter application has many memory leakages, So I want to specify which part consume the memory. Although I can get memory usage from devtools in debug mode, the debug mode has more memory usage than release mode,so the debug mode make the analyzing more complicated. I know there is a profile mode,but I don't know how to use it in my envirnment.my device is a tv box,runing on linux and arm cpu. no adb, and I had implemented a platform in the flutter engine. the flutter engine is launched by the shell script,not by the flutter tools. So,how to get the memory usage in release mode or profile mode?

kenzieschmoll commented 2 years ago

To use the memory tools, we need a vm service connection, which is only available in debug and profile mode. @iskakaushik do you know if there is a way to run in profile mode in this unique run environment where the engine is launched outside of flutter tools?

@makesimple can you please provide specific steps on the workflow you use to launch your app and connect to DevTools?

makesimple commented 2 years ago

To use the memory tools, we need a vm service connection, which is only available in debug and profile mode. @iskakaushik do you know if there is a way to run in profile mode in this unique run environment where the engine is launched outside of flutter tools?

@makesimple can you please provide specific steps on the workflow you use to launch your app and connect to DevTools?

The specific steps are:

  1. Connect to my device by ssh.
  2. Launch the flutter engine manually in the device.
  3. In the device, forward the tcp port with my PC,the port is provided by the url such as "http://127.0.0.1:46585/aQhFCbIBJXM=/".
  4. Run command "flutter pub global run devtools" in my PC.
  5. The rest steps are as usual.
bleroux commented 2 years ago

Which command do you use to "Launch the flutter engine manually in the device." ?

makesimple commented 2 years ago

Which command do you use to "Launch the flutter engine manually in the device." ?

The command is a linux executable application that i implemented for my platform. It's similar to the implementation of other platforms,especially such as linux desktop. My linux application was based on the APIs provided by the flutter engine (libflutter_engine.so): flutter_engine/src/flutter/shell/platform/embedder/embedder.h I can feed any parameters to the application as other platforms,so, i can pass flutter_assets dir to it, or libapp.so,icudtl.dat,and so on.

bleroux commented 2 years ago

For profile mode, you have to build your engine accordingly. For instance, on Linux, when running in profile mode, the resulting bundle contains profile builds for '.so' files :

An easier solution, if possible for your app, would be to run it on desktop mode : it might help to spot performance issues in your Dart code, but it will not if your performance issues are in your embedder.

makesimple commented 2 years ago

For profile mode, you have to build your engine accordingly.

How to build the engine for profile mode?