forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8c75ad4
committed
Fix memory leaks in PL/Python.
Previously, plpython was in the habit of allocating a lot of stuff inTopMemoryContext, and it was very slipshod about making sure that stuffgot cleaned up; in particular, use of TopMemoryContext as fn_mcxt forfunction calls represents an unfixable leak, since we generally don'tknow what the called function might have allocated in fn_mcxt. Thisresults in session-lifespan leakage in certain usage scenarios, as forexample in a case reported by Ed Behn back in July.To fix, get rid of all the retail allocations in TopMemoryContext.All long-lived allocations are now made in sub-contexts that areassociated with specific objects (either pl/python procedures, orPython-visible objects such as cursors and plans). We can clean theseup when the associated object is deleted.I went so far as to get rid of PLy_malloc completely. There were acouple of places where it could still have been used safely, but onthe whole it was just an invitation to bad coding.Haribabu Kommi, based on a draft patch by Heikki Linnakangas;some further work by me1 parent64b2e7a commit8c75ad4
File tree
15 files changed
+221
-223
lines changed- src/pl/plpython
15 files changed
+221
-223
lines changedLines changed: 21 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
| 11 | + | |
11 | 12 |
| |
12 | 13 |
| |
13 | 14 |
| |
| |||
111 | 112 |
| |
112 | 113 |
| |
113 | 114 |
| |
114 |
| - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
115 | 121 |
| |
116 | 122 |
| |
117 | 123 |
| |
| |||
139 | 145 |
| |
140 | 146 |
| |
141 | 147 |
| |
142 |
| - | |
| 148 | + | |
143 | 149 |
| |
144 | 150 |
| |
145 | 151 |
| |
| |||
200 | 206 |
| |
201 | 207 |
| |
202 | 208 |
| |
203 |
| - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
204 | 215 |
| |
205 | 216 |
| |
206 | 217 |
| |
| |||
261 | 272 |
| |
262 | 273 |
| |
263 | 274 |
| |
264 |
| - | |
| 275 | + | |
265 | 276 |
| |
266 | 277 |
| |
267 | 278 |
| |
| |||
315 | 326 |
| |
316 | 327 |
| |
317 | 328 |
| |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
318 | 335 |
| |
319 |
| - | |
320 |
| - | |
321 |
| - | |
322 |
| - | |
323 |
| - | |
324 | 336 |
| |
325 | 337 |
| |
326 | 338 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
| 17 | + | |
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
852 | 852 |
| |
853 | 853 |
| |
854 | 854 |
| |
855 |
| - | |
| 855 | + | |
856 | 856 |
| |
857 | 857 |
|
Lines changed: 30 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
277 | 277 |
| |
278 | 278 |
| |
279 | 279 |
| |
280 |
| - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
281 | 286 |
| |
282 | 287 |
| |
283 | 288 |
| |
| |||
364 | 369 |
| |
365 | 370 |
| |
366 | 371 |
| |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
367 | 389 |
| |
368 | 390 |
| |
369 | 391 |
| |
370 |
| - | |
| 392 | + | |
371 | 393 |
| |
| 394 | + | |
| 395 | + | |
372 | 396 |
| |
373 |
| - | |
374 |
| - | |
375 |
| - | |
376 |
| - | |
377 |
| - | |
| 397 | + | |
378 | 398 |
| |
379 | 399 |
| |
380 | 400 |
| |
| |||
390 | 410 |
| |
391 | 411 |
| |
392 | 412 |
| |
393 |
| - | |
394 |
| - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
395 | 416 |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 |
|
Lines changed: 8 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| 14 | + | |
14 | 15 |
| |
15 | 16 |
| |
16 | 17 |
| |
| |||
80 | 81 |
| |
81 | 82 |
| |
82 | 83 |
| |
| 84 | + | |
83 | 85 |
| |
84 | 86 |
| |
85 | 87 |
| |
| |||
96 | 98 |
| |
97 | 99 |
| |
98 | 100 |
| |
| 101 | + | |
99 | 102 |
| |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 |
| - | |
104 |
| - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
105 | 106 |
| |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
| 107 | + | |
| 108 | + | |
111 | 109 |
| |
112 |
| - | |
113 | 110 |
| |
114 | 111 |
| |
115 | 112 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
| 20 | + | |
20 | 21 |
| |
21 | 22 |
| |
22 | 23 |
| |
|
0 commit comments
Comments
(0)