Commit 78c7fc4
http2: fix memory leak when headers are not emitted
When headers are not emitted to JS, e.g. because of an error
before that could happen, we currently still have the vector of
previously received headers lying around, each one holding
a reference count of 1.
To fix the resulting memory leak, release them in the `Http2Stream`
destructor.
Also, clear the vector of headers once they have been emitted –
there’s not need to keep it around, wasting memory.
PR-URL: nodejs#21373
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>1 parent 4d46e35 commit 78c7fc4
2 files changed
Lines changed: 10 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1137 | 1137 | | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | | - | |
1141 | | - | |
| 1140 | + | |
1142 | 1141 | | |
1143 | 1142 | | |
1144 | 1143 | | |
| |||
1155 | 1154 | | |
1156 | 1155 | | |
1157 | 1156 | | |
1158 | | - | |
| 1157 | + | |
1159 | 1158 | | |
1160 | | - | |
| 1159 | + | |
1161 | 1160 | | |
1162 | 1161 | | |
1163 | 1162 | | |
| |||
1166 | 1165 | | |
1167 | 1166 | | |
1168 | 1167 | | |
1169 | | - | |
1170 | 1168 | | |
1171 | 1169 | | |
1172 | 1170 | | |
| |||
1782 | 1780 | | |
1783 | 1781 | | |
1784 | 1782 | | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
1785 | 1788 | | |
1786 | 1789 | | |
1787 | 1790 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
656 | | - | |
657 | | - | |
| 656 | + | |
| 657 | + | |
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | 664 | | |
669 | 665 | | |
670 | 666 | | |
| |||
0 commit comments