Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the new memory allocator to the amalgamation. Improvements to out-of-memory handling. (CVS 4498) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b58c2b37a5deb19ce0ef786299890167 |
User & Date: | drh 2007-10-20 16:36:31.000 |
Context
2007-10-20
| ||
20:58 | Use the 2-argument version of substr() in the SQL contained in the VACUUM and ALTER TABLE commands. Ticket #2737. (CVS 4499) (check-in: 82b08a3dc2 user: drh tags: trunk) | |
16:36 | Add the new memory allocator to the amalgamation. Improvements to out-of-memory handling. (CVS 4498) (check-in: b58c2b37a5 user: drh tags: trunk) | |
16:11 | Bug fix in the realloc algorithm of the static memory allocator. (CVS 4497) (check-in: 50db16be50 user: drh tags: trunk) | |
Changes
Changes to src/malloc.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Memory allocation functions used throughout sqlite. ** ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Memory allocation functions used throughout sqlite. ** ** ** $Id: malloc.c,v 1.14 2007/10/20 16:36:31 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> #include <ctype.h> /* ** This routine runs when the memory allocator sees that the |
︙ | ︙ | |||
233 234 235 236 237 238 239 | if( db && db->mallocFailed ){ sqlite3Error(db, SQLITE_NOMEM, 0); db->mallocFailed = 0; rc = SQLITE_NOMEM; } return rc & (db ? db->errMask : 0xff); } | < | 233 234 235 236 237 238 239 | if( db && db->mallocFailed ){ sqlite3Error(db, SQLITE_NOMEM, 0); db->mallocFailed = 0; rc = SQLITE_NOMEM; } return rc & (db ? db->errMask : 0xff); } |
Changes to src/mem3.c.
︙ | ︙ | |||
16 17 18 19 20 21 22 | ** use of malloc(). All dynamically allocatable memory is ** contained in a static array, mem.aPool[]. The size of this ** fixed memory pool is SQLITE_MEMORY_SIZE bytes. ** ** This version of the memory allocation subsystem is used if ** and only if SQLITE_MEMORY_SIZE is defined. ** | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ** use of malloc(). All dynamically allocatable memory is ** contained in a static array, mem.aPool[]. The size of this ** fixed memory pool is SQLITE_MEMORY_SIZE bytes. ** ** This version of the memory allocation subsystem is used if ** and only if SQLITE_MEMORY_SIZE is defined. ** ** $Id: mem3.c,v 1.5 2007/10/20 16:36:31 drh Exp $ */ /* ** This version of the memory allocator is used only when ** SQLITE_MEMORY_SIZE is defined. */ #if defined(SQLITE_MEMORY_SIZE) |
︙ | ︙ | |||
368 369 370 371 372 373 374 375 376 377 378 379 380 381 | /* ** Return a block of memory of at least nBytes in size. ** Return NULL if unable. */ static void *memsys3Malloc(int nByte){ int i; int nBlock; assert( sizeof(Mem3Block)==8 ); if( nByte<=0 ){ nBlock = 2; }else{ nBlock = (nByte + 15)/8; } | > | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | /* ** Return a block of memory of at least nBytes in size. ** Return NULL if unable. */ static void *memsys3Malloc(int nByte){ int i; int nBlock; int toFree; assert( sizeof(Mem3Block)==8 ); if( nByte<=0 ){ nBlock = 2; }else{ nBlock = (nByte + 15)/8; } |
︙ | ︙ | |||
414 415 416 417 418 419 420 | /* STEP 3: ** Loop through the entire memory pool. Coalesce adjacent free ** chunks. Recompute the master chunk as the largest free chunk. ** Then try again to satisfy the allocation by carving a piece off ** of the end of the master chunk. This step happens very ** rarely (we hope!) */ | > | | | | | | | | | | | | | | | | > | 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 | /* STEP 3: ** Loop through the entire memory pool. Coalesce adjacent free ** chunks. Recompute the master chunk as the largest free chunk. ** Then try again to satisfy the allocation by carving a piece off ** of the end of the master chunk. This step happens very ** rarely (we hope!) */ for(toFree=nBlock*16; toFree<SQLITE_MEMORY_SIZE*2; toFree *= 2){ memsys3OutOfMemory(toFree); if( mem.iMaster ){ memsys3Link(mem.iMaster); mem.iMaster = 0; mem.szMaster = 0; } for(i=0; i<N_HASH; i++){ memsys3Merge(&mem.aiHash[i]); } for(i=0; i<MX_SMALL-1; i++){ memsys3Merge(&mem.aiSmall[i]); } if( mem.szMaster ){ memsys3Unlink(mem.iMaster); if( mem.szMaster>=nBlock ){ return memsys3FromMaster(nBlock); } } } /* If none of the above worked, then we fail. */ return 0; } |
︙ | ︙ |
Changes to tool/mksqlite3c.tcl.
︙ | ︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | sqlite3.h date.c os.c mem1.c mem2.c mutex.c mutex_os2.c mutex_unix.c mutex_w32.c malloc.c printf.c random.c | > | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | sqlite3.h date.c os.c mem1.c mem2.c mem3.c mutex.c mutex_os2.c mutex_unix.c mutex_w32.c malloc.c printf.c random.c |
︙ | ︙ |