skip to Main Content

So when we Run code, by F5 in VS code, does that Application on physical device leave only on RAM?
This question arise will using image_picker library on Handling MainActivity destruction , which say in summer, "the intent is executing the source application is moved to the background and becomes eligible for cleanup when the system is low on memory. When the intent finishes executing, Android will restart the application".

On apk release this work fine, but on development with device with 2 gb ram, i always get lost connection device error

Try developing on 4gb ram , error is mostly on xiaomi device

2

Answers


  1. All applications that are running in foreground or background lives in RAM. The issue you are having with image_picker plugin will only arise when the device is low on RAM, it does not matter if the RAM is 2 GB or 16 GB. If too many applications are running on foreground or background, Android OS will try to free RAM by closing the applications running in background to smoothly run the application that is on the foreground.

    In order to overcome this issue, image_picker plugin provides a method to retrieve the data picked by user when the Flutter application was killed by the Android OS:

    final LostDataResponse response = await picker.retrieveLostData();
    

    Another way is to use camera plugin:

    final XFile file = await cameraController.takePicture();
    

    A good feature of camera plugin is that it provides a Flutter widget, so your application will not be killed by Android OS since it will be in the foreground.

    Login or Signup to reply.
  2. The application is installed on the device.
    Only hot-reload/hot-restart changes live only in RAM.

    You can test it yourself:

    1. Press F5
    2. Stop debugging & close the application.
    3. You can still open the application. (without debugging)
    4. Run the debugger again (F5)
    5. Make some changes.
    6. Stop debugging & close application
    7. Restart the application. (no F5)
    8. You will see that the hot reload changes are gone.

    Even though debugging requires more memory due to the larger application size and debugging tools, it is not certain that the "lost connection device error" is caused by less memory. But it seems to be.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search