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
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:
Another way is to use camera plugin:
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.
The application is installed on the device.
Only hot-reload/hot-restart changes live only in RAM.
You can test it yourself:
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.