olexale / arkit_flutter_plugin

ARKit Flutter Plugin
MIT License
797 stars 225 forks source link

Dispose method now releases the main ARKit resource #112

Closed BrutalCoding closed 3 years ago

BrutalCoding commented 3 years ago

Every time the AR page was being used (e.g. closing & reopening several times) the sceneView was holding up a lot of memory (my testing was 100MB+ memory each time AR opened, without any assets loading). The sceneView is now optional but guards have been placed where sceneView was referenced to avoid runtime exceptions.

BrutalCoding commented 3 years ago

Made it a bit messy with merging branches after I submitted this PR, so I've reset it back to commit https://github.com/olexale/arkit_flutter_plugin/pull/112/commits/cb4b0b2b49d40ec1296fa4757e1c47375ea608b2 which was when I originally made this PR.

olexale commented 3 years ago

Hi @BrutalCoding , Thanks for your proposition, but this will not fix the leak, it will just explicitly release the most expensive object. Could you please pull the latest version (and especially this commit) and approve that the leak is gone?

BrutalCoding commented 3 years ago

Will take a look tomorrow and let you know. This PR did not cause any issues on my end, couldn't get past ~8 reopenings before and after this PR I got no limitations anymore.

However I'll still check the commit you mentioned.

BrutalCoding commented 3 years ago

Hi @olexale,

Your proposed fix seems to work too and the commit looks more robust. I'll close this issue.

Note: App has more than AR hence why the RAM is not representing this plugin on its own, just want to highlight its working:

Shortly after closing AR ~ 400 MB: image

Roughly 30 sec after closing AR again ~ 364 MB: image

While AR is open ~ 524 MB: image