Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The sqlite3_memory_alarm() interface has been deprecated and undocumented for almost 8 years (since version 3.5.3). Change it into a no-op. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5d3f5df4da9f40d5897b5c23b2ea9333 |
User & Date: | drh 2015-09-02 14:56:56.653 |
References
2015-09-10
| ||
01:22 | No-op the sqlite3_memory_alarm() interface in a different way, that does not break legacy memory behavior. This is a re-do of check-in [5d3f5df4da9f40d5]. (check-in: 8250e2a487 user: drh tags: trunk) | |
Context
2015-09-02
| ||
15:37 | Use sqlite3XPrintf() instead of sqlite3StrAccumAppend() in a few places for better performance and a smaller footprint. (check-in: 82355e4108 user: drh tags: trunk) | |
14:56 | The sqlite3_memory_alarm() interface has been deprecated and undocumented for almost 8 years (since version 3.5.3). Change it into a no-op. (check-in: 5d3f5df4da user: drh tags: trunk) | |
2015-09-01
| ||
23:51 | Very minor optimizations in the unix VFS. (check-in: 6db3ff45bc user: drh tags: trunk) | |
Changes
Changes to src/malloc.c.
︙ | ︙ | |||
41 42 43 44 45 46 47 | } ScratchFreeslot; /* ** State information local to the memory allocation subsystem. */ static SQLITE_WSD struct Mem0Global { sqlite3_mutex *mutex; /* Mutex to serialize access */ | < < < < < < < | < < | | < < < < | < < < | > > | < | | | < | > > > > > | > > > > > > > > > > | | < | | < > > | | > > | < > | < < < > | | | > | < | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 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 | } ScratchFreeslot; /* ** State information local to the memory allocation subsystem. */ static SQLITE_WSD struct Mem0Global { sqlite3_mutex *mutex; /* Mutex to serialize access */ sqlite3_int64 alarmThreshold; /* The soft heap limit */ /* ** Pointers to the end of sqlite3GlobalConfig.pScratch memory ** (so that a range test can be used to determine if an allocation ** being freed came from pScratch) and a pointer to the list of ** unused scratch allocations. */ void *pScratchEnd; ScratchFreeslot *pScratchFree; u32 nScratchFree; /* ** True if heap is nearly "full" where "full" is defined by the ** sqlite3_soft_heap_limit() setting. */ int nearlyFull; } mem0 = { 0, 0, 0, 0, 0, 0 }; #define mem0 GLOBAL(struct Mem0Global, mem0) /* ** Return the memory allocator mutex. sqlite3_status() needs it. */ sqlite3_mutex *sqlite3MallocMutex(void){ return mem0.mutex; } /* ** Return the amount of memory currently in use. */ static sqlite3_int64 memInUse(void){ assert( sqlite3_mutex_held(mem0.mutex) ); return sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); } /* ** Called when the soft heap limit is exceeded for an allocation ** of nBytes. */ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT static void sqlite3HeapLimitExceeded(int nByte){ sqlite3_int64 excess = memInUse() + nByte - mem0.alarmThreshold; sqlite3_mutex_leave(mem0.mutex); sqlite3_release_memory((int)(excess & 0x7fffffff)); sqlite3_mutex_enter(mem0.mutex); } #else # define sqlite3HeapLimitExceeded(X) /* no-op */ #endif /* ** Check to see if increasing the total memory usage by nNew bytes ** will exceed the soft heap limit. ** ** If the soft heap limit is exceeded, set the mem0.nearlyFull flag ** and invoke sqlite3HeapLimitExceeded() to try to free up some ** memory. */ static void sqlite3CheckSoftHeapLimit(int nNew){ assert( sqlite3_mutex_held(mem0.mutex) ); if( mem0.alarmThreshold>0 ){ if( mem0.alarmThreshold-nNew >= memInUse() ){ mem0.nearlyFull = 1; sqlite3HeapLimitExceeded(nNew); }else{ mem0.nearlyFull = 0; } } } #ifndef SQLITE_OMIT_DEPRECATED /* ** Deprecated external interface. First deprecated 2007-11-05. Changed ** into a no-op on 2015-09-02. */ int sqlite3_memory_alarm( void(*xCallback)(void *pArg, sqlite3_int64 used,int N), void *pArg, sqlite3_int64 iThreshold ){ return SQLITE_OK; } #endif /* ** Set the soft heap-size limit for the library. Passing a zero or ** negative value indicates no limit. */ sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){ sqlite3_int64 priorLimit; #ifndef SQLITE_OMIT_AUTOINIT int rc = sqlite3_initialize(); if( rc ) return -1; #endif sqlite3_mutex_enter(mem0.mutex); priorLimit = mem0.alarmThreshold; if( n>0 ){ mem0.alarmThreshold = n; sqlite3CheckSoftHeapLimit(0); }else if( n==0 ){ mem0.alarmThreshold = 0; mem0.nearlyFull = 0; } sqlite3_mutex_leave(mem0.mutex); return priorLimit; } void sqlite3_soft_heap_limit(int n){ if( n<0 ) n = 0; sqlite3_soft_heap_limit64(n); } |
︙ | ︙ | |||
237 238 239 240 241 242 243 | */ sqlite3_int64 sqlite3_memory_highwater(int resetFlag){ sqlite3_int64 res, mx; sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, resetFlag); return mx; } | < < < < < < < < < < < < < < < < < < < < < < < | < < < < | | | 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 | */ sqlite3_int64 sqlite3_memory_highwater(int resetFlag){ sqlite3_int64 res, mx; sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, resetFlag); return mx; } /* ** Do a memory allocation with statistics and alarms. Assume the ** lock is already held. */ static int mallocWithAlarm(int n, void **pp){ int nFull; void *p; assert( sqlite3_mutex_held(mem0.mutex) ); nFull = sqlite3GlobalConfig.m.xRoundup(n); sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); sqlite3CheckSoftHeapLimit(nFull); p = sqlite3GlobalConfig.m.xMalloc(nFull); #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT if( p==0 && mem0.alarmThreshold ){ sqlite3HeapLimitExceeded(nFull); p = sqlite3GlobalConfig.m.xMalloc(nFull); } #endif if( p ){ nFull = sqlite3MallocSize(p); sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull); sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1); |
︙ | ︙ | |||
561 562 563 564 565 566 567 | nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes); if( nOld==nNew ){ pNew = pOld; }else if( sqlite3GlobalConfig.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes); nDiff = nNew - nOld; | < < | < > | | > | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes); if( nOld==nNew ){ pNew = pOld; }else if( sqlite3GlobalConfig.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes); nDiff = nNew - nOld; sqlite3CheckSoftHeapLimit(nDiff); pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT if( pNew==0 && mem0.alarmThreshold ){ sqlite3HeapLimitExceeded((int)nBytes); pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); } #endif if( pNew ){ nNew = sqlite3MallocSize(pNew); sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld); } sqlite3_mutex_leave(mem0.mutex); }else{ pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); |
︙ | ︙ |