1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Add the -DSQLITE_MAX_MEMORY=N compile-time option. The default is no limit.

FossilOrigin-Name: eabd4ef498a0f0d97d65e321c4d06ab90523ed61
This commit is contained in:
drh
2017-03-10 16:22:40 +00:00
3 changed files with 14 additions and 7 deletions

View File

@@ -230,6 +230,12 @@ static void mallocWithAlarm(int n, void **pp){
** following xRoundup() call. */
nFull = sqlite3GlobalConfig.m.xRoundup(n);
#ifdef SQLITE_MAX_MEMORY
if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){
return 0;
}
#endif
sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
if( mem0.alarmThreshold>0 ){
sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);