7mada123 / disposable_cached_images

MIT License
9 stars 4 forks source link

Isolate usage should be optional #15

Open spauldhaliwal opened 3 months ago

spauldhaliwal commented 3 months ago

Depending on the particulars of an app, using isolates can greatly increase memory usage. From my understanding, since all global properties are copied when spawning an isolate, there's the possibility of essentially doubling initial ram usage when the isolate is used. In my app in particular, the memory used by _imagesHelperIsolate matches that of the main isolate, which means ram usage is doubled.

For most apps this probably isn't an issue, but still I believe a flag in DisposableImages.init allowing users to disable isolate usage would be advisable.

Edit: Btw, in devtools you can now view ram usage of other isolates by clicking on "main #1" on the bottom blue bar of the devtools page. I believe this was a recent addition to devtools (or at least I wasn't aware of it until last year)

spauldhaliwal commented 1 month ago

This was an incorrect assessment on my part. The confusion comes from devtools reporting ~40 mb increase in allocated ram, however, this is a bug in devtools. Actually RSS increases are minimal.

https://github.com/flutter/flutter/issues/136864

7mada123 commented 1 month ago

I will let this open because it's still it's a good option to have Maybe the app use few images so there is no need for spawning an isolate

The is simple to implement hoverer I couldn't find time lately to do anything