PostgreSQL Source Code: src/backend/utils/mmgr/mcxt.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

40

47

48

49static void BogusFree(void *pointer);

50static void *BogusRealloc(void *pointer, Size size, int flags);

53

54

55

56

57#define BOGUS_MCTX(id) \

58 [id].free_p = BogusFree, \

59 [id].realloc = BogusRealloc, \

60 [id].get_chunk_context = BogusGetChunkContext, \

61 [id].get_chunk_space = BogusGetChunkSpace

62

64

74#ifdef MEMORY_CONTEXT_CHECKING

76#endif

77

78

88#ifdef MEMORY_CONTEXT_CHECKING

90#endif

91

92

102#ifdef MEMORY_CONTEXT_CHECKING

104#endif

105

106

116#ifdef MEMORY_CONTEXT_CHECKING

118#endif

119

120

130#ifdef MEMORY_CONTEXT_CHECKING

132#endif

133

134

135

136

137

138

139

140

152};

153

154#undef BOGUS_MCTX

155

156

157

158

159

161

162

163

164

165

173

174

176

180 int max_level, int max_children,

182 bool print_to_stderr);

184 const char *stats_string,

185 bool print_to_stderr);

186

187

188

189

190

191

192#define AssertNotInCriticalSection(context) \

193 Assert(CritSectionCount == 0 || (context)->allowInCritSection)

194

195

196

197

198

199#define MCXT_METHOD(pointer, method) \

200 mcxt_methods[GetMemoryChunkMethodID(pointer)].method

201

202

203

204

205

206

209{

211

212

213

214

215

216

218

219

221

222 header = *((const uint64 *) ((const char *) pointer - sizeof(uint64)));

223

224

226

228}

229

230

231

232

233

234

235

238{

240

241

243

244 header = *((const uint64 *) ((const char *) pointer - sizeof(uint64)));

245

246

248

249 return header;

250}

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

275{

276

279

280

281

282

283

284

285

286

288 {

290 if (curr == top)

291 return NULL;

292 }

294}

295

296

297

298

299

300

301

302static void

