Repository navigation
Memory Leak flutter framework iOS - gridview, listview - it IS a bug... #32143
Description
Steps to Reproduce
Code below - the simple introductory app, but with a gridview. There is a Map of a list of URLs. If you check the size of each JPG, it is 115k, 130k.
Well, when I run the app, two things are not happening:
it is not deallocating memory of objects not visible. So memory usage is going crazy. It already starts with 60-100MB (way too much for a simple app like this IMHO) and goes to the point where the app may crash due to OOM. You scroll to the end, memory usage may end up +600MB. I'm running it in debug mode. (is that the reason? Shouldn't be...)
The image size on memory is around 4MB/image, at least. I understand that this is due to rendering of the image. I will drop this down by downloading them, resizing the images beforehand in my server. But even then, not deallocating is huge.
And I have seen this happen in fact with any image. I can post code later, but I have an app with several pages. You push one page, see an image (svg, small in size. But rendered, big). Pop page. That image never gets deallocated. So, memory usage keeps increasing 3-4MB at a time. Should I manually deallocate every Image.network or NetworkImage or etc ... I use?
Shouldn't the framework free this when popping a page?
Cheers, here to help if anything (willing to contribute, I've already posted things on image_picker in the past)
I just tested with Android, garbage collector works in android. Although it goes up a lot, at some point it decides to offload objects, and memory goes from 200-300MB back to 100MB. And when I pop the page, memory is released. So yes, this is a flutter issue on IOS
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: GridView.builder(
itemCount: marineLifeArray.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
itemBuilder: (BuildContext context, int i) {
return GestureDetector(
onTap: () {
print("TAPPED");
},
child: Card(
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
marineLifeArray[i]["photo"],
)),
),
),
Container(
padding: EdgeInsets.all(8),
child: Text(
"${marineLifeArray[i]["name"]}",
style: TextStyle(height: 1.2, fontSize: 10, color: Colors.white, fontWeight: FontWeight.w100),
),
color: Color(0xbf000000),
),
],
)),
);
}),
);
}
}
const String name = "name";
const String site = "site";
const String photo = "photo";
const String type = "type";
const String subtype = "subtype";
List<Map<String, String>> marineLifeArray = [
{
name: 'Whale shark',
site: 'https://reeflifesurvey.com/species/rhincodon-typus',
photo: 'https://images.reeflifesurvey.com/0/species_86_570f12bd2970e.w1300.h866.jpg',
type: 'Shark',
subtype: 'Shark',
},
{
name: 'Hawksbill Turtle',
site: 'https://reeflifesurvey.com/species/eretmochelys-imbricata/',
photo: 'https://images.reeflifesurvey.com/0/species_c3_5774942365681.w1300.h866.JPG',
type: 'Turtle',
subtype: 'Turtle',
},
{
name: 'Green Turtle',
site: 'https://reeflifesurvey.com/species/chelonia-mydas/',
photo: 'https://images.reeflifesurvey.com/0/species_04_574e86d9ddc6c.w1300.h866.jpg',
type: 'Turtle',
subtype: 'Turtle',
},
{
name: 'Grey Reef Shark',
site: 'https://reeflifesurvey.com/species/carcharhinus-amblyrhynchos/',
photo: 'https://images.reeflifesurvey.com/0/species_78_5704765706b21.w1300.h866.jpg',
type: 'Shark',
subtype: 'Shark',
},
{
name: 'Nurse Shark',
site: 'https://reeflifesurvey.com/species/ginglymostoma-cirratum/',
photo: 'https://images.reeflifesurvey.com/0/species_8a_582953dfc0b8b.w1300.h866.jpg',
type: 'Shark',
subtype: 'Shark',
},
{
name: 'White Tip Reef Shark',
site: 'https://reeflifesurvey.com/species/triaenodon-obesus/',
photo: 'https://images.reeflifesurvey.com/0/species_1c_5704a01e5ad90.w1300.h866.jpg',
type: 'Shark',
subtype: 'Shark',
},
{
name: 'Sergeant Fish',
site: 'https://reeflifesurvey.com/species/abudefduf-saxatilis/',
photo: 'https://images.reeflifesurvey.com/0/species_92_576c98fc7e3e9.w1300.h866.jpg',
type: 'Fish',
subtype: 'Sergeant Fish'
},
{
name: 'Longfin Bannerfish',
site: 'https://reeflifesurvey.com/species/heniochus-acuminatus/',
photo: 'https://images.reeflifesurvey.com/0/species_c4_56e73207418da.w1300.h866.jpg',
type: 'Fish',
subtype: 'Bannerfish'
},
{
name: 'Singular Bannerfish',
site: 'https://reeflifesurvey.com/species/heniochus-singularius/',
photo: 'https://images.reeflifesurvey.com/0/species_16_57bbfb9a6b55e.w1300.h866.jpg',
type: 'Fish',
subtype: 'Bannerfish'
},
{
name: 'Lionfish',
site: 'https://reeflifesurvey.com/species/pterois-miles/',
photo: 'https://images.reeflifesurvey.com/0/species_a1_570ecefec427e.w1300.h866.jpg',
type: 'Fish',
subtype: 'Lionfish',
},
{
name: 'Red Lionfish',
site: 'https://reeflifesurvey.com/species/pterois-volitans/',
photo: 'https://images.reeflifesurvey.com/0/species_15_570edcdedc6e8.w1300.h866.jpg',
type: 'Fish',
subtype: 'Lionfish'
},
{
name: 'Shaded Batfish',
site: 'https://reeflifesurvey.com/species/platax-pinnatus/',
photo: 'https://images.reeflifesurvey.com/0/species_fd_58d8827947d58.w1300.h866.jpg',
type: 'Fish',
subtype: 'Batfish',
},
{
name: 'Round Batfish',
site: 'https://reeflifesurvey.com/species/platax-orbicularis/',
photo: 'https://images.reeflifesurvey.com/0/species_49_576c9f446ae52.w1300.h866.jpg',
type: 'Fish',
subtype: 'Batfish',
},
{
name: 'Maldives Damselfish',
site: 'https://reeflifesurvey.com/species/amblyglyphidodon-indicus/',
photo: 'https://images.reeflifesurvey.com/0/species_a4_57c1456553462.w1300.h866.jpg',
type: 'Fish',
subtype: 'Damselfish',
},
{
name: 'Yellowtail Damselfish',
site: 'https://reeflifesurvey.com/species/neopomacentrus-azysron/',
photo: 'https://images.reeflifesurvey.com/0/species_35_57adb386b3fe3.w1300.h866.jpg',
type: 'Fish',
subtype: 'Damselfish',
},
{
name: 'Banded Frogfish',
site: 'https://reeflifesurvey.com/species/halophryne-diemensis/',
photo: 'https://images.reeflifesurvey.com/0/species_b3_570b4bac198aa.w1300.h866.jpg',
type: 'Fish',
subtype: 'Frogfish',
},
{
name: 'Eastern Frogfish',
site: 'https://reeflifesurvey.com/species/batrachomoeus-dubius/',
photo: 'https://images.reeflifesurvey.com/0/species_00_570b45f42575c.w1300.h866.jpg',
type: 'Fish',
subtype: 'Frogfish',
},
{
name: 'Zebra Moray',
site: 'https://reeflifesurvey.com/species/echidna-nebulosa/',
photo: 'https://images.reeflifesurvey.com/0/species_d2_5705cb696d3d0.w1300.h866.jpg',
type: 'Moray',
subtype: 'Moray',
},
{
name: 'Chestnut Moray',
site: 'https://reeflifesurvey.com/species/gymnothorax-castaneus/',
photo: 'https://images.reeflifesurvey.com/0/species_c5_57e2262da3196.w1300.h866.JPG',
type: 'Moray',
subtype: 'Moray',
},
{
name: 'Honeycomb Moray',
site: 'https://reeflifesurvey.com/species/gymnothorax-favagineus/',
photo: 'https://images.reeflifesurvey.com/0/species_50_5706f1102266c.w1300.h866.jpg',
type: 'Moray',
subtype: 'Moray',
},
{
name: 'Green Moray',
site: 'https://reeflifesurvey.com/species/gymnothorax-funebris/',
photo: 'https://images.reeflifesurvey.com/0/species_6c_582954f05eaf0.w1300.h866.jpg',
type: 'Moray',
subtype: 'Moray',
},
{
name: 'Giant Moray',
site: 'https://reeflifesurvey.com/species/gymnothorax-javanicus/',
photo: 'https://images.reeflifesurvey.com/0/species_48_5706f8e197fce.w1300.h866.jpg',
type: 'Moray',
subtype: 'Moray',
},
{
name: 'Garden Eel',
site: 'https://reeflifesurvey.com/species/gorgasia-barnesi/',
photo: 'https://images.reeflifesurvey.com/0/species_ca_58041a9fb15e9.w1300.h866.JPG',
type: 'Eel',
subtype: 'Eel',
},
{
name: 'Ribbon Eel',
site: 'https://reeflifesurvey.com/species/rhinomuraena-quaesita/',
photo: 'https://images.reeflifesurvey.com/0/species_39_5707289e49bcb.w1300.h866.jpg',
type: 'Eel',
subtype: 'Eel',
},
{
name: 'Golden Scorpionfish',
site: 'https://reeflifesurvey.com/species/parascorpaena-aurita/',
photo: 'https://images.reeflifesurvey.com/0/species_cb_570dd32a84f77.w1300.h866.jpg',
type: 'Fish',
subtype: 'Scorpionfish',
},
{
name: 'Leaf Scorpionfish',
site: 'https://reeflifesurvey.com/species/taenianotus-triacanthus/',
photo: 'https://images.reeflifesurvey.com/0/species_d2_571429baf3ed7.w1300.h866.jpg',
type: 'Fish',
subtype: 'Scorpionfish',
},
{
name: 'Papua Scorpionfish',
site: 'https://reeflifesurvey.com/species/scorpaenopsis-papuensis/',
photo: 'https://images.reeflifesurvey.com/0/species_22_570f01536f2ed.w1300.h866.jpg',
type: 'Fish',
subtype: 'Scorpionfish',
},
{
name: 'Reef Scorpionfish',
site: 'https://reeflifesurvey.com/species/synanceia-verrucosa/',
photo: 'https://images.reeflifesurvey.com/0/species_bd_570dba2c27ec5.w1300.h866.jpg',
type: 'Fish',
subtype: 'Scorpionfish',
},
{
name: 'Razorfish',
site: 'https://reeflifesurvey.com/species/aeoliscus-strigatus/',
photo: 'https://images.reeflifesurvey.com/0/species_9a_57539da9f360f.w1300.h866.jpg',
type: 'Fish',
subtype: 'Razorfish',
},
{
name: 'Redbanded Shrimpgoby',
site: 'https://reeflifesurvey.com/species/amblyeleotris-fasciata/',
photo: 'https://images.reeflifesurvey.com/0/species_cc_58eee471a9ec0.w1300.h866.jpg',
type: 'Fish',
subtype: 'Goby',
},
{
name: 'Gorgeous Goby',
site: 'https://reeflifesurvey.com/species/amblyeleotris-wheeleri/',
photo: 'https://images.reeflifesurvey.com/0/species_27_57580db0465ef.w1300.h866.jpg',
type: 'Fish',
subtype: 'Goby',
},
{
name: 'Magnificent Shrimp',
site: 'https://reeflifesurvey.com/species/ancylomenes-magnificus/',
photo: 'https://images.reeflifesurvey.com/0/species_55_57d92def934aa.w1300.h866.jpg',
type: 'Shrimp',
subtype: 'Shrimp',
},
{
name: 'Painted Shrimp',
site: 'https://reeflifesurvey.com/species/campylonotus-vagans/',
photo: 'https://images.reeflifesurvey.com/0/species_31_57a126540716d.w1300.h866.JPG',
type: 'Shrimp',
subtype: 'Shrimp',
},
{
name: 'Mantis Shrimp',
site: 'https://reeflifesurvey.com/species/odontodactylus-scyllarus/',
photo: 'https://images.reeflifesurvey.com/0/species_99_57d9342e94a4c.w1300.h866.jpg',
type: 'Shrimp',
subtype: 'Shrimp',
},
{
name: 'Pederson Cleaner Shrimp',
site: 'https://reeflifesurvey.com/species/periclimenes-pedersoni/',
photo: 'https://images.reeflifesurvey.com/0/species_56_57e36be43a23f.w1300.h866.jpg',
type: 'Shrimp',
subtype: 'Shrimp',
},
{
name: 'Banded Cleaner Shrimp',
site: 'https://reeflifesurvey.com/species/stenopus-hispidus/',
photo: 'https://images.reeflifesurvey.com/0/species_11_5744f825e876a.w1300.h866.JPG',
type: 'Shrimp',
subtype: 'Shrimp',
},
{
name: 'Squat Shrimp',
site: 'https://reeflifesurvey.com/species/thor-amboinensis/',
photo: 'https://images.reeflifesurvey.com/0/species_4d_577c79755fb69.w1300.h866.jpg',
type: 'Shrimp',
subtype: 'Shrimp',
},
{
name: 'Octopus Ornatus',
site: 'https://reeflifesurvey.com/species/callistoctopus-ornatus/',
photo: 'https://images.reeflifesurvey.com/0/species_05_59573150af214.w1300.h866.jpg',
type: 'Octopus',
subtype: 'Octopus',
},
{
name: 'Blue Ringed Octopus',
site: 'https://reeflifesurvey.com/species/hapalochlaena-maculosa/',
photo: 'https://images.reeflifesurvey.com/0/species_04_572006d177f46.w1300.h866.jpg',
type: 'Octopus',
subtype: 'Octopus',
},
{
name: 'Day Octopus',
site: 'https://reeflifesurvey.com/species/octopus-cyanea/',
photo: 'https://images.reeflifesurvey.com/0/species_08_578f437da20cb.w1300.h866.jpg',
type: 'Octopus',
subtype: 'Octopus',
},
{
name: 'Common Octopus',
site: 'https://reeflifesurvey.com/species/octopus-vulgaris/',
photo: 'https://images.reeflifesurvey.com/0/species_07_5738101a97445.w1300.h866.jpg',
type: 'Octopus',
subtype: 'Octopus',
},
{
name: 'Manta Ray',
site: 'https://reeflifesurvey.com/species/manta-birostris',
photo: 'https://images.reeflifesurvey.com/0/species_8d_5705c04c9922e.w1300.h866.jpg',
type: 'Ray',
subtype: 'Manta Ray',
},
{
name: 'Common Cuttlefish',
site: 'https://reeflifesurvey.com/species/sepia-officinalis/',
photo: 'https://images.reeflifesurvey.com/0/species_fb_573854b42e14e.w1300.h866.jpg',
type: 'Cuttlefish',
subtype: 'Cuttlefish',
},
{
name: 'Broadclub Cuttlefish',
site: 'https://reeflifesurvey.com/species/sepia-latimanus/',
photo: 'https://images.reeflifesurvey.com/0/species_28_579550badcd0f.w1300.h866.jpg',
type: 'Cuttlefish',
subtype: 'Cuttlefish',
},
{
name: 'White-spotted Eagle Ray',
site: 'https://reeflifesurvey.com/species/aetobatus-narinari/',
photo: 'https://images.reeflifesurvey.com/0/species_a9_58294c65a2c62.w1300.h866.jpg',
type: 'Ray',
subtype: 'Eagly Ray',
},
{
name: 'Common Eagle Ray',
site: 'https://reeflifesurvey.com/species/myliobatis-aquila/',
photo: 'https://images.reeflifesurvey.com/0/species_54_5791a2bb801f0.w1300.h866.JPG',
type: 'Ray',
subtype: 'Eagly Ray',
},
{
name: 'Sea Snake',
site: 'https://reeflifesurvey.com/species/aipysurus-tenuis/',
photo: 'https://images.reeflifesurvey.com/0/species_4f_5768fa5434877.w1300.h866.jpg',
type: 'Snake',
subtype: 'Snake',
},
{
name: 'Mackerel Tuna',
site: 'https://reeflifesurvey.com/species/euthynnus-affinis/',
photo: 'https://images.reeflifesurvey.com/0/species_a2_57730df300db5.w1300.h866.jpg',
type: 'Fish',
subtype: 'Tuna',
},
{
name: 'Bluefin Trevally',
site: 'https://reeflifesurvey.com/species/caranx-melampygus/',
photo: 'https://images.reeflifesurvey.com/0/species_31_5a1b88b755d83.w1300.h866.jpg',
type: 'Fish',
subtype: 'Trevally',
},
{
name: 'Silver Trevally',
site: 'https://reeflifesurvey.com/species/pseudocaranx-georgianus/',
photo: 'https://images.reeflifesurvey.com/0/species_ee_573555398a747.w1300.h866.jpg',
type: 'Fish',
subtype: 'Trevally',
},
{
name: 'Golden Trevally',
site: 'https://reeflifesurvey.com/species/gnathanodon-speciosus/',
photo: 'https://images.reeflifesurvey.com/0/species_62_5735516c3db19.w1300.h866.JPG',
type: 'Fish',
subtype: 'Trevally',
},
{
name: 'Big Eye Trevally',
site: 'https://reeflifesurvey.com/species/caranx-sexfasciatus/',
photo: 'https://images.reeflifesurvey.com/0/species_ec_573537d672b79.w1300.h866.JPG',
type: 'Fish',
subtype: 'Trevally',
},
{
name: 'Giant Trevally',
site: 'https://reeflifesurvey.com/species/caranx-ignobilis/',
photo: 'https://images.reeflifesurvey.com/0/species_07_5735199e6a719.w1300.h866.jpg',
type: 'Fish',
subtype: 'Trevally',
},
{
name: 'Yellowtail Barracuda',
site: 'https://reeflifesurvey.com/species/sphyraena-flavicauda/',
photo: 'https://images.reeflifesurvey.com/0/species_63_5772fe39415bc.w1300.h866.jpg',
type: 'Fish',
subtype: 'Barracuda',
},
{
name: 'Barracuda',
site: 'https://reeflifesurvey.com/species/sphyraena-ensis/',
photo: 'https://images.reeflifesurvey.com/0/species_c2_57fcd1a0d0706.w1300.h866.jpg',
type: 'Fish',
subtype: 'Barracuda',
},
{
name: 'Blackfin Barracuda',
site: 'https://reeflifesurvey.com/species/sphyraena-qenie/',
photo: 'https://images.reeflifesurvey.com/0/species_84_5a978743a2965.w1300.h866.jpg',
type: 'Fish',
subtype: 'Barracuda',
},
{
name: 'Great Barracuda',
site: 'https://reeflifesurvey.com/species/sphyraena-barracuda/',
photo: 'https://images.reeflifesurvey.com/0/species_fd_5772f875f1a17.w1300.h866.jpg',
type: 'Fish',
subtype: 'Barracuda',
},
{
name: 'Blackbar Soldierfish',
site: 'https://reeflifesurvey.com/species/myripristis-jacobus/',
photo: 'https://images.reeflifesurvey.com/0/species_07_576cb9994d286.w1300.h866.jpg',
type: 'Fish',
subtype: 'Soldierfish',
},
{
name: 'Big Eye Soldierfish',
site: 'https://reeflifesurvey.com/species/myripristis-pralinia/',
photo: 'https://images.reeflifesurvey.com/0/species_d5_570c40091164d.w1300.h866.jpg',
type: 'Fish',
subtype: 'Soldierfish',
},
{
name: 'Cardinalfish',
site: 'https://reeflifesurvey.com/species/apogon-victoriae/',
photo: 'https://images.reeflifesurvey.com/0/species_40_578844ec219fc.w1300.h866.jpg',
type: 'Fish',
subtype: 'Cardinalfish',
},
{
name: 'Pink Cardinalfish',
site: 'https://reeflifesurvey.com/species/apogon-pacificus/',
photo: 'https://images.reeflifesurvey.com/0/species_68_578443b1a88f8.w1300.h866.JPG',
type: 'Fish',
subtype: 'Cardinalfish',
},
{
name: 'Tryons Nudibranch',
site: 'https://reeflifesurvey.com/species/risbecia-tryoni/',
photo: 'https://images.reeflifesurvey.com/0/species_df_578c3b6907b7a.w1300.h866.JPG',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Red Lined Flabellina',
site: 'https://reeflifesurvey.com/species/flabellina-rubrolineata/',
photo: 'https://images.reeflifesurvey.com/0/species_f6_5716dea56c5ed.w1300.h866.jpg',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Magnificent Nudibranch',
site: 'https://reeflifesurvey.com/species/chromodoris-magnifica/',
photo: 'https://images.reeflifesurvey.com/0/species_27_578c2e4654607.w1300.h866.JPG',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Black Margined Nudibranch',
site: 'https://reeflifesurvey.com/species/doriprismatica-atromarginata/',
photo: 'https://images.reeflifesurvey.com/0/species_52_578ec487e4a44.w1300.h866.jpg',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Gem Nudibranch',
site: 'https://reeflifesurvey.com/species/goniobranchus-geminus/',
photo: 'https://images.reeflifesurvey.com/0/species_bd_5792e968a35dc.w1300.h866.jpg',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Obscure Nudibranch',
site: 'https://reeflifesurvey.com/species/hypselodoris-obscura/',
photo: 'https://images.reeflifesurvey.com/0/species_e2_575b3f295239d.w1300.h866.JPG',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Heavenly Phyllidia',
site: 'https://reeflifesurvey.com/species/phyllidia-coelestis/',
photo: 'https://images.reeflifesurvey.com/0/species_1c_5791e0eb9a92f.w1300.h866.jpg',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Danielles Thurunna',
site: 'https://reeflifesurvey.com/species/thorunna-daniellae/',
photo: 'https://images.reeflifesurvey.com/0/species_ba_5744f23de1818.w1300.h866.JPG',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Spanish Dancer',
site: 'https://reeflifesurvey.com/species/hexabranchus-sanguineus/',
photo: 'https://images.reeflifesurvey.com/0/species_a8_5772f286c4928.w1300.h866.JPG',
type: 'Nudibranch',
subtype: 'Nudibranch',
},
{
name: 'Yellowfin Parrotfish',
site: 'https://reeflifesurvey.com/species/scarus-flavipectoralis/',
photo: 'https://images.reeflifesurvey.com/0/species_c9_574a791002916.w1300.h866.jpg',
type: 'Fish',
subtype: 'Parrotfish',
},
{
name: 'Orange Clownfish',
site: 'https://reeflifesurvey.com/species/amphiprion-percula/',
photo: 'https://images.reeflifesurvey.com/0/species_42_56f0b88b9140c.w1300.h866.jpg',
type: 'Fish',
subtype: 'Clownfish',
},
{
name: 'False Clownfish',
site: 'https://reeflifesurvey.com/species/amphiprion-ocellaris/',
photo: 'https://images.reeflifesurvey.com/0/species_6c_57c14fe630111.w1300.h866.jpg',
type: 'Fish',
subtype: 'Clownfish',
},
{
name: 'Black Anemonefish',
site: 'https://reeflifesurvey.com/species/amphiprion-melanopus/',
photo: 'https://images.reeflifesurvey.com/0/species_8e_57c14f3d1d532.w1300.h866.jpg',
type: 'Fish',
subtype: 'Clownfish',
},
{
name: 'Spinecheek Clownfish',
site: 'https://reeflifesurvey.com/species/premnas-biaculeatus/',
photo: 'https://images.reeflifesurvey.com/0/species_71_56f20d99702d8.w1300.h866.jpg',
type: 'Fish',
subtype: 'Clownfish',
},
{
name: 'Bluespotted Cornetfish',
site: 'https://reeflifesurvey.com/species/fistularia-commersonii/',
photo: 'https://images.reeflifesurvey.com/0/species_2b_570daa2ab14e9.w1300.h866.jpg',
type: 'Fish',
subtype: 'Cornetfish',
},
{
name: 'Bumphead Parrotfish',
site: 'https://reeflifesurvey.com/species/bolbometopon-muricatum/',
photo: 'https://images.reeflifesurvey.com/0/species_f6_574aba0a31f7d.w1300.h866.jpg',
type: 'Fish',
subtype: 'Parrotfish',
},
{
name: 'Napoleon Wrasse',
site: 'https://reeflifesurvey.com/species/cheilinus-undulatus/',
photo: 'https://images.reeflifesurvey.com/0/species_e7_57463ab55fe49.w1300.h866.jpg',
type: 'Fish',
subtype: 'Parrotfish',
},
{
name: 'Bicolor Parrotfish',
site: 'https://reeflifesurvey.com/species/cetoscarus-ocellatus/',
photo: 'https://images.reeflifesurvey.com/0/species_35_574a5fda7b827.w1300.h866.jpg',
type: 'Fish',
subtype: 'Parrotfish',
},
{
name: 'Bleekers Parrotfish',
site: 'https://reeflifesurvey.com/species/chlorurus-bleekeri/',
photo: 'https://images.reeflifesurvey.com/0/species_f8_574aa89414b5d.w1300.h866.jpg',
type: 'Fish',
subtype: 'Parrotfish',
},
{
name: 'Pacific Trumpetfish',
site: 'https://reeflifesurvey.com/species/aulostomus-chinensis/',
photo: 'https://images.reeflifesurvey.com/0/species_39_570da3c0bf56a.w1300.h866.jpg',
type: 'Fish',
subtype: 'Trumpetfish',
},
{
name: 'Trumpetfish maculatus',
site: 'https://reeflifesurvey.com/species/aulostomus-maculatus/',
photo: 'https://images.reeflifesurvey.com/0/species_c6_576c99f1b2c60.w1300.h866.jpg',
type: 'Fish',
subtype: 'Trumpetfish',
},
{
name: 'Gold-banded Butterflyfish',
site: 'https://reeflifesurvey.com/species/chaetodon-aureofasciatus/',
photo: 'https://images.reeflifesurvey.com/0/species_0e_56de1a819f9c6.w1300.h866.jpg',
type: 'Fish',
subtype: 'Butterflyfish',
},
{
name: 'Eclipse Butterflyfish',
site: 'https://reeflifesurvey.com/species/chaetodon-bennetti/',
photo: 'https://images.reeflifesurvey.com/0/species_bd_56e203c488681.w1300.h866.jpg',
type: 'Fish',
subtype: 'Butterflyfish',
},
{
name: 'Brown Butterflyfish',
site: 'https://reeflifesurvey.com/species/chaetodon-kleinii/',
photo: 'https://images.reeflifesurvey.com/0/species_0a_56de28c0644d0.w1300.h866.jpg',
type: 'Fish',
subtype: 'Butterflyfish',
},
{
name: 'Lorde Howe Butterflyfish',
site: 'https://reeflifesurvey.com/species/amphichaetodon-howensis/',
photo: 'https://images.reeflifesurvey.com/0/species_76_56e2106358721.w1300.h866.jpg',
type: 'Fish',
subtype: 'Butterflyfish',
},
{
name: 'Titan Triggerfish',
site: 'https://reeflifesurvey.com/species/balistoides-viridescens/',
photo: 'https://images.reeflifesurvey.com/0/species_86_577343c1765f6.w1300.h866.jpg',
type: 'Fish',
subtype: 'Triggerfish',
},
{
name: 'Red Tooth Triggerfish',
site: 'https://reeflifesurvey.com/species/odonus-niger/',
photo: 'https://images.reeflifesurvey.com/0/species_3d_5773523487cc7.w1300.h866.jpg',
type: 'Fish',
subtype: 'Triggerfish',
},
{
name: 'Bridled Triggerfish',
site: 'https://reeflifesurvey.com/species/sufflamen-fraenatum/',
photo: 'https://images.reeflifesurvey.com/0/species_d0_57514d75591e6.w1300.h866.jpg',
type: 'Fish',
subtype: 'Triggerfish',
},
{
name: 'Half-moon Triggerfish',
site: 'https://reeflifesurvey.com/species/sufflamen-chrysopterum/',
photo: 'https://images.reeflifesurvey.com/0/species_57_57514bb24bfd5.w1300.h866.jpg',
type: 'Fish',
subtype: 'Triggerfish',
},
{
name: 'Striped Triggerfish',
site: 'https://reeflifesurvey.com/species/balistapus-undulatus/',
photo: 'https://images.reeflifesurvey.com/0/species_29_57733d5a87498.w1300.h866.jpg',
type: 'Fish',
subtype: 'Triggerfish',
},
{
name: 'Humpback Unicornfish',
site: 'https://reeflifesurvey.com/species/naso-brachycentron/',
photo: 'https://images.reeflifesurvey.com/0/species_58_5993f0ccd6f15.w1300.h866.jpg',
type: 'Fish',
subtype: 'Unicornfish',
},
{
name: 'Blue-spine Unicornfish',
site: 'https://reeflifesurvey.com/species/naso-unicornis/',
photo: 'https://images.reeflifesurvey.com/0/species_ed_574ed2c731b74.w1300.h866.jpg',
type: 'Fish',
subtype: 'Unicornfish',
},
{
name: 'Striped Sweetlips',
site: 'https://reeflifesurvey.com/species/plectorhinchus-lessonii/',
photo: 'https://images.reeflifesurvey.com/0/species_ac_573bc2fb7eaec.w1300.h866.JPG',
type: 'Fish',
subtype: 'Sweetlips',
},
{
name: 'Oblique-banded Sweetlips',
site: 'https://reeflifesurvey.com/species/plectorhinchus-lineatus/',
photo: 'https://images.reeflifesurvey.com/0/species_9a_577b5ac23378f.w1300.h866.JPG',
type: 'Fish',
subtype: 'Sweetlips',
},
{
name: 'Oriental Sweetlips',
site: 'https://reeflifesurvey.com/species/plectorhinchus-vittatus/',
photo: 'https://images.reeflifesurvey.com/0/species_51_579dda39c87d8.w1300.h866.jpg',
type: 'Fish',
subtype: 'Sweetlips',
},
{
name: 'Giant Sweetlips',
site: 'https://reeflifesurvey.com/species/plectorhinchus-albovittatus/',
photo: 'https://images.reeflifesurvey.com/0/species_88_5774ffad9557f.w1300.h866.jpg',
type: 'Fish',
subtype: 'Sweetlips',
},
{
name: 'Clown Triggerfish',
site: 'https://reeflifesurvey.com/species/balistoides-conspicillum/',
photo: 'https://images.reeflifesurvey.com/0/species_98_5768b1443fcbe.w1300.h866.jpg',
type: 'Fish',
subtype: 'Triggerfish',
},
{
name: 'Ornate Butterflyfish',
site: 'https://reeflifesurvey.com/species/chaetodon-ornatissimus/',
photo: 'https://images.reeflifesurvey.com/0/species_88_56de527269e83.w1300.h866.jpg',
type: 'Fish',
subtype: 'Butterflyfish',
},
{
name: 'Harlequin Sweetlips',
site: 'https://reeflifesurvey.com/species/plectorhinchus-chaetodonoides/',
photo: 'https://images.reeflifesurvey.com/0/species_6a_573bb15cccd0d.w1300.h866.jpg',
type: 'Fish',
subtype: 'Sweetlips',
},
{
name: 'Orange Spine Unicornfish',
site: 'https://reeflifesurvey.com/species/naso-lituratus/',
photo: 'https://images.reeflifesurvey.com/0/species_e9_57d8bb37d4c9c.w1300.h866.jpg',
type: 'Fish',
subtype: 'Unicornfish',
},
{
name: 'Western Australian Seahorse',
site: 'https://reeflifesurvey.com/species/hippocampus-angustus/',
photo: 'https://images.reeflifesurvey.com/0/species_70_57f5caad06f1c.w1300.h866.JPG',
type: 'Seahorse',
subtype: 'Seahorse',
},
{
name: 'Pygmy Seahorse',
site: 'https://reeflifesurvey.com/species/hippocampus-bargibanti/',
photo: 'https://images.reeflifesurvey.com/0/species_49_570d9352604a7.w1300.h866.jpg',
type: 'Seahorse',
subtype: 'Seahorse',
},
{
name: "White's Seahorse",
site: 'https://reeflifesurvey.com/species/hippocampus-whitei/',
photo: 'https://images.reeflifesurvey.com/0/species_c5_570da06cb520e.w1300.h866.jpg',
type: 'Seahorse',
subtype: 'Seahorse',
},
{
name: 'Blacktip Reef Shark',
site: 'https://reeflifesurvey.com/species/carcharhinus-melanopterus/',
photo: 'https://images.reeflifesurvey.com/0/species_b5_5775d90277a96.w1300.h866.jpg',
type: 'Shark',
subtype: 'Shark',
},
{
name: 'Hermit Crab',
site: 'https://reeflifesurvey.com/species/calcinus-spicatus/',
photo: 'https://images.reeflifesurvey.com/0/species_1e_59c85a79b3ac1.w1300.h866.JPG',
type: 'Crab',
subtype: 'Crab',
},
{
name: 'Red Rock Crab',
site: 'https://reeflifesurvey.com/species/cancer-productus/',
photo: 'https://images.reeflifesurvey.com/0/species_54_59db34f0a742b.w1300.h866.jpg',
type: 'Crab',
subtype: 'Crab',
},
{
name: 'Spotted Hermit Crab',
site: 'https://reeflifesurvey.com/species/dardanus-megistos/',
photo: 'https://images.reeflifesurvey.com/0/species_58_57d92aac7c3b8.w1300.h866.jpg',
type: 'Crab',
subtype: 'Crab',
},
{
name: 'Red Spider Crab',
site: 'https://reeflifesurvey.com/species/schizophrys-aspera/',
photo: 'https://images.reeflifesurvey.com/0/species_e3_59e3fa4684f6f.w1300.h866.jpg',
type: 'Crab',
subtype: 'Crab',
},
{
name: 'Trapeze Crab',
site: 'https://reeflifesurvey.com/species/trapezia-rufopunctata/',
photo: 'https://images.reeflifesurvey.com/0/species_9a_59e3fe68b98bd.w1300.h866.JPG',
type: 'Crab',
subtype: 'Crab',
},
{
name: 'Arrow Crab',
site: 'https://reeflifesurvey.com/species/stenorhynchus-lanceolatus/',
photo: 'https://images.reeflifesurvey.com/0/species_cd_57385d56d5acd.w1300.h866.jpg',
type: 'Crab',
subtype: 'Crab',
},
];Analyzing flutter_debugging_app...
info • The value of the field '_counter' isn't used • lib/main.dart:29:7 • unused_field
info • The method '_incrementCounter' isn't used • lib/main.dart:31:8 • unused_element
2 issues found. (ran in 2.4s)
[✓] Flutter (Channel dev, v1.5.8, on Mac OS X 10.14.4 18E226, locale en-US)
• Flutter version 1.5.8 at /Users/emiliomaciel/flutter
• Framework revision 0ba67226ee (12 days ago), 2019-04-24 17:18:28 -0700
• Engine revision c63d1cf9c9
• Dart version 2.3.0 (build 2.3.0-dev.0.1 1f1592edce)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/emiliomaciel/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/emiliomaciel/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 35.2.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] VS Code (version 1.33.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.26.1
[✓] Connected device (1 available)
• Emílio’s iPhone • a79c59712b95afdff8852bc37765b7a14a5b299b • ios • iOS 12.1.4
Activity
[-]Memory Leak flutter framework iOS - gridview, listview - bug or me doing sth wrong?[/-][+]Memory Leak flutter framework iOS - gridview, listview - it IS a bug...[/+]diver2 commentedon May 6, 2019
@zoechi @cyanglaz you are the only ones that I know. Can you please take a look? Looks serious...
JohnnyDevX commentedon May 7, 2019
diver2 commentedon May 7, 2019
Hixie commentedon May 8, 2019
jacob314 commentedon May 8, 2019
fyi @terrylucas this is a case the Dart DevTools memory profiler might be able to help with.
dnfield commentedon May 8, 2019
Can you run this in profile mode and see if you still get the memory ballooning? A couple of us have tried this and only see it in debug mode, but not profile. This is true on iOS and Android.
dnfield commentedon May 8, 2019
Also, according to @jason-simmons it seems like it might be the widget inspector that's holding on to references to the images after they should be GC-able (which may be why this doesn't repro on profile/release mode).
diver2 commentedon May 8, 2019
Will try tomorrow (late here in France) - but what I can tell right on is that the app crashed on the iOS phone (an iphone6) due to OOM. Debug mode. So it is not just the widget inspector, the memory is getting used in the smartphone.
Cheers
dnfield commentedon May 8, 2019
The theory is that having the Widget Inspector enabled might be causing something on the phone to not release the images for garbage collection - it may be holding a reference somewhere to the image preventing it form getting collected. The Inspector is not enabled in profile mode though, where this problem seems to go away.
jacob314 commentedon May 9, 2019
If you run the app in debug mode from the
flutter toolsthe widget inspector should definitely not be holding on to any widgets. If the widget inspector is activated from IntelliJ or Dart DevTools it could be holding on to references from widgets from the last snapshot of the widget tree that was captured. We do believe we do a good job of freeing references to widgets not in the last snapshot of the widget tree captured by group allocating and freeing references to objects tracked by the inspector.diver2 commentedon May 9, 2019
Hi @dnfield , I've made the test with the code above with profiling mode - going to Xcode, building for profiling (menu Product, Build For, Profile) and then running without building.
And, if I scroll down like crazy, I manage to crash the app - the memory goes from 130MB to +650MB, and boom...
I noticed that if I scroll slowly, the app manages to free memory sometimes, even though it settles at a minimum of 400MB... but it does go to 500MB and down to 320, back up, etc...
So there is some garbage collection going on. But not enough...
dnfield commentedon May 9, 2019
@diver2 I wasn't able to reproduce that but will try again.
89 remaining items
ds84182 commentedon Aug 18, 2019
Ok, here's an update for @chinmaygarde:
Engine changes seem to work, as long as I let the GC free the images. I also fixed a bug in my custom image cache, so that makes things slightly better too. However, if I call
Image.disposemanually, the disposal does not actually happen. I think this is due to #28912.Thanks for all the hard work! This app is image heavy, and I really do see the IO thread improvements. Fetching and displaying cached low resolution thumbnails from disk is almost in the sub frame levels.
DyaryRaoof commentedon Oct 12, 2019
same issue, any solution ?
sooxt98 commentedon Oct 20, 2019
The fix is here #42785 🎉🎉🎉
gabryelferreira commentedon Dec 26, 2019
It is still crashing, even with cacheWidth and cacheHeight properties. Any other possible solution?
dnfield commentedon Jan 9, 2020
#48536 should make this better.
YudiH commentedon Jan 16, 2020
Still having this issue in iPhone 6+.
Above is what I have inside a ListTile, wrapped inside a ListViewBuilder for my list of up to about 500+ images.
App loads the list smoothly but crashes without warning or errors on scroll. Just shows lost connection to device. Any help/clue/guidance would be much appreciated. Thanks.
Edit: It crashes when the list has more than 100+ images. Around or below that number the crash doesn't happen.
iampato commentedon Apr 26, 2020
Having the same issue over here
danielappelgren0 commentedon Jun 19, 2020
Having same issue with IPhone X, tried to limit maxCacheObject size from 200(default) to 100 to 75 to 25 without luck.
jvidalorozco commentedon Aug 10, 2020
Today Having the same issue over here
CoderJava commentedon Nov 16, 2020
Hm ... I still have this issue. And still haven't found a solution to this issue.
predeepravi commentedon Nov 16, 2020
JohnOnLee commentedon Dec 3, 2020
I'm using
CachedNetworkImageafter settingmemCacheWidth&memCacheHeightto a small value, the issue seems disappeared.github-actions commentedon Aug 8, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.