Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Re-enable memory statistics and backtraces. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
75b8ccc0a84cc687d1ab45756f9fe18c |
User & Date: | dan 2013-05-21 18:19:02.713 |
Context
2013-05-21
| ||
20:08 | Remove sqlite4_mem_methods from sqlite.h.in. Other modifications so that src4.test works again. check-in: 7091e990cd user: dan tags: trunk | |
18:19 | Re-enable memory statistics and backtraces. check-in: 75b8ccc0a8 user: dan tags: trunk | |
2013-05-18
| ||
19:42 | Use the default sqlite4_mm object for malloc() and free(). check-in: e3280f4585 user: dan tags: trunk | |
Changes
Changes to src/env.c.
︙ | |||
38 39 40 41 42 43 44 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - - + + | struct sqlite4_env sqlite4DefaultEnv = { sizeof(sqlite4_env), /* nByte */ 1, /* iVersion */ SQLITE4_DEFAULT_MEMSTATUS, /* bMemstat */ 1, /* bCoreMutex */ SQLITE4_THREADSAFE==1, /* bFullMutex */ 0x7ffffffe, /* mxStrlen */ |
︙ | |||
300 301 302 303 304 305 306 | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | - + - + - + - - - + - - + - + - - - - + - | *va_arg(ap, sqlite4_mutex_methods*) = pEnv->mutex; break; } #endif /* |
︙ |
Changes to src/mem.c.
︙ | |||
281 282 283 284 285 286 287 288 289 290 291 292 293 294 | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | pOvfl->xMemberOfA = pA->pMethods->xMember; pOvfl->pA = pA; pOvfl->pB = pB; } return &pOvfl->base; } /************************************************************************* ** The SQLITE4_MM_STATS memory allocator. */ /* ** Number of available statistics. Statistics are assigned ids starting at ** one, not zero. */ #define MM_STATS_NSTAT 8 struct mmStats { sqlite4_mm base; /* Base class. Must be first. */ sqlite4_mm *p; /* Underlying allocator object */ sqlite4_mutex *mutex; /* Mutex protecting aStat[] (or NULL) */ i64 nOut; /* Number of bytes outstanding */ i64 nOutHw; /* Highwater mark of nOut */ i64 nUnit; /* Number of allocations outstanding */ i64 nUnitHw; /* Highwater mark of nUnit */ i64 nMaxRequest; /* Largest request seen so far */ i64 nFault; /* Number of malloc or realloc failures */ }; static void updateStatsMalloc( struct mmStats *pStats, void *pNew, sqlite4_size_t iSz ){ /* Statistic SQLITE4_MMSTAT_SIZE records the largest allocation request ** that has been made so far. So if iSz is larger than the current value, ** set MMSTAT_SIZE to iSz now. This statistic is updated regardless of ** whether or not the allocation succeeded. */ if( iSz>pStats->nMaxRequest ){ pStats->nMaxRequest = iSz; } /* If the allocation succeeded, increase the number of allocations and ** bytes outstanding accordingly. Also update the highwater marks if ** required. If the allocation failed, increment the fault count. */ if( pNew ){ pStats->nOut += sqlite4_mm_msize(pStats->p, pNew); pStats->nUnit += 1; if( pStats->nOut>pStats->nOutHw ) pStats->nOutHw = pStats->nOut; if( pStats->nUnit>pStats->nUnitHw ) pStats->nUnitHw = pStats->nUnit; }else{ pStats->nFault++; } } static void *mmStatsMalloc(sqlite4_mm *pMM, sqlite4_size_t iSz){ struct mmStats *pStats = (struct mmStats*)pMM; void *pRet; pRet = sqlite4_mm_malloc(pStats->p, iSz); sqlite4_mutex_enter(pStats->mutex); updateStatsMalloc(pStats, pRet, iSz); sqlite4_mutex_leave(pStats->mutex); return pRet; } static void mmStatsFree(sqlite4_mm *pMM, void *pOld){ struct mmStats *pStats = (struct mmStats*)pMM; sqlite4_mutex_enter(pStats->mutex); if( pOld ){ sqlite4_size_t nByte = sqlite4_mm_msize(pMM, pOld); pStats->nOut -= nByte; pStats->nUnit -= 1; } sqlite4_mutex_leave(pStats->mutex); sqlite4_mm_free(pStats->p, pOld); } static void *mmStatsRealloc(sqlite4_mm *pMM, void *pOld, sqlite4_size_t iSz){ struct mmStats *pStats = (struct mmStats*)pMM; sqlite4_size_t nOrig = (pOld ? sqlite4_mm_msize(pStats->p, pOld) : 0); void *pRet; pRet = sqlite4_mm_realloc(pStats->p, pOld, iSz); sqlite4_mutex_enter(pStats->mutex); if( pRet ){ pStats->nOut -= nOrig; if( pOld ) pStats->nUnit--; } updateStatsMalloc(pStats, pRet, iSz); sqlite4_mutex_leave(pStats->mutex); return pRet; } static sqlite4_size_t mmStatsMsize(sqlite4_mm *pMM, void *pOld){ struct mmStats *pStats = (struct mmStats*)pMM; return sqlite4_mm_msize(pStats->p, pOld); } static int mmStatsMember(sqlite4_mm *pMM, const void *pOld){ struct mmStats *pStats = (struct mmStats*)pMM; return sqlite4_mm_member(pStats->p, pOld); } static sqlite4_int64 mmStatsStat( sqlite4_mm *pMM, unsigned int eType, unsigned int flags ){ struct mmStats *pStats = (struct mmStats*)pMM; i64 iRet = 0; sqlite4_mutex_enter(pStats->mutex); switch( eType ){ case SQLITE4_MMSTAT_OUT: { iRet = pStats->nOut; break; } case SQLITE4_MMSTAT_OUT_HW: { iRet = pStats->nOutHw; if( flags & SQLITE4_MMSTAT_RESET ) pStats->nOutHw = pStats->nOut; break; } case SQLITE4_MMSTAT_UNITS: { iRet = pStats->nUnit; break; } case SQLITE4_MMSTAT_UNITS_HW: { iRet = pStats->nUnitHw; if( flags & SQLITE4_MMSTAT_RESET ) pStats->nUnitHw = pStats->nUnit; break; } case SQLITE4_MMSTAT_SIZE: { iRet = pStats->nMaxRequest; if( flags & SQLITE4_MMSTAT_RESET ) pStats->nMaxRequest = 0; break; } case SQLITE4_MMSTAT_MEMFAULT: case SQLITE4_MMSTAT_FAULT: { iRet = pStats->nFault; if( flags & SQLITE4_MMSTAT_RESET ) pStats->nFault = 0; break; } } sqlite4_mutex_leave(pStats->mutex); return iRet; } /* ** Destroy the allocator object passed as the first argument. */ static void mmStatsFinal(sqlite4_mm *pMM){ struct mmStats *pStats = (struct mmStats*)pMM; sqlite4_mm *p = pStats->p; sqlite4_mm_free(p, pStats); sqlite4_mm_destroy(p); } static const sqlite4_mm_methods mmStatsMethods = { /* iVersion */ 1, /* xMalloc */ mmStatsMalloc, /* xRealloc */ mmStatsRealloc, /* xFree */ mmStatsFree, /* xMsize */ mmStatsMsize, /* xMember */ mmStatsMember, /* xBenign */ 0, /* xStat */ mmStatsStat, /* xCtrl */ 0, /* xFinal */ mmStatsFinal }; /* ** Allocate a new stats allocator. */ static sqlite4_mm *mmStatsNew(sqlite4_mm *p){ struct mmStats *pNew; pNew = (struct mmStats *)sqlite4_mm_malloc(p, sizeof(*pNew)); if( pNew ){ memset(pNew, 0, sizeof(*pNew)); pNew->p = p; pNew->base.pMethods = &mmStatsMethods; } return (sqlite4_mm *)pNew; } /************************************************************************* ** The SQLITE4_MM_ONESIZE memory allocator. ** ** All memory allocations are rounded up to a single size, "sz". A request ** for an allocation larger than sz bytes fails. All allocations come out ** of a single initial buffer with "cnt" chunks of "sz" bytes each. |
︙ | |||
350 351 352 353 354 355 356 | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | - + + + + + | struct mmOnesz *pOnesz = (struct mmOnesz*)pMM; return pOld ? pOnesz->sz : 0; } static int mmOneszMember(sqlite4_mm *pMM, const void *pOld){ struct mmOnesz *pOnesz = (struct mmOnesz*)pMM; return pOld && pOld>=pOnesz->pSpace && pOld<=pOnesz->pLast; } |
︙ | |||
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | + + + + + | } case SQLITE4_MM_ONESIZE: { void *pSpace = va_arg(ap, void*); int sz = va_arg(ap, int); int cnt = va_arg(ap, int); pMM = mmOneszNew(pSpace, sz, cnt); break; } case SQLITE4_MM_STATS: { sqlite4_mm *p = va_arg(ap, sqlite4_mm*); pMM = mmStatsNew(p); break; } default: { pMM = 0; break; } } va_end(ap); return pMM; } |
Changes to src/prepare.c.
︙ | |||
592 593 594 595 596 597 598 599 600 601 602 603 604 605 | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | + + + | Vdbe *pOld, /* VM being reprepared */ sqlite4_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ int *pnUsed /* OUT: Bytes read from zSql */ ){ int rc; assert( ppStmt!=0 ); *ppStmt = 0; if( pnUsed ){ *pnUsed = 0; } if( !sqlite4SafetyCheckOk(db) ){ return SQLITE4_MISUSE_BKPT; } sqlite4_mutex_enter(db->mutex); rc = sqlite4Prepare(db, zSql, nBytes, pOld, ppStmt, pnUsed); if( rc==SQLITE4_SCHEMA ){ sqlite4_finalize(*ppStmt); |
︙ |
Changes to src/sqlite.h.in.
︙ | |||
166 167 168 169 170 171 172 | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | - + | ** ** If pOld is not a valid memory allocation or is a memory allocation that ** has previously been freed, then the result of this routine is undefined. */ int sqlite4_mm_member(sqlite4_mm *pMM, const void *pOld); /* |
︙ | |||
193 194 195 196 197 198 199 | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | - + | ** a memory allocator is unavailable, then -1 is returned. */ sqlite4_int64 sqlite4_mm_stat(sqlite4_mm *pMM, int eType, unsigned flags); /* ** Send a control message into a memory allocator. */ |
︙ | |||
245 246 247 248 249 250 251 | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | - - + + | */ #define SQLITE4_ENVCONFIG_INIT 1 /* size, template */ #define SQLITE4_ENVCONFIG_SINGLETHREAD 2 /* */ #define SQLITE4_ENVCONFIG_MULTITHREAD 3 /* */ #define SQLITE4_ENVCONFIG_SERIALIZED 4 /* */ #define SQLITE4_ENVCONFIG_MUTEX 5 /* sqlite4_mutex_methods* */ #define SQLITE4_ENVCONFIG_GETMUTEX 6 /* sqlite4_mutex_methods* */ |
︙ |
Changes to src/tclsqlite.c.
︙ | |||
2875 2876 2877 2878 2879 2880 2881 | 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 | - - - | extern int Sqlitetestrtree_Init(Tcl_Interp*); extern int Sqlitequota_Init(Tcl_Interp*); extern int SqliteSuperlock_Init(Tcl_Interp*); extern int SqlitetestSyscall_Init(Tcl_Interp*); extern int Sqliteteststorage_Init(Tcl_Interp*); extern int Sqliteteststorage2_Init(Tcl_Interp*); extern int SqlitetestLsm_Init(Tcl_Interp*); |
︙ |
Changes to test/testInt.h.
︙ | |||
21 22 23 24 25 26 27 28 29 | 21 22 23 24 25 26 27 28 29 30 31 32 | + + + | /* test_main.c */ void sqlite4TestInit(Tcl_Interp*); void *sqlite4TestTextToPtr(const char *z); int sqlite4TestDbHandle(Tcl_Interp *, Tcl_Obj *, sqlite4 **); int sqlite4TestSetResult(Tcl_Interp *interp, int rc); sqlite4_mm *test_mm_debug(sqlite4_mm *p); void test_mm_debug_report(sqlite4_mm *p, FILE *pFile); #endif |
Changes to test/test_malloc.c.
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | + + | */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #include <assert.h> #include "testInt.h" /* ** This structure is used to encapsulate the global state variables used ** by malloc() fault simulation. */ static struct MemFault { int iCountdown; /* Number of pending successes before a failure */ int nRepeat; /* Number of times to repeat the failure */ |
︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | + | } /* ** Add or remove the fault-simulation layer using sqlite4_env_config(). If ** the argument is non-zero, the */ static int faultsimInstall(int install){ #if 0 static struct sqlite4_mem_methods m = { faultsimMalloc, /* xMalloc */ faultsimFree, /* xFree */ faultsimRealloc, /* xRealloc */ faultsimSize, /* xSize */ faultsimInit, /* xInit */ faultsimShutdown, /* xShutdown */ |
︙ | |||
223 224 225 226 227 228 229 230 231 232 233 234 235 236 | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | + | rc = sqlite4_env_config(0, SQLITE4_ENVCONFIG_MALLOC, &memfault.m); } if( rc==SQLITE4_OK ){ memfault.isInstalled = 1; } return rc; #endif } #ifdef SQLITE4_TEST /* ** This function is implemented in test1.c. Returns a pointer to a static ** buffer containing the symbolic SQLite error code that corresponds to |
︙ | |||
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 | 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 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #ifdef SQLITE4_ENABLE_MEMSYS3 const sqlite4_mem_methods *sqlite4MemGetMemsys3(void); rc = sqlite4_env_config(0, SQLITE4_ENVCONFIG_MALLOC, sqlite4MemGetMemsys3()); #endif Tcl_SetResult(interp, (char *)sqlite4TestErrorName(rc), TCL_VOLATILE); return TCL_OK; } static sqlite4_mm *pMMDebug = 0; /* ** tclcmd: test_mm_install ?debug? ?backtrace? ?stats? */ static int test_mm_install( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ const char *azOpt[] = { "debug", /* 0 */ "backtrace", /* 1 */ "stats", /* 2 */ 0 }; sqlite4_mm *pMM = 0; int i; int bDebug = 0; int bBacktrace = 0; int bStats = 0; for(i=1; i<objc; i++){ int iOpt = 0; int rc = Tcl_GetIndexFromObj(interp, objv[i], azOpt, "option", 0, &iOpt); if( rc!=TCL_OK ) return rc; switch( iOpt ){ case 0: bDebug = 1; break; case 1: bBacktrace = 1; break; case 2: bStats = 1; break; } } sqlite4_env_config(0, SQLITE4_ENVCONFIG_GETMM, &pMM); if( pMM==sqlite4_mm_default() ){ if( bDebug ){ pMMDebug = pMM = test_mm_debug(pMM); } if( bStats ){ pMM = sqlite4_mm_new(SQLITE4_MM_STATS, pMM); } sqlite4_env_config(0, SQLITE4_ENVCONFIG_SETMM, pMM); } return TCL_OK; } /* ** tclcmd: test_mm_stat ?-reset? STATISTIC */ static int test_mm_stat( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int flags = 0; sqlite4_mm *pMM = 0; sqlite4_int64 iRet = -1; Tcl_Obj *pOpt; if( objc!=2 && objc!=3 ){ Tcl_WrongNumArgs(interp, 1, objv, "?-reset? STATISTIC"); return TCL_ERROR; } if( objc==3 ){ const char *azOpt[] = { "-reset", 0 }; int iOpt = 0; int rc = Tcl_GetIndexFromObj(interp, objv[1], azOpt, "option", 0, &iOpt); if( rc!=TCL_OK ) return rc; flags = SQLITE4_MMSTAT_RESET; } pOpt = objv[objc-1]; sqlite4_env_config(0, SQLITE4_ENVCONFIG_GETMM, &pMM); if( pMM ){ const char *azOpt[] = { "out", "out_hw", "units", "units_hw", "size", "szfault", "memfault", "fault", 0 }; int iOpt = 0; int rc = Tcl_GetIndexFromObj(interp, pOpt, azOpt, "option", 0, &iOpt); if( rc!=TCL_OK ) return rc; iRet = sqlite4_mm_stat(pMM, iOpt+1, flags); } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(iRet)); return TCL_OK; } /* ** tclcmd: test_mm_report FILENAME */ static int test_mm_report( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ FILE *pFile; const char *zFile; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "FILE"); return TCL_ERROR; } if( pMMDebug ){ zFile = Tcl_GetString(objv[1]); pFile = fopen(zFile, "w"); if( pFile==0 ){ Tcl_AppendResult(interp, "Failed to open file: ", zFile, 0); return TCL_ERROR; } test_mm_debug_report(pMMDebug, pFile); } return TCL_OK; } /* ** Register commands with the TCL interpreter. */ int Sqlitetest_malloc_Init(Tcl_Interp *interp){ static struct { char *zName; |
︙ | |||
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | + + + + | { "sqlite4_db_status", test_db_status ,0 }, { "install_malloc_faultsim", test_install_malloc_faultsim ,0 }, { "sqlite4_env_config_memstatus", test_config_memstatus ,0 }, { "sqlite4_envconfig_lookaside", test_envconfig_lookaside ,0 }, { "sqlite4_config_error", test_config_error ,0 }, { "sqlite4_db_config_lookaside", test_db_config_lookaside ,0 }, { "sqlite4_install_memsys3", test_install_memsys3 ,0 }, { "test_mm_install", test_mm_install ,0 }, { "test_mm_stat", test_mm_stat ,0 }, { "test_mm_report", test_mm_report ,0 }, }; int i; for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ ClientData c = (ClientData)SQLITE4_INT_TO_PTR(aObjCmd[i].clientData); Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, c, 0); } return TCL_OK; } #endif |
Changes to test/test_mem.c.
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | - + + | ** May you share freely, never taking more than you give. ** */ #include <stdio.h> #include <assert.h> #include <string.h> |
︙ | |||
32 33 34 35 36 37 38 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | - + + + + - - - - + + + + + + - + - - - | # define backtrace(A,B) 1 # define backtrace_symbols_fd(A,B,C) #endif typedef struct TmBlockHdr TmBlockHdr; typedef struct TmAgg TmAgg; |
︙ | |||
74 75 76 77 78 79 80 | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | + + + + - + - + - - - - - + + + + + + + + + - + - + - + - - + + - + - + - + - + - - + + - + + + + - + + - + - - + + + - - + + + - + - + + + + - + - + - - + - - - + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + - - - - - - + + + - - - - + - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - + - - - - + - - - - - + + - - - - - - - - - - - + - - - - - - - + + - - - - - + - - - - - - - - - - - - - - - - - - - - - + - - - - - + - - - - + - - - - - - - + - - + - - - - - - - + + - - - - + + + - - - + - - - + + - - - - + - - + - - - - - - - - + - - - - + - - - - - - - + + + + + - - - - - - + - - - - - - - + + - - - - - + - - - - - - - - + - - - - - - - - - - - - - + - - - + - - - - - - - - + - - - - - - | #define FOREGUARD 0x80F5E153 #define REARGUARD 0xE4676B53 static const u32 rearguard = REARGUARD; #define ROUND8(x) (((x)+7)&~7) #define BLOCK_HDR_SIZE (ROUND8( sizeof(TmBlockHdr) )) /* ** Given a user data pointer, return a pointer to the associated ** TmBlockHdr structure. */ |
Changes to test/tester.tcl.
︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | + + | # 64KB into the database file instead of the one 1GB in. This means # the code that handles that special case can be tested without creating # very large database files. # set tcl_precision 15 #sqlite4_test_control_pending_byte 0x0010000 test_mm_install stats debug # If the pager codec is available, create a wrapper for the [sqlite4] # command that appends "-key {xyzzy}" to the command line. i.e. this: # # sqlite4 db test.db # # becomes |
︙ | |||
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | + + + + + + + + + + + - - - + + - + - - - - - + + + + + + + + - - - + + + + | puts "in your TCL build." puts "******************************************************************" } if {$::cmdlinearg(binarylog)} { vfslog finalize binarylog } kvwrap uninstall set nOut [test_mm_stat out] set nUnit [test_mm_stat units] if {$nOut!=0 || $nUnit!=0} { puts "Unfreed memory: $nOut bytes in $nUnit allocations" } else { puts "All memory allocations freed - no leaks" } show_memstats test_mm_report malloc.txt # if {[lindex [sqlite4_env_status SQLITE4_ENVSTATUS_MALLOC_COUNT 0] 1]>0 || # [sqlite4_memory_used]>0} { # puts "Unfreed memory: [sqlite4_memory_used] bytes in\ # [lindex [sqlite4_env_status SQLITE4_ENVSTATUS_MALLOC_COUNT 0] 1] allocations" # incr nErr # ifcapable memdebug||mem5||(mem3&&debug) { # puts "Writing unfreed memory log to \"./memleak.txt\"" # sqlite4_memdebug_dump ./memleak.txt # } # } else { # puts "All memory allocations freed - no leaks" # ifcapable memdebug||mem5 { # sqlite4_memdebug_dump ./memusage.txt # } # } |
︙ |