aboutsummaryrefslogtreecommitdiff
path: root/src/malloc.c
AgeCommit message (Collapse)AuthorLines
2026-01-14Guard against oversized index entries in databases larger than 2GiB.drh-23/+1
FossilOrigin-Name: ed17a878e5a2e0cd1e9b69d528f5ac2ba8452d7c83deaf3cc72ecbff054f5ca3
2024-02-22Fix debugging code so that it compiles on MSVC.drh-4/+4
FossilOrigin-Name: ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3
2024-02-01Add the test_oom_breakpoint() routine on debug builds, to serve as adrh-0/+20
convenient breakpoint to intercept OOM conditions. FossilOrigin-Name: e45df7dcd6b5766d7593ee87e59dd422a217cce0a1a8d369c03144bb21859428
2023-10-11Simplification to sqlite3ApiExit(). Generates identical machine code, butdrh-1/+1
easier for humans to read. FossilOrigin-Name: 793bbfa5af9721bc3a61e8e5eda46dfce2f5ff3f223a7564c9e1b09f11e53cb3
2022-12-03Doc typo fix for SQLITE_MAX_ALLOCATION_SIZE in malloc.c. No code changes.stephan-1/+1
FossilOrigin-Name: ed1ed21221b048ac5a5275cdfc4d9b2a406acdc7d4b648c3b61bcc822d88d955
2022-11-22Convert an ALWAYS() in sqlite3DbSpanDup() into an assert(), for a performancedrh-1/+6
increase and size reduction. FossilOrigin-Name: 21e80a29737c367babcc0cf2533eed61b5d0fcf3cc3c33ab88761899e394eaf3
2022-09-27Provide the SQLITE_MAX_ALLOCATION_SIZE compile-time option for limiting thedrh-6/+22
maximum memory allocation size. FossilOrigin-Name: 584de6a996c78b8e41bdfcd05a8e2a3844664c6b4efedb5883c8b8af388462b5
2022-08-22Performance enhancement for sqlite3DbFree().drh-18/+20
FossilOrigin-Name: c296a9d958ec360fc8d217363348b4918d665bccb3c4f27503a2dcef7db49052
2022-08-22Add the new internal interface sqlite3DbNNFreeNN(db,ptr) where both thedrh-0/+35
db and ptr parameters are guaranteed to be non-NULL. Use this where appropriate to save more than 2 million CPU cycles on the standard performance test. FossilOrigin-Name: e5eaa80e81fdf86f2875a912b880272b8d099b82b08e945a7988c5dd0fe9d6b5
2022-07-10When an OOM occurs and sets the Parse.nErr value, also set the Parse.nErrdrh-0/+5
value for all outer Parse objects. dbsqlfuzz d33f60aaa67733aa700cd69dacf8e0e23a327a29 FossilOrigin-Name: 9a494d25944f4f640026e7a7ae2948e555d7af31487c55ed2ec2818a0789b887
2022-04-12Modify utility function sqlite3SetString() so that it may be used safely on ↵dan-1/+2
Parse.zErrMsg. Fuzzer test case "crash-1604e5d76c92574e21e437049dab9b672e06b767.txt". FossilOrigin-Name: 09c5a4ec13b02efd6207e26dab7beaf184f0d8ccea0bd0dfe94fc803fe5636ce
2022-01-24Make sure the sqlite3OomFault() routine sets an error in the Parse objectdrh-1/+10
if there is a Parse object active and linked to the database connection. FossilOrigin-Name: ad7aace761c6b21ba453eaf43c68d985be7cbd5a200fe0d2e27a0c7150f99874
2021-09-24Add lots of new "const" on internal function parameters. There is opportunitydrh-6/+6
for many more - this is a work in progress. FossilOrigin-Name: a3c71a673ddd1c299bdae550fb955077b77088329a8ca2895dfb23538b524a8e
2021-05-21Fix a problem with SQLITE_MAX_MEMORY in malloc.c.dan-1/+0
FossilOrigin-Name: c18dbe2f389f4ba7b219b7995d4f7009d1bc249ef8f93a30b262c6d2c008319d
2020-11-18Improvements to the mechanism that attempts to report SQLITE_CORRUPT ifdrh-3/+0
pread() says that the underlying filesystem is corrupt. FossilOrigin-Name: b887c7504e7edeba758f3c1203c6cc56eef499fe05e7e6c6d82939bf7d78c57f
2020-11-18On unix, for certain error codes of read()/pread() returndrh-7/+13
SQLITE_IOERR_CORRUPTFS instead of SQLITE_IOERR_READ. And then convert this error into SQLITE_CORRUPT prior to returning back to the application. FossilOrigin-Name: 9538ea8447e7b07c05197d6ff2208d3e97b45798736c85b63e8f0c7a3a98c1f3
2020-10-20Fix the sqlite3_hard_heap_limit() so that it works with sqlite3_realloc64()drh-1/+6
in addition to sqlite3_malloc64(). Improvements to OOM processing and debugging aids in the fuzzcheck utility. FossilOrigin-Name: 602d7369166d406a26834aa47d71d565a17d377d32e41f308821a50b41f91896
2020-07-16Small performance improvement and size reduction in sqlite3DbStrNDup().drh-4/+2
FossilOrigin-Name: 35cd87063d1933b87bc2176f957ecd758d7d167e9473fa615e33caec3be14783
2020-05-17Use the sqlite3Realloc() interface internally, rather than the publicdrh-1/+1
sqlite3_realloc64() equivalent, to avoid unnecessary calls to sqlite3_initialize(). FossilOrigin-Name: 1313557b512297e7b75ed748894379b2022aecf696d5a58318e46a668321c1ff
2020-05-08Do not retry on a failed realloc() unless SQLITE_ENABLE_MEMORY_MANAGEMENTdrh-0/+2
is available, meaning that the retry has some possibility of success. FossilOrigin-Name: e9a8f910b5e2b84dd77364783f0610bca970cc88aa037c88636c72145b99f411
2020-04-28Use AtomicStore() when setting the mem0.nearlyFull boolean to avoiddrh-3/+3
harmless TSAN warnings and to forestall doubts about threadsafety. FossilOrigin-Name: ce980af65a9b528f112baa22a95020a98ac5340155a0b53b09c46f99aad9b12b
2020-04-28Use an AtomicLoad() macro in sqlite3HeapNearlyFull().drh-1/+1
FossilOrigin-Name: 7556bc632e271d8a1e4fd836ce91e28213768ac09c90857b91171e9cd1009884
2020-03-30Use __atomic_load_n() and __atomic_store_n() for a few more things where ↵dan-2/+2
they are available. FossilOrigin-Name: a49f8ec552bede7da731e0571ccf49de1a30e7be3a5673150436c8b411ba6ffc
2019-12-31Refactor names. Use "small" instead of "mini" to describe the smallerdrh-17/+17
of the two lookaside memory allocation sizes. FossilOrigin-Name: 88d244983854cdc1a369c5df09ae00f1098784db768ba4e17b963d187dcb1009
2019-12-13Cleanup and performance enhancements for mini-lookaside.drh-21/+42
FossilOrigin-Name: 74805668430051032ae9b256c84e252755ee03075fc08293c948675ed40ec280
2019-12-12Reduce the number of call sites to dbMallocRawFinish in the case where n > ↵numist-3/+4
lookaside.sz FossilOrigin-Name: e392e7f22861ce4b66e4bf84b59c8fd38568fc241a699e001f47fd82011f4d28
2019-12-12Fix an issue where malloc could be used to fulfill a small allocation when a ↵numist-2/+5
large lookaside slot could have beeen used instead. FossilOrigin-Name: 611020e3378f4c81c277cccd84807ae51a816bbab6c3d887c91c5e5af3b5225f
2019-12-12Change the size of a mini-lookaside allocation to a macro (MINI_SZ) ratherdrh-3/+3
than a magic number (128). FossilOrigin-Name: 5e1949bca998f3c8c23a8ebf01c7a2e7a2af1fdad43886271e1fe0f25411551d
2019-12-12More efficient implementation of a lookaside allocator that supports mini ↵numist-3/+33
(in this case, harcoded to 128B) slots. FossilOrigin-Name: b02fdc09c838f355d9efce57f817d6a86153153b4a1f2b763914f4aaa34cb76e
2019-11-14Fix a bug in the hard_heap_limit pragma so that it returns the new value ofdrh-8/+8
the hard_heap_limit, not the soft_heap_limit. Change SQLITE_MAX_MEMORY so that it works by setting the default hard_heap_limit value. FossilOrigin-Name: 33fd0c3abcad5555a150990a22d9c1bab99e79be01143fccb9fafc9b52cf92c8
2019-11-14Merge recent enhancements from trunk.drh-22/+20
FossilOrigin-Name: b8a631fd30d0732505679230684b3362c965438197a2b11518f01a77599c9202
2019-10-05Performance optimization to the lookaside-memory disabling mechanism.drh-22/+20
FossilOrigin-Name: 17ce1c49cb0ed6fdd8c7c33431bc2afa217f1092c99b8dd608890a8e7aec7fb1
2019-04-25Add the sqlite3_hard_heap_limit64() interface and the correspondingdrh-2/+51
"PRAGMA hard_heap_limit=N" command. FossilOrigin-Name: b0ccef61a7f92d20228becbf4f997bf0f4e46dad2deaf0896dc63b976ad1dd11
2019-02-08Give the sqlite3 object a pointer to the current Parse so that if an OOMdrh-0/+3
occurs, it can automatically set the Parse.rc value to SQLITE_NOMEM. This avoids a frequent extra test of db.mallocFailed in the innermost parser loop. FossilOrigin-Name: 5c6638040b3017c6be016441422d965a3ca00dd6ae1f78cadc0b54562978f64e
2018-01-10Tag an unreachable branch using ALWAYS().drh-1/+1
FossilOrigin-Name: c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7
2017-12-27Add and use the internal sqlite3DbSpanDup() interface.drh-0/+13
FossilOrigin-Name: a8e1545cb7aacb6a26a8c92a3ad4a3d584d150c3a00d2828c8adbb1ee19fcb6d
2017-08-29Faster memory allocation from lookaside by not trying to keep track of thedrh-8/+7
number of outstanding allocations, and rather computing that value only when requested. FossilOrigin-Name: a06263f1efd2d45eac88b8d59e8fe8e458670fa3808c795feaa7f247fc36cbe9
2017-08-28Remove the rarely-used scratch memory allocator. This makes the code smaller,drh-140/+1
faster, and easier to maintain. In place of the scratch allocator, add the SQLITE_CONFIG_SMALL_MALLOC configuration option that provides a hint to SQLite that large memory allocations should be avoided. FossilOrigin-Name: 54b000246cfb5c7b8adb61a17357ef5a49adddde9e48e8937834d5ba0beb8a6b
2017-04-05Split off sqlite3DbFreeNN() from sqlite3DbFree() and use it in cases wheredrh-3/+8
we know that the argument to be freed is never NULL. FossilOrigin-Name: ad90e8bb5e47945607c8fb47b6ade8cfc52a9b684805cc40132629be0ecc14cc
2017-03-10Fix an error in the SQLITE_MAX_MEMORY implementation resulting from a baddrh-1/+2
merge. Update the OSSFuzz interface so that it times out after running the byte-code engine for 10 seconds. FossilOrigin-Name: f8560c60d10c0365b33342ab05b5a953987b0471
2017-03-10Add the -DSQLITE_MAX_MEMORY=N compile-time option. The default is no limit.drh-0/+6
FossilOrigin-Name: eabd4ef498a0f0d97d65e321c4d06ab90523ed61
2017-03-10Add the SQLITE_MAX_MEMORY compile-time option that provides a hard upper bounddrh-3/+9
on the amount of memory that SQLite will use, per process. FossilOrigin-Name: 77dfe2abdae88dea81217f352d87e5ba2c822715
2017-02-13Change all legacy instances of "#if SQLITE_DEBUG" to "#ifdef SQLITE_DEBUG" fordrh-2/+2
consistency. FossilOrigin-Name: 670f10b24230863688270d12ac519609ade2302b
2017-02-08Typo fixes in comment. No changes to code.mistachkin-3/+3
FossilOrigin-Name: c09dd5c0befaf5028abfead8114bd74a30ffe5d4
2017-02-08Always invoke the xRoundup() method of the memory allocator before callingdrh-4/+12
xMalloc(). FossilOrigin-Name: 77b470b0df73dc5ae5ad2f0170ef7c50558c7c88
2017-01-13Fix the build for SQLITE_ENABLE_MEMORY_MANAGEMENT.drh-2/+3
FossilOrigin-Name: 8c85b8fdd7f0ba65fba83361d361a567b797a184
2017-01-10Avoid unnecessary calls to the xRoundup() method of the memory allocator whendrh-7/+5
the soft heap limit is not set. FossilOrigin-Name: 4209b89eab01814228a178963238e0dffffad2a4
2016-12-27Avoid a potential (harmless) signed integer overflow in memory usagedrh-1/+1
accounting when calling sqlite3_realloc() to reduce the size of an allocation. FossilOrigin-Name: 2d71cbdf6bc24f0269027c70b39ea7f342436bdb
2016-10-17Small size reduction and performance increase in the string duplicator.drh-3/+2
FossilOrigin-Name: cda998f080cb00779d8c0d1c83d8fe2b74462cd4
2016-02-13Enhance ability to debug out-of-memory errors.mistachkin-1/+1
FossilOrigin-Name: 6a9c4a3ebfb7cc0738ef6634440ccab44a21ff28