drh
0b8c3126f4
Fix debugging code so that it compiles on MSVC.
...
FossilOrigin-Name: ce5df19dc4aff3fde03ef62261a5e095a16a8f4e46e2924becea4fed56ce49e3
2024-02-22 00:50:54 +00:00
drh
d87299cece
Add the test_oom_breakpoint() routine on debug builds, to serve as a
...
convenient breakpoint to intercept OOM conditions.
FossilOrigin-Name: e45df7dcd6b5766d7593ee87e59dd422a217cce0a1a8d369c03144bb21859428
2024-02-01 11:38:58 +00:00
drh
58c7b770de
Simplification to sqlite3ApiExit(). Generates identical machine code, but
...
easier for humans to read.
FossilOrigin-Name: 793bbfa5af9721bc3a61e8e5eda46dfce2f5ff3f223a7564c9e1b09f11e53cb3
2023-10-11 13:34:18 +00:00
stephan
54ac04c831
Doc typo fix for SQLITE_MAX_ALLOCATION_SIZE in malloc.c. No code changes.
...
FossilOrigin-Name: ed1ed21221b048ac5a5275cdfc4d9b2a406acdc7d4b648c3b61bcc822d88d955
2022-12-03 13:05:33 +00:00
drh
c59b7a8053
Convert an ALWAYS() in sqlite3DbSpanDup() into an assert(), for a performance
...
increase and size reduction.
FossilOrigin-Name: 21e80a29737c367babcc0cf2533eed61b5d0fcf3cc3c33ab88761899e394eaf3
2022-11-22 12:47:32 +00:00
drh
5d48e0cdc5
Provide the SQLITE_MAX_ALLOCATION_SIZE compile-time option for limiting the
...
maximum memory allocation size.
FossilOrigin-Name: 584de6a996c78b8e41bdfcd05a8e2a3844664c6b4efedb5883c8b8af388462b5
2022-09-27 16:35:06 +00:00
drh
376860ba88
Performance enhancement for sqlite3DbFree().
...
FossilOrigin-Name: c296a9d958ec360fc8d217363348b4918d665bccb3c4f27503a2dcef7db49052
2022-08-22 15:18:37 +00:00
drh
41ce47c4f4
Add the new internal interface sqlite3DbNNFreeNN(db,ptr) where both the
...
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-08-22 02:00:26 +00:00
drh
25bb72a7a8
When an OOM occurs and sets the Parse.nErr value, also set the Parse.nErr
...
value for all outer Parse objects.
dbsqlfuzz d33f60aaa67733aa700cd69dacf8e0e23a327a29
FossilOrigin-Name: 9a494d25944f4f640026e7a7ae2948e555d7af31487c55ed2ec2818a0789b887
2022-07-10 21:12:54 +00:00
dan
f7413d9acf
Modify utility function sqlite3SetString() so that it may be used safely on Parse.zErrMsg. Fuzzer test case "crash-1604e5d76c92574e21e437049dab9b672e06b767.txt".
...
FossilOrigin-Name: 09c5a4ec13b02efd6207e26dab7beaf184f0d8ccea0bd0dfe94fc803fe5636ce
2022-04-12 11:02:06 +00:00
drh
3cdb1394b9
Make sure the sqlite3OomFault() routine sets an error in the Parse object
...
if there is a Parse object active and linked to the database connection.
FossilOrigin-Name: ad7aace761c6b21ba453eaf43c68d985be7cbd5a200fe0d2e27a0c7150f99874
2022-01-24 12:48:54 +00:00
drh
b6dad520e5
Add lots of new "const" on internal function parameters. There is opportunity
...
for many more - this is a work in progress.
FossilOrigin-Name: a3c71a673ddd1c299bdae550fb955077b77088329a8ca2895dfb23538b524a8e
2021-09-24 16:14:47 +00:00
dan
acef1abda2
Fix a problem with SQLITE_MAX_MEMORY in malloc.c.
...
FossilOrigin-Name: c18dbe2f389f4ba7b219b7995d4f7009d1bc249ef8f93a30b262c6d2c008319d
2021-05-21 16:41:22 +00:00
drh
f56a4bfcd1
Improvements to the mechanism that attempts to report SQLITE_CORRUPT if
...
pread() says that the underlying filesystem is corrupt.
FossilOrigin-Name: b887c7504e7edeba758f3c1203c6cc56eef499fe05e7e6c6d82939bf7d78c57f
2020-11-18 21:50:05 +00:00
drh
5a07d10fd1
On unix, for certain error codes of read()/pread() return
...
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-11-18 12:48:48 +00:00
drh
672f07c642
Fix the sqlite3_hard_heap_limit() so that it works with sqlite3_realloc64()
...
in addition to sqlite3_malloc64(). Improvements to OOM processing and
debugging aids in the fuzzcheck utility.
FossilOrigin-Name: 602d7369166d406a26834aa47d71d565a17d377d32e41f308821a50b41f91896
2020-10-20 14:40:53 +00:00
drh
369e758fdc
Small performance improvement and size reduction in sqlite3DbStrNDup().
...
FossilOrigin-Name: 35cd87063d1933b87bc2176f957ecd758d7d167e9473fa615e33caec3be14783
2020-07-16 14:19:57 +00:00
drh
d924e7bc78
Use the sqlite3Realloc() interface internally, rather than the public
...
sqlite3_realloc64() equivalent, to avoid unnecessary calls to
sqlite3_initialize().
FossilOrigin-Name: 1313557b512297e7b75ed748894379b2022aecf696d5a58318e46a668321c1ff
2020-05-17 00:26:44 +00:00
drh
acc175215a
Do not retry on a failed realloc() unless SQLITE_ENABLE_MEMORY_MANAGEMENT
...
is available, meaning that the retry has some possibility of success.
FossilOrigin-Name: e9a8f910b5e2b84dd77364783f0610bca970cc88aa037c88636c72145b99f411
2020-05-08 10:44:23 +00:00
drh
23bef340be
Use AtomicStore() when setting the mem0.nearlyFull boolean to avoid
...
harmless TSAN warnings and to forestall doubts about threadsafety.
FossilOrigin-Name: ce980af65a9b528f112baa22a95020a98ac5340155a0b53b09c46f99aad9b12b
2020-04-28 14:01:31 +00:00
drh
9f603fcefd
Use an AtomicLoad() macro in sqlite3HeapNearlyFull().
...
FossilOrigin-Name: 7556bc632e271d8a1e4fd836ce91e28213768ac09c90857b91171e9cd1009884
2020-04-28 11:45:41 +00:00
dan
892edb69c4
Use __atomic_load_n() and __atomic_store_n() for a few more things where they are available.
...
FossilOrigin-Name: a49f8ec552bede7da731e0571ccf49de1a30e7be3a5673150436c8b411ba6ffc
2020-03-30 13:35:05 +00:00
drh
cf014f6cbd
Refactor names. Use "small" instead of "mini" to describe the smaller
...
of the two lookaside memory allocation sizes.
FossilOrigin-Name: 88d244983854cdc1a369c5df09ae00f1098784db768ba4e17b963d187dcb1009
2019-12-31 15:12:34 +00:00
drh
e6068027ca
Cleanup and performance enhancements for mini-lookaside.
...
FossilOrigin-Name: 74805668430051032ae9b256c84e252755ee03075fc08293c948675ed40ec280
2019-12-13 15:48:21 +00:00
numist
1b47c9c98e
Reduce the number of call sites to dbMallocRawFinish in the case where n > lookaside.sz
...
FossilOrigin-Name: e392e7f22861ce4b66e4bf84b59c8fd38568fc241a699e001f47fd82011f4d28
2019-12-12 20:58:32 +00:00
numist
c947d6a4dc
Fix an issue where malloc could be used to fulfill a small allocation when a large lookaside slot could have beeen used instead.
...
FossilOrigin-Name: 611020e3378f4c81c277cccd84807ae51a816bbab6c3d887c91c5e5af3b5225f
2019-12-12 20:39:47 +00:00
drh
0225d819c4
Change the size of a mini-lookaside allocation to a macro (MINI_SZ) rather
...
than a magic number (128).
FossilOrigin-Name: 5e1949bca998f3c8c23a8ebf01c7a2e7a2af1fdad43886271e1fe0f25411551d
2019-12-12 17:17:24 +00:00
numist
115d663c05
More efficient implementation of a lookaside allocator that supports mini (in this case, harcoded to 128B) slots.
...
FossilOrigin-Name: b02fdc09c838f355d9efce57f817d6a86153153b4a1f2b763914f4aaa34cb76e
2019-12-12 02:50:07 +00:00
drh
31999c5cac
Fix a bug in the hard_heap_limit pragma so that it returns the new value of
...
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-14 17:46:32 +00:00
drh
803f06bf62
Merge recent enhancements from trunk.
...
FossilOrigin-Name: b8a631fd30d0732505679230684b3362c965438197a2b11518f01a77599c9202
2019-11-14 15:21:15 +00:00
drh
31f69626df
Performance optimization to the lookaside-memory disabling mechanism.
...
FossilOrigin-Name: 17ce1c49cb0ed6fdd8c7c33431bc2afa217f1092c99b8dd608890a8e7aec7fb1
2019-10-05 14:39:36 +00:00
drh
10c0e7115b
Add the sqlite3_hard_heap_limit64() interface and the corresponding
...
"PRAGMA hard_heap_limit=N" command.
FossilOrigin-Name: b0ccef61a7f92d20228becbf4f997bf0f4e46dad2deaf0896dc63b976ad1dd11
2019-04-25 18:15:38 +00:00
drh
1cf197583d
Give the sqlite3 object a pointer to the current Parse so that if an OOM
...
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
2019-02-08 14:55:30 +00:00
drh
e75d1f5290
Tag an unreachable branch using ALWAYS().
...
FossilOrigin-Name: c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7
2018-01-10 13:58:23 +00:00
drh
9b2e0435d2
Add and use the internal sqlite3DbSpanDup() interface.
...
FossilOrigin-Name: a8e1545cb7aacb6a26a8c92a3ad4a3d584d150c3a00d2828c8adbb1ee19fcb6d
2017-12-27 19:43:22 +00:00
drh
52fb8e1945
Faster memory allocation from lookaside by not trying to keep track of the
...
number of outstanding allocations, and rather computing that value only
when requested.
FossilOrigin-Name: a06263f1efd2d45eac88b8d59e8fe8e458670fa3808c795feaa7f247fc36cbe9
2017-08-29 20:21:12 +00:00
drh
b2a0f75c06
Remove the rarely-used scratch memory allocator. This makes the code smaller,
...
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-08-28 15:51:35 +00:00
drh
dbd6a7dc06
Split off sqlite3DbFreeNN() from sqlite3DbFree() and use it in cases where
...
we know that the argument to be freed is never NULL.
FossilOrigin-Name: ad90e8bb5e47945607c8fb47b6ade8cfc52a9b684805cc40132629be0ecc14cc
2017-04-05 12:39:49 +00:00
drh
a6bf20b587
Fix an error in the SQLITE_MAX_MEMORY implementation resulting from a bad
...
merge. Update the OSSFuzz interface so that it times out after running
the byte-code engine for 10 seconds.
FossilOrigin-Name: f8560c60d10c0365b33342ab05b5a953987b0471
2017-03-10 17:03:11 +00:00
drh
1e45c7db56
Add the -DSQLITE_MAX_MEMORY=N compile-time option. The default is no limit.
...
FossilOrigin-Name: eabd4ef498a0f0d97d65e321c4d06ab90523ed61
2017-03-10 16:22:40 +00:00
drh
e43d6aee45
Add the SQLITE_MAX_MEMORY compile-time option that provides a hard upper bound
...
on the amount of memory that SQLite will use, per process.
FossilOrigin-Name: 77dfe2abdae88dea81217f352d87e5ba2c822715
2017-03-10 15:55:54 +00:00
drh
d879e3eb8d
Change all legacy instances of "#if SQLITE_DEBUG" to "#ifdef SQLITE_DEBUG" for
...
consistency.
FossilOrigin-Name: 670f10b24230863688270d12ac519609ade2302b
2017-02-13 13:35:55 +00:00
mistachkin
40b84365e4
Typo fixes in comment. No changes to code.
...
FossilOrigin-Name: c09dd5c0befaf5028abfead8114bd74a30ffe5d4
2017-02-08 18:13:46 +00:00
drh
087a29c78b
Always invoke the xRoundup() method of the memory allocator before calling
...
xMalloc().
FossilOrigin-Name: 77b470b0df73dc5ae5ad2f0170ef7c50558c7c88
2017-02-08 16:01:57 +00:00
drh
be7a0cee4e
Fix the build for SQLITE_ENABLE_MEMORY_MANAGEMENT.
...
FossilOrigin-Name: 8c85b8fdd7f0ba65fba83361d361a567b797a184
2017-01-13 12:53:35 +00:00
drh
1d21bac8aa
Avoid unnecessary calls to the xRoundup() method of the memory allocator when
...
the soft heap limit is not set.
FossilOrigin-Name: 4209b89eab01814228a178963238e0dffffad2a4
2017-01-10 16:09:46 +00:00
drh
1aa346950e
Avoid a potential (harmless) signed integer overflow in memory usage
...
accounting when calling sqlite3_realloc() to reduce the size of an
allocation.
FossilOrigin-Name: 2d71cbdf6bc24f0269027c70b39ea7f342436bdb
2016-12-27 12:08:36 +00:00
drh
cee11adaaa
Small size reduction and performance increase in the string duplicator.
...
FossilOrigin-Name: cda998f080cb00779d8c0d1c83d8fe2b74462cd4
2016-10-17 00:48:06 +00:00
mistachkin
fad3039c51
Enhance ability to debug out-of-memory errors.
...
FossilOrigin-Name: 6a9c4a3ebfb7cc0738ef6634440ccab44a21ff28
2016-02-13 23:43:46 +00:00
drh
f5818aa560
Make sure variable declarations occur at the beginning of blocks, even
...
with SQLITE_DEBUG enabled.
FossilOrigin-Name: 2f7778e64d93ef237e23ceac01ea9808df5cf2a1
2016-02-06 19:48:50 +00:00