screenshot
screenshot copied to clipboard
Image memory leak
Images are not released from memory.
For example taking several screenshots with captureFromWidget
one after the other severely increases memory usage causing out of memory crash.
Solution:
Please put image.dispose();
everywhere after byteData is extracted from image.
final ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
image.dispose(); // needed to clean up memory
image = null; // also important
return byteData!.buffer.asUint8List();
Hi @SachinGanesh,
I totally agree with @kreativityapps , there is memory leak, I faced some memory crashes too.
I forked the project and fixed the problem, you can use it in your pubspec.yaml
using:
screenshot:
git: https://github.com/rignaneseleo/screenshot.git
Hi,
This has been fixed in latest versions. So closing this issue.