Commit 04ef2aa
committed
fix: free stale embedding engines when switching provider classes
Preserve the transactional behavior added to memory_set_model(), but
release the previous engine after a successful switch even when the new
model uses a different provider class.
Without this, switching between custom, local, and remote providers can
leave the old engine attached to the context until close or until the
same provider class is selected again. For local models this can keep
large model / VRAM allocations resident unnecessarily.
Also add a regression test covering cross-class provider switches to
ensure the previous engine is freed immediately and not double-freed on
database close.1 parent f47d2f9 commit 04ef2aa
2 files changed
Lines changed: 83 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1119 | 1119 | | |
1120 | 1120 | | |
1121 | 1121 | | |
1122 | | - | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
1123 | 1128 | | |
| 1129 | + | |
1124 | 1130 | | |
1125 | 1131 | | |
1126 | 1132 | | |
1127 | | - | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
1128 | 1139 | | |
| 1140 | + | |
1129 | 1141 | | |
1130 | 1142 | | |
1131 | | - | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1132 | 1149 | | |
| 1150 | + | |
1133 | 1151 | | |
1134 | 1152 | | |
1135 | 1153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2579 | 2579 | | |
2580 | 2580 | | |
2581 | 2581 | | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
2582 | 2643 | | |
2583 | 2644 | | |
2584 | 2645 | | |
| |||
2718 | 2779 | | |
2719 | 2780 | | |
2720 | 2781 | | |
| 2782 | + | |
2721 | 2783 | | |
2722 | 2784 | | |
2723 | 2785 | | |
| |||
0 commit comments