srplab / starcore_for_flutter

middleware for flutter calling other script languages
140 stars 29 forks source link

memory leak caused from weak references - Pyhton+Flutter #23

Open MaxBerktoldRocketEngineer opened 3 years ago

MaxBerktoldRocketEngineer commented 3 years ago

Our company wants to use a pyhton libary to communicate to extern datahub. For that we integrated Python in our flutter project. So far so good. But after initializing the whole enviroment (loading all modules, services... ) we want to use the pyhton instance more then once without every time loading all new in. -> we made the "python" context globally so other functions can use it and call pyhton functions through it.

We used a function in a loop. But after a a view calls we get the following outputs: image The counter goes on and on....

We tried to resolve this using the "freeLocalFrame" method without success. Also tried with Starflut.gc() to get rid of it.

Somehow these methods reduce the amount of weak references. But not completely!!

App is not functional like this and reaches a critical level of weak refs after 25 min..

Would be very nice to get help here. Thank you.