304{

305 elog(ERROR, "pfree called with invalid pointer %p (header 0x%016" PRIx64 ")",

307}

308

309static void *

311{

312 elog(ERROR, "repalloc called with invalid pointer %p (header 0x%016" PRIx64 ")",

314 return NULL;

315}

316

319{

320 elog(ERROR, "GetMemoryChunkContext called with invalid pointer %p (header 0x%016" PRIx64 ")",

322 return NULL;

323}

324

327{

328 elog(ERROR, "GetMemoryChunkSpace called with invalid pointer %p (header 0x%016" PRIx64 ")",

330 return 0;

331}

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355void

357{

359

360

361

362

364 "TopMemoryContext",

366

367

368

369

370

372

373

374

375

376

377

378

379

380

381

382

383

384

385

387 "ErrorContext",

388 8 * 1024,

389 8 * 1024,

390 8 * 1024);

392}

393

394

395

396

397

398

399void

401{

403

404

407

408

411}

412

413

414

415

416

417

418void

420{

422

423

425 {

427

428

429

430

431

432

433

434

435

438 }

439}

440

441

442

443

444

445

446

447void

449{

451

453 curr != NULL;

455 {

457 }

458}

459

460

461

462

463

464

465

466

467

468void

470{

472

474

475

476

477

478

479

480

481

482

483 curr = context;

484 for (;;)

485 {

487

488

491

492

493

494

495

496 parent = curr->parent;

498

499 if (curr == context)

500 break;

501 curr = parent;

502 }

503}

504

505

506

507

508

509

510static void

512{

514

516

518

520

521

522

523

524

525

526

528

529

530

531

532

533

535

536

537

538

539

540

541 context->ident = NULL;

542

544}

545

546

547

548

549

550

551void

553{

555

556

557

558

559

562}

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578void

581{

583

584

587

588 context->isReset = false;

589}

590

591

592

593

594

595

596

597

598

599

600

601

602

603void

606{

609

611

614 {

615 if (cur != cb)

616 continue;

617 if (prev)

619 else

621 return;

622 }

624}

625

626

627

628

629

630static void

632{

634

635

636

637

638

639

640 while ((cb = context->reset_cbs) != NULL)

641 {

644 }

645}

646

647

648

649

650

651

652

653

654

655

656

657void

659{

661 context->ident = id;

662}

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682void

684{

686 Assert(context != new_parent);

687

688

689 if (new_parent == context->parent)

690 return;

691

692

694 {

696

699 else

700 {

703 }

704

707 }

708

709

710 if (new_parent)

711 {

713 context->parent = new_parent;

719 }

720 else

721 {

722 context->parent = NULL;

725 }

726}

727

728

729

730

731

732

733

734

735

736

737

738

739void

741{

743

745}

746

747

748

749

750

751

754{

755 return MCXT_METHOD(pointer, get_chunk_context) (pointer);

756}

757

758

759

760

761

762

763

764

765

768{

769 return MCXT_METHOD(pointer, get_chunk_space) (pointer);

770}

771

772

773

774

775

778{

780

781 return context->parent;

782}

783

784

785

786

787

788bool

790{

792

793

794

795

796

798 return false;

799

801}

802

803

804

805

806

809{

811

813

814 if (recurse)

815 {

817 curr != NULL;

819 {

820 total += curr->mem_allocated;

821 }

822 }

823

824 return total;

825}

826

827

828

829

830

831void

834{

836

837 memset(consumed, 0, sizeof(*consumed));

838

839

840 context->methods->stats(context, NULL, NULL, consumed, false);

841

842

844 curr != NULL;

846 {

847 curr->methods->stats(curr, NULL, NULL, consumed, false);

848 }

849}

850

851

852

853

854

855

856

857

858

859void

861{

862

864}

865

866

867

868

869

870

871

872

873

874void

876 int max_level, int max_children,

877 bool print_to_stderr)

878{

880

881 memset(&grand_totals, 0, sizeof(grand_totals));

882

884 &grand_totals, print_to_stderr);

885

886 if (print_to_stderr)

888 "Grand total: %zu bytes in %zu blocks; %zu free (%zu chunks); %zu used\n",

892 else

893 {

894

895

896

897

898

899

900

901

902

903

907 errmsg_internal("Grand total: %zu bytes in %zu blocks; %zu free (%zu chunks); %zu used",

911 }

912}

913

914

915

916

917

918

919

920

921static void

923 int max_level, int max_children,

925 bool print_to_stderr)

926{

928 int ichild;

929

931

932

935 &level,

936 totals, print_to_stderr);

937

938

939

940

941

942

943

944

945

947 ichild = 0;

949 {

950 for (; child != NULL && ichild < max_children;

951 child = child->nextchild, ichild++)

952 {

954 max_level, max_children,

955 totals,

956 print_to_stderr);

957 }

958 }

959

960 if (child != NULL)

961 {

962

964

965 memset(&local_totals, 0, sizeof(local_totals));

966

967 ichild = 0;

968 while (child != NULL)

969 {

970 child->methods->stats(child, NULL, NULL, &local_totals, false);

971 ichild++;

973 }

974

975 if (print_to_stderr)

976 {

977 for (int i = 0; i < level; i++)

980 "%d more child contexts containing %zu total in %zu blocks; %zu free (%zu chunks); %zu used\n",

981 ichild,

987 }

988 else

992 errmsg_internal("level: %d; %d more child contexts containing %zu total in %zu blocks; %zu free (%zu chunks); %zu used",

993 level,

994 ichild,

1000

1001 if (totals)

1002 {

1007 }

1008 }

1009}

1010

1011

1012

1013

1014

1015

1016

1017

1018static void

1020 const char *stats_string,

1021 bool print_to_stderr)

