JS Closure Memory Leaks
နိဒါန်း
Problem: Arrow Function နဲ့ Memory Leak
ပြဿနာရှိတဲ့ Code
Memory Leak ဖြစ်တဲ့အကြောင်းရင်း
Memory Leak Chain
Solution: bind() Method သုံးခြင်း
Fix လုပ်ပြီးသား Code
bind() က Memory Leak ကို ဘယ်လို fix လုပ်သလဲ
Technical အသေးစိတ်
Arrow Function vs Bound Function
Memory Footprint နှိုင်းယှဉ်ချက်
ECMAScript Specification အရ ဆိုရင်
Arrow Function Closure (§15.3.3)
Bound Function (§20.2.3.2, §10.4.1)
Real-World ဥပမာ
Web Application: Fetch Requests
Performance Impact
Best Practices
၁. Long-lived Event Listener တွေမှာ bind() သုံးပါ
၂. { once: true } option ကို သုံးပါ
၃. Timer တွေမှာ bind() သုံးပါ
၄. Memory cleanup ကို သေချာ လုပ်ပါ
နိဂုံး
အဓိက Point တွေ
Performance Tips
Reference
Last updated