forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit46fb9c2
committed
Here is the patch with memory leak checker. This checker allow detect
in-chunk leaks, overwrite-next-chunk leaks and overwrite block-freeptr leaks.A in-chunk leak --- if something overwrite space after wanted (via palloc()size, but it is still inside chunk. For example x = palloc(12); /* create 16b chunk */ memset(x, '#', 13);this leak is in the current source total invisible, because chunk is 16b andleak is in the "align space". For this feature I add data_size to StandardChunk, and all memory which gofrom AllocSetAlloc() is marked as 0x7F. The MemoryContextCheck() is compiled '#ifdef USE_ASSERT_CHECKING'.I add this checking to 'tcop/postgres.c' and is active after each backendquery, but it is probably not sufficient, because some MemoryContext existonly during memory processing --- will good if someone who known whereit is needful (Tom:-) add it for others contexts; A problem in the current source is that we have still some malloc()allocation that is not needful and this allocation is total invisible forall context routines. For example Dllist in backend (pretty dirty it is incatcache where values in Dllist are palloc-ed, but list is malloc-ed).--- and BTW. this Dllist design stand in the way for query cache :-) Tom, if you agree I start replace some mallocs. BTW. --- Tom, have you idea for across transaction presistent allocation for SQL functions? (like regex - now it is via malloc) I almost forget. I add one if() to AllocSetAlloc(), for 'size' that aregreater than ALLOC_BIGCHUNK_LIMIT is not needful check AllocSetFreeIndex(),because 'fidx' is always 'ALLOCSET_NUM_FREELISTS - 1'. It a little brisk upallocation for very large chunks. Right? Karel1 parent0d32cdc commit46fb9c2
File tree
6 files changed
+284
-35
lines changed- src
- backend
- tcop
- utils/mmgr
- include
- nodes
- utils
6 files changed
+284
-35
lines changedLines changed: 9 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
1415 | 1415 |
| |
1416 | 1416 |
| |
1417 | 1417 |
| |
1418 |
| - | |
| 1418 | + | |
1419 | 1419 |
| |
1420 | 1420 |
| |
1421 | 1421 |
| |
| |||
1653 | 1653 |
| |
1654 | 1654 |
| |
1655 | 1655 |
| |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
1656 | 1663 |
| |
1657 | 1664 |
| |
1658 | 1665 |
| |
|
0 commit comments
Comments
(0)