astoilkov / main-thread-scheduling

Fast and consistently responsive apps using a single function call
MIT License
1.29k stars 32 forks source link

Any GC concerns when using async/await #2

Closed ScriptedAlchemy closed 2 years ago

ScriptedAlchemy commented 2 years ago

If I use a .then() chain, I believe the browser is able to GC better compared to async await which I believe prevents automated GC

Have you come across this scenario before?

astoilkov commented 2 years ago

I know that async/await takes more memory compared to .then().

I don't know about GC being different when using async/await. If you have some resources regarding that you can share them. I'm interested in learning more about this.

I first implemented the library using .then() instead of async/await but refactored it afterward because the code was harder to understand and iterate on. I believe there might be a place for refactoring back to using .then() but for now I feel like it's a premature optimization. I am a believer in "Premature optimization is the root of all evil.".

astoilkov commented 2 years ago

I'm closing this issue as I'm not sure if GC is better when using .then() instead of await. However, if somebody adds to the conversation I will open it, so we can discuss it further.