Commit e23b8f5
committed
fix: resolve memory leak in parser buffer management with threshold-based shrinking
Implement smart buffer shrinking that only reallocates when there's significant waste:
- Only shrink if waste > max(4x remaining data, 64KB)
- When shrinking, allocate 2x remaining data for growth room
- Fall back to cursor strategy for normal cases
This prevents memory leaks from large buffers while avoiding excessive allocations in high-throughput scenarios, addressing both memory efficiency and performance concerns.1 parent 65bc3d4 commit e23b8f5
1 file changed
+19
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
118 | 134 | | |
119 | 135 | | |
120 | 136 | | |
| |||
0 commit comments