Commit 26ec0af
committed
fix: dispose Tone.js instruments and reset data structures to free audio memory
- Add .dispose() calls before deleting instruments in ___createSynth()
for BUILTIN_SYNTHS, CUSTOM_SYNTHS, and CUSTOMSAMPLES code paths
- Add disposeAllInstruments() method to Synth that properly disposes
all instruments, filters, and effects for every turtle
- Call disposeAllInstruments() in Logo.doStopTurtles() to free decoded
AudioBuffers and Web Audio nodes when the stop button is pressed
- Close AudioContext in testTuner() and testSpecificFrequency() to
prevent orphaned audio resource leaks (~4-8 MB each)
- Reset unbounded data structures (turtleHeaps, turtleDicts,
notationNotes, _midiData, statusFields, specialArgs, connectionStore,
recordingBuffer) at the start of runLogoCommands() to free memory
between repeated runs
- Update test mocks to include disposeAllInstruments
Estimated RAM savings: ~65-145 MB depending on session length and
number of instruments loaded.1 parent f488f0b commit 26ec0af
3 files changed
+113
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
424 | 425 | | |
425 | 426 | | |
426 | 427 | | |
| 428 | + | |
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| |||
437 | 439 | | |
438 | 440 | | |
439 | 441 | | |
| 442 | + | |
440 | 443 | | |
441 | 444 | | |
442 | 445 | | |
| |||
451 | 454 | | |
452 | 455 | | |
453 | 456 | | |
| 457 | + | |
454 | 458 | | |
455 | 459 | | |
456 | 460 | | |
| |||
465 | 469 | | |
466 | 470 | | |
467 | 471 | | |
| 472 | + | |
468 | 473 | | |
469 | 474 | | |
470 | 475 | | |
| |||
1069 | 1074 | | |
1070 | 1075 | | |
1071 | 1076 | | |
| 1077 | + | |
1072 | 1078 | | |
1073 | 1079 | | |
1074 | 1080 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1043 | 1048 | | |
1044 | 1049 | | |
1045 | 1050 | | |
| |||
1148 | 1153 | | |
1149 | 1154 | | |
1150 | 1155 | | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
1151 | 1175 | | |
1152 | 1176 | | |
1153 | 1177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1562 | 1562 | | |
1563 | 1563 | | |
1564 | 1564 | | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1565 | 1572 | | |
1566 | 1573 | | |
1567 | 1574 | | |
| |||
1575 | 1582 | | |
1576 | 1583 | | |
1577 | 1584 | | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
1578 | 1592 | | |
1579 | 1593 | | |
1580 | 1594 | | |
| |||
1585 | 1599 | | |
1586 | 1600 | | |
1587 | 1601 | | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
1588 | 1609 | | |
1589 | 1610 | | |
1590 | 1611 | | |
| |||
3509 | 3530 | | |
3510 | 3531 | | |
3511 | 3532 | | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
3512 | 3595 | | |
3513 | 3596 | | |
3514 | 3597 | | |
| |||
0 commit comments