1022{

1023 int level = *(int *) passthru;

1024 const char *name = context->name;

1026 char truncated_ident[110];

1027 int i;

1028

1029

1030

1031

1032

1033

1034 if (ident && strcmp(name, "dynahash") == 0)

1035 {

1038 }

1039

1040 truncated_ident[0] = '\0';

1041

1043 {

1044

1045

1046

1047

1048

1049

1050 int idlen = strlen(ident);

1051 bool truncated = false;

1052

1053 strcpy(truncated_ident, ": ");

1054 i = strlen(truncated_ident);

1055

1056 if (idlen > 100)

1057 {

1059 truncated = true;

1060 }

1061

1062 while (idlen-- > 0)

1063 {

1064 unsigned char c = *ident++;

1065

1066 if (c < ' ')

1067 c = ' ';

1068 truncated_ident[i++] = c;

1069 }

1070 truncated_ident[i] = '\0';

1071

1072 if (truncated)

1073 strcat(truncated_ident, "...");

1074 }

1075

1076 if (print_to_stderr)

1077 {

1078 for (i = 1; i < level; i++)

1080 fprintf(stderr, "%s: %s%s\n", name, stats_string, truncated_ident);

1081 }

1082 else

1087 level, name, stats_string, truncated_ident)));

1088}

1089

1090

1091

1092

1093

1094

1095

1096#ifdef MEMORY_CONTEXT_CHECKING

1097void

1099{

1101 context->methods->check(context);

1102

1104 curr != NULL;

1106 {

1108 curr->methods->check(curr);

1109 }

1110}

1111#endif

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145void

1150 const char *name)

1151{

1152

1154

1155

1157 Assert(node != parent);

1158

1159

1160 node->type = tag;

1163 node->parent = parent;

1168 node->ident = NULL;

1170

1171

1172 if (parent)

1173 {

1178

1180 }

1181 else

1182 {

1185 }

1186}

1187

1188

1189

1190

1191

1192

1193

1194void *

1196{

1198 {

1202 (errcode(ERRCODE_OUT_OF_MEMORY),

1203 errmsg("out of memory"),

1204 errdetail("Failed on request of size %zu in memory context \"%s\".",

1205 size, context->name)));

1206 }

1207 return NULL;

1208}

1209

1210

1211

1212

1213

1214

1215void

1217{

1218 elog(ERROR, "invalid memory alloc request size %zu", size);

1219}

1220

1221

1222

1223

1224

1225

1226

1227

1228void *

1230{

1231 void *ret;

1232

1235

1236 context->isReset = false;

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248 ret = context->methods->alloc(context, size, 0);

1249

1251

1252 return ret;

1253}

1254

1255

1256

1257

1258

1259

1260

1261

1262void *

1264{

1265 void *ret;

1266

1269

1270 context->isReset = false;

1271

1272 ret = context->methods->alloc(context, size, 0);

1273

1275

1277

1278 return ret;

1279}

1280

1281

1282

1283

1284

1285void *

1287{

1288 void *ret;

1289

1292

1295 elog(ERROR, "invalid memory alloc request size %zu", size);

1296

1297 context->isReset = false;

1298

1299 ret = context->methods->alloc(context, size, flags);

1301 return NULL;

1302

1304

1307

1308 return ret;

1309}

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319void

1321{

1324

1325}

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336void

1338{

1340

1341

1342

1343

1344

1348 errmsg("logging memory contexts of PID %d", MyProcPid)));

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1362}

1363

1364void *

1366{

1367

1368 void *ret;

1370

1373

1374 context->isReset = false;

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386 ret = context->methods->alloc(context, size, 0);

1387

1388 Assert(ret != NULL);

1390

1391 return ret;

1392}

1393

1394void *

1396{

1397

1398 void *ret;

1400

1403

1404 context->isReset = false;

1405

1406 ret = context->methods->alloc(context, size, 0);

1407

1408 Assert(ret != NULL);

1410

1412

1413 return ret;

1414}

1415

1416void *

1418{

1419

1420 void *ret;

1422

1425

1426 context->isReset = false;

1427

1428 ret = context->methods->alloc(context, size, flags);

1430 {

1431

1433 return NULL;

1434 }

1435

1437

1440

1441 return ret;

1442}

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459void *

1461 Size size, Size alignto, int flags)

1462{

1464 Size alloc_size;

1465 void *unaligned;

1466 void *aligned;

1467

1468

1469

1470

1471

1472

1473

1474

1475 Assert(alignto < (128 * 1024 * 1024));

1476

1477

1478 Assert((alignto & (alignto - 1)) == 0);

1479

1480

1481

1482

1483

1484 if (unlikely(alignto <= MAXIMUM_ALIGNOF))

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1505

1506#ifdef MEMORY_CONTEXT_CHECKING

1507

1508 alloc_size += 1;

1509#endif

1510

1511

1512

1513

1514

1515

1518

1519

1520 aligned = (void *) TYPEALIGN(alignto, (char *) unaligned +

1522

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1537

1538

1539 Assert((void *) TYPEALIGN(alignto, aligned) == aligned);

1540

1541#ifdef MEMORY_CONTEXT_CHECKING

1542 alignedchunk->requested_size = size;

1543

1544 set_sentinel(aligned, size);

1545#endif

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1560

1561

1564

1565 return aligned;

1566}

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583void *

1585{

1587}

1588

1589

1590

1591

1592

1593void

1595{

1596#ifdef USE_VALGRIND

1598#endif

1599

1601

1603}

1604

1605

1606

1607

1608

1609void *

1611{

1612#if defined(USE_ASSERT_CHECKING) || defined(USE_VALGRIND)

1614#endif

1615 void *ret;

1616

1618

1619

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1633

1635

1636 return ret;

1637}

1638

1639

1640

1641

1642

1643

1644void *

1646{

1647#if defined(USE_ASSERT_CHECKING) || defined(USE_VALGRIND)

1649#endif

1650 void *ret;

1651

1653

1654

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1669 return NULL;

1670

1672

1673 return ret;

1674}

1675

1676

1677

1678

1679

1680

1681void *

1683{

1684 void *ret;

1685

1686

1687 if (unlikely(oldsize > size))

1688 elog(ERROR, "invalid repalloc0 call: oldsize %zu, new size %zu",

1689 oldsize, size);

1690

1691 ret = repalloc(pointer, size);

1692 memset((char *) ret + oldsize, 0, (size - oldsize));

1693 return ret;

1694}

1695

1696

1697

1698

1699

1700

1701

1702void *

1704{

1705 void *ret;

1706

1709

1710 context->isReset = false;

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1723

1725

1726 return ret;

1727}

1728

1729

1730

1731

1732

1733

1734void *

1736{

1737

1739}

1740

1741

1742

1743

1744

1745char *

1747{

1748 char *nstr;

1749 Size len = strlen(string) + 1;

1750

1752

1753 memcpy(nstr, string, len);

1754

1755 return nstr;

1756}

1757

1758char *

1760{

1762}

1763

1764

1765

1766

1767

1768

1769char *

1771{

1772 char *out;

1773

1775

1777 memcpy(out, in, len);

1778 out[len] = '\0';

1779

1780 return out;

1781}

1782

1783

1784

1785

1786char *

1788{

1789 size_t n;

1790

1791 n = strlen(in);

1792 while (n > 0 && in[n - 1] == '\n')

1793 n--;

1795}

MemoryContext AlignedAllocGetChunkContext(void *pointer)

void * AlignedAllocRealloc(void *pointer, Size size, int flags)

Size AlignedAllocGetChunkSpace(void *pointer)

void AlignedAllocFree(void *pointer)

void AllocSetReset(MemoryContext context)

void * AllocSetRealloc(void *pointer, Size size, int flags)

Size AllocSetGetChunkSpace(void *pointer)

MemoryContext AllocSetGetChunkContext(void *pointer)

void AllocSetStats(MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr)

bool AllocSetIsEmpty(MemoryContext context)

void * AllocSetAlloc(MemoryContext context, Size size, int flags)

void AllocSetFree(void *pointer)

void AllocSetDelete(MemoryContext context)

void BumpFree(void *pointer)

void BumpDelete(MemoryContext context)

Size BumpGetChunkSpace(void *pointer)

void BumpStats(MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr)

MemoryContext BumpGetChunkContext(void *pointer)

void BumpReset(MemoryContext context)

bool BumpIsEmpty(MemoryContext context)

void * BumpRealloc(void *pointer, Size size, int flags)

void * BumpAlloc(MemoryContext context, Size size, int flags)

#define TYPEALIGN(ALIGNVAL, LEN)

#define MemSetAligned(start, val, len)

#define fprintf(file, fmt, msg)

int errmsg_internal(const char *fmt,...)

int errhidestmt(bool hide_stmt)

int errdetail(const char *fmt,...)

int errhidecontext(bool hide_ctx)

int errcode(int sqlerrcode)

int errmsg(const char *fmt,...)

#define ereport(elevel,...)

#define MCXT_ALLOC_NO_OOM

void * GenerationRealloc(void *pointer, Size size, int flags)

void GenerationReset(MemoryContext context)

void GenerationFree(void *pointer)

MemoryContext GenerationGetChunkContext(void *pointer)

Size GenerationGetChunkSpace(void *pointer)

bool GenerationIsEmpty(MemoryContext context)

void GenerationStats(MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr)

void GenerationDelete(MemoryContext context)

void * GenerationAlloc(MemoryContext context, Size size, int flags)

volatile sig_atomic_t LogMemoryContextPending

volatile sig_atomic_t InterruptPending

volatile uint32 CritSectionCount

Assert(PointerIsAligned(start, uint64))

int pg_mbcliplen(const char *mbstr, int len, int limit)

static void MemoryContextStatsInternal(MemoryContext context, int level, int max_level, int max_children, MemoryContextCounters *totals, bool print_to_stderr)

void MemoryContextUnregisterResetCallback(MemoryContext context, MemoryContextCallback *cb)

void * repalloc0(void *pointer, Size oldsize, Size size)

static void MemoryContextCallResetCallbacks(MemoryContext context)

char * MemoryContextStrdup(MemoryContext context, const char *string)

void * MemoryContextAlloc(MemoryContext context, Size size)

MemoryContext MessageContext

bool MemoryContextIsEmpty(MemoryContext context)

void MemoryContextMemConsumed(MemoryContext context, MemoryContextCounters *consumed)

void MemoryContextReset(MemoryContext context)

void MemoryContextCreate(MemoryContext node, NodeTag tag, MemoryContextMethodID method_id, MemoryContext parent, const char *name)

void * MemoryContextAllocZero(MemoryContext context, Size size)

MemoryContext TopTransactionContext

char * pstrdup(const char *in)

void HandleLogMemoryContextInterrupt(void)

void MemoryContextRegisterResetCallback(MemoryContext context, MemoryContextCallback *cb)

static MemoryContextMethodID GetMemoryChunkMethodID(const void *pointer)

void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)

static void * BogusRealloc(void *pointer, Size size, int flags)

void * repalloc(void *pointer, Size size)

void pfree(void *pointer)

Size GetMemoryChunkSpace(void *pointer)

void * palloc0(Size size)

static Size BogusGetChunkSpace(void *pointer)

void * MemoryContextAllocAligned(MemoryContext context, Size size, Size alignto, int flags)

void MemoryContextDeleteChildren(MemoryContext context)

MemoryContext TopMemoryContext

char * pchomp(const char *in)

#define AssertNotInCriticalSection(context)

MemoryContext CurTransactionContext

MemoryContext CurrentMemoryContext

static MemoryContext MemoryContextTraverseNext(MemoryContext curr, MemoryContext top)

MemoryContext GetMemoryChunkContext(void *pointer)

void * MemoryContextAllocExtended(MemoryContext context, Size size, int flags)

void MemoryContextStatsDetail(MemoryContext context, int max_level, int max_children, bool print_to_stderr)

Size MemoryContextMemAllocated(MemoryContext context, bool recurse)

char * pnstrdup(const char *in, Size len)

void MemoryContextStats(MemoryContext context)

void MemoryContextInit(void)

static void BogusFree(void *pointer)

void * palloc_extended(Size size, int flags)

MemoryContext PostmasterContext

void * MemoryContextAllocationFailure(MemoryContext context, Size size, int flags)

static const MemoryContextMethods mcxt_methods[]

void * repalloc_extended(void *pointer, Size size, int flags)

MemoryContext MemoryContextGetParent(MemoryContext context)

void ProcessLogMemoryContextInterrupt(void)

MemoryContext ErrorContext

static MemoryContext BogusGetChunkContext(void *pointer)

MemoryContext CacheMemoryContext

void MemoryContextSizeFailure(MemoryContext context, Size size, int flags)

void * MemoryContextAllocHuge(MemoryContext context, Size size)

void MemoryContextDelete(MemoryContext context)

void MemoryContextAllowInCriticalSection(MemoryContext context, bool allow)

static void MemoryContextDeleteOnly(MemoryContext context)

void MemoryContextResetChildren(MemoryContext context)

static void MemoryContextStatsPrint(MemoryContext context, void *passthru, const char *stats_string, bool print_to_stderr)

void * repalloc_huge(void *pointer, Size size)

void MemoryContextSetIdentifier(MemoryContext context, const char *id)

void MemoryContextResetOnly(MemoryContext context)

static uint64 GetMemoryChunkHeader(const void *pointer)

MemoryContext PortalContext

void * palloc_aligned(Size size, Size alignto, int flags)

#define MCXT_METHOD(pointer, method)

#define VALGRIND_MAKE_MEM_DEFINED(addr, size)

#define VALGRIND_MEMPOOL_CHANGE(context, optr, nptr, size)

#define VALGRIND_MEMPOOL_ALLOC(context, addr, size)

#define VALGRIND_MEMPOOL_FREE(context, addr)

#define VALGRIND_MAKE_MEM_NOACCESS(addr, size)

#define MemoryContextIsValid(context)

#define AllocSetContextCreate

#define ALLOCSET_DEFAULT_SIZES

#define AllocHugeSizeIsValid(size)

#define AllocSizeIsValid(size)

#define MEMORY_CONTEXT_METHODID_MASK

#define PallocAlignedExtraBytes(alignto)

@ MCTX_15_RESERVED_WIPEDMEM_ID

@ MCTX_1_RESERVED_GLIBC_ID

@ MCTX_0_RESERVED_UNUSEDMEM_ID

@ MCTX_2_RESERVED_GLIBC_ID

@ MCTX_ALIGNED_REDIRECT_ID

struct MemoryChunk MemoryChunk

#define PointerGetMemoryChunk(p)

static void MemoryChunkSetHdrMask(MemoryChunk *chunk, void *block, Size value, MemoryContextMethodID methodid)

size_t strnlen(const char *str, size_t maxlen)

void * SlabAlloc(MemoryContext context, Size size, int flags)

void SlabFree(void *pointer)

void SlabReset(MemoryContext context)

Size SlabGetChunkSpace(void *pointer)

bool SlabIsEmpty(MemoryContext context)

MemoryContext SlabGetChunkContext(void *pointer)

void * SlabRealloc(void *pointer, Size size, int flags)

void SlabStats(MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr)

void SlabDelete(MemoryContext context)

bool stack_is_too_deep(void)

struct MemoryContextCallback * next

MemoryContextCallbackFunction func

MemoryContextCallback * reset_cbs

const MemoryContextMethods * methods

void(* delete_context)(MemoryContext context)

void(* stats)(MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr)

bool(* is_empty)(MemoryContext context)

void *(* alloc)(MemoryContext context, Size size, int flags)

void(* reset)(MemoryContext context)