Commit ce24cc5
committed
fix: defer library loading and fix DOM/event listener memory leaks
- Remove p5.min, p5-sound-adapter, and p5.dom.min from MYDEFINES
eager-load list. These libraries (~1.2 MB code, ~10-15 MB heap after
JIT) are only needed for the JS-export feature and are never called
by the main application. They remain available via RequireJS for
on-demand loading when needed.
- Remove Chart.js from MYDEFINES and add lazy-loading via require()
in the StatsWindow constructor. Chart.js is only used by the
statistics widget (~3-5 MB heap savings when widget is not opened).
- Fix pie menu click handler accumulation: replace anonymous
addEventListener on document.body with a named handler that is
removed before being re-added, preventing listener pile-up on
every right-click (~3-5 MB over a long session).
- Store idle watcher event listener references and setInterval ID to
enable proper cleanup via new _cleanupIdleWatcher() method,
preventing duplicate listeners on re-initialization.
- Fix GIF animator resource leaks: stopAnimation() and stopAll() now
pause gifPlayer, remove hidden <img> elements from DOM, and null
canvas references to allow garbage collection (~2-10 MB per GIF).
Estimated RAM savings: ~25-50 MB depending on session length and
features used.1 parent 81cefcb commit ce24cc5
4 files changed
+109
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| |||
2759 | 2764 | | |
2760 | 2765 | | |
2761 | 2766 | | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
2762 | 2770 | | |
2763 | 2771 | | |
2764 | 2772 | | |
2765 | 2773 | | |
2766 | 2774 | | |
2767 | 2775 | | |
2768 | 2776 | | |
2769 | | - | |
2770 | | - | |
| 2777 | + | |
| 2778 | + | |
2771 | 2779 | | |
2772 | 2780 | | |
2773 | 2781 | | |
| |||
2789 | 2797 | | |
2790 | 2798 | | |
2791 | 2799 | | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
2792 | 2819 | | |
2793 | 2820 | | |
2794 | 2821 | | |
| |||
7796 | 7823 | | |
7797 | 7824 | | |
7798 | 7825 | | |
7799 | | - | |
7800 | | - | |
7801 | | - | |
7802 | | - | |
7803 | | - | |
| 7826 | + | |
| 7827 | + | |
| 7828 | + | |
| 7829 | + | |
| 7830 | + | |
| 7831 | + | |
7804 | 7832 | | |
7805 | 7833 | | |
7806 | 7834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
219 | 230 | | |
220 | 231 | | |
221 | 232 | | |
222 | 233 | | |
223 | 234 | | |
224 | | - | |
| 235 | + | |
225 | 236 | | |
226 | 237 | | |
227 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
228 | 251 | | |
229 | 252 | | |
230 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3610 | 3610 | | |
3611 | 3611 | | |
3612 | 3612 | | |
3613 | | - | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
3614 | 3620 | | |
3615 | 3621 | | |
3616 | 3622 | | |
3617 | 3623 | | |
3618 | 3624 | | |
3619 | | - | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
3620 | 3628 | | |
3621 | 3629 | | |
3622 | 3630 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
40 | 51 | | |
41 | 52 | | |
42 | 53 | | |
| |||
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
55 | 86 | | |
56 | 87 | | |
57 | 88 | | |
| |||
0 commit comments