10190d1daSdanielk1977# 2005 November 30 20190d1daSdanielk1977# 30190d1daSdanielk1977# The author disclaims copyright to this source code. In place of 40190d1daSdanielk1977# a legal notice, here is a blessing: 50190d1daSdanielk1977# 60190d1daSdanielk1977# May you do good and not evil. 70190d1daSdanielk1977# May you find forgiveness for yourself and forgive others. 80190d1daSdanielk1977# May you share freely, never taking more than you give. 90190d1daSdanielk1977# 100190d1daSdanielk1977#*********************************************************************** 110190d1daSdanielk1977# 12aef0bf64Sdanielk1977# This file contains test cases focused on the two memory-management APIs, 13aef0bf64Sdanielk1977# sqlite3_soft_heap_limit() and sqlite3_release_memory(). 14aef0bf64Sdanielk1977# 15468c82bcSdanielk1977# Prior to version 3.6.2, calling sqlite3_release_memory() or exceeding 16468c82bcSdanielk1977# the configured soft heap limit could cause sqlite to upgrade database 17468c82bcSdanielk1977# locks and flush dirty pages to the file system. As of 3.6.2, this is 18468c82bcSdanielk1977# no longer the case. In version 3.6.2, sqlite3_release_memory() only 19468c82bcSdanielk1977# reclaims clean pages. This test file has been updated accordingly. 200190d1daSdanielk1977# 2111809366Sdrh# $Id: malloc5.test,v 1.22 2009/04/11 19:09:54 drh Exp $ 2252622828Sdanielk1977 230190d1daSdanielk1977set testdir [file dirname $argv0] 240190d1daSdanielk1977source $testdir/tester.tcl 25eee4c8caSdrhsource $testdir/malloc_common.tcl 2652622828Sdanielk1977db close 270190d1daSdanielk1977 28aef0bf64Sdanielk1977# Only run these tests if memory debugging is turned on. 29ed138fb3Sdrh# 30eee4c8caSdrhif {!$MEMDEBUG} { 315a3032b3Sdrh puts "Skipping malloc5 tests: not compiled with -DSQLITE_MEMDEBUG..." 32aef0bf64Sdanielk1977 finish_test 33aef0bf64Sdanielk1977 return 34aef0bf64Sdanielk1977} 35aef0bf64Sdanielk1977 3652622828Sdanielk1977# Skip these tests if OMIT_MEMORY_MANAGEMENT was defined at compile time. 3752622828Sdanielk1977ifcapable !memorymanage { 3852622828Sdanielk1977 finish_test 3952622828Sdanielk1977 return 4052622828Sdanielk1977} 4152622828Sdanielk1977 423aefabafSdrhsqlite3_soft_heap_limit 0 4352622828Sdanielk1977sqlite3 db test.db 4452622828Sdanielk1977 450190d1daSdanielk1977do_test malloc5-1.1 { 466aafc29bSdrh # Simplest possible test. Call sqlite3_release_memory when there is exactly 47468c82bcSdanielk1977 # one unused page in a single pager cache. The page cannot be freed, as 48468c82bcSdanielk1977 # it is dirty. So sqlite3_release_memory() returns 0. 490190d1daSdanielk1977 # 500190d1daSdanielk1977 execsql { 51271d8cb0Sdrh PRAGMA auto_vacuum=OFF; 520190d1daSdanielk1977 BEGIN; 530190d1daSdanielk1977 CREATE TABLE abc(a, b, c); 540190d1daSdanielk1977 } 55468c82bcSdanielk1977 sqlite3_release_memory 56468c82bcSdanielk1977} {0} 57468c82bcSdanielk1977 58468c82bcSdanielk1977do_test malloc5-1.2 { 59468c82bcSdanielk1977 # Test that the transaction started in the above test is still active. 60468c82bcSdanielk1977 # The lock on the database file should not have been upgraded (this was 61468c82bcSdanielk1977 # not the case before version 3.6.2). 62468c82bcSdanielk1977 # 63468c82bcSdanielk1977 sqlite3 db2 test.db 64468c82bcSdanielk1977 execsql { SELECT * FROM sqlite_master } db2 65468c82bcSdanielk1977} {} 66468c82bcSdanielk1977do_test malloc5-1.3 { 67468c82bcSdanielk1977 # Call [sqlite3_release_memory] when there is exactly one unused page 68468c82bcSdanielk1977 # in the cache belonging to db2. 69468c82bcSdanielk1977 # 706aafc29bSdrh set ::pgalloc [sqlite3_release_memory] 710190d1daSdanielk1977 expr $::pgalloc > 0 720190d1daSdanielk1977} {1} 73468c82bcSdanielk1977 74468c82bcSdanielk1977do_test malloc5-1.4 { 75468c82bcSdanielk1977 # Commit the transaction and open a new one. Read 1 page into the cache. 76468c82bcSdanielk1977 # Because the page is not dirty, it is eligible for collection even 77468c82bcSdanielk1977 # before the transaction is concluded. 78468c82bcSdanielk1977 # 790190d1daSdanielk1977 execsql { 800190d1daSdanielk1977 COMMIT; 810190d1daSdanielk1977 BEGIN; 820190d1daSdanielk1977 SELECT * FROM abc; 830190d1daSdanielk1977 } 846aafc29bSdrh sqlite3_release_memory 850190d1daSdanielk1977} $::pgalloc 86468c82bcSdanielk1977 870190d1daSdanielk1977do_test malloc5-1.5 { 88468c82bcSdanielk1977 # Conclude the transaction opened in the previous [do_test] block. This 89468c82bcSdanielk1977 # causes another page (page 1) to become eligible for recycling. 90468c82bcSdanielk1977 # 91468c82bcSdanielk1977 execsql { COMMIT } 92468c82bcSdanielk1977 sqlite3_release_memory 93468c82bcSdanielk1977} $::pgalloc 94468c82bcSdanielk1977 95468c82bcSdanielk1977do_test malloc5-1.6 { 960190d1daSdanielk1977 # Manipulate the cache so that it contains two unused pages. One requires 970190d1daSdanielk1977 # a journal-sync to free, the other does not. 9824168728Sdanielk1977 db2 close 990190d1daSdanielk1977 execsql { 100468c82bcSdanielk1977 BEGIN; 1010190d1daSdanielk1977 SELECT * FROM abc; 1020190d1daSdanielk1977 CREATE TABLE def(d, e, f); 1030190d1daSdanielk1977 } 1046aafc29bSdrh sqlite3_release_memory 500 1050190d1daSdanielk1977} $::pgalloc 106468c82bcSdanielk1977 1070190d1daSdanielk1977do_test malloc5-1.7 { 108468c82bcSdanielk1977 # Database should not be locked this time. 109468c82bcSdanielk1977 sqlite3 db2 test.db 110468c82bcSdanielk1977 catchsql { SELECT * FROM abc } db2 111468c82bcSdanielk1977} {0 {}} 112468c82bcSdanielk1977do_test malloc5-1.8 { 113468c82bcSdanielk1977 # Try to release another block of memory. This will fail as the only 114468c82bcSdanielk1977 # pages currently in the cache are dirty (page 3) or pinned (page 1). 11524168728Sdanielk1977 db2 close 1166aafc29bSdrh sqlite3_release_memory 500 117468c82bcSdanielk1977} 0 1180190d1daSdanielk1977do_test malloc5-1.8 { 119468c82bcSdanielk1977 # Database is still not locked. 120468c82bcSdanielk1977 # 12124168728Sdanielk1977 sqlite3 db2 test.db 122468c82bcSdanielk1977 catchsql { SELECT * FROM abc } db2 123468c82bcSdanielk1977} {0 {}} 1240190d1daSdanielk1977do_test malloc5-1.9 { 1250190d1daSdanielk1977 execsql { 1260190d1daSdanielk1977 COMMIT; 1270190d1daSdanielk1977 } 1280190d1daSdanielk1977} {} 1290190d1daSdanielk1977 1300190d1daSdanielk1977do_test malloc5-2.1 { 1310190d1daSdanielk1977 # Put some data in tables abc and def. Both tables are still wholly 1320190d1daSdanielk1977 # contained within their root pages. 1330190d1daSdanielk1977 execsql { 1340190d1daSdanielk1977 INSERT INTO abc VALUES(1, 2, 3); 1350190d1daSdanielk1977 INSERT INTO abc VALUES(4, 5, 6); 1360190d1daSdanielk1977 INSERT INTO def VALUES(7, 8, 9); 1370190d1daSdanielk1977 INSERT INTO def VALUES(10,11,12); 1380190d1daSdanielk1977 } 1390190d1daSdanielk1977} {} 1400190d1daSdanielk1977do_test malloc5-2.2 { 1410190d1daSdanielk1977 # Load the root-page for table def into the cache. Then query table abc. 1420190d1daSdanielk1977 # Halfway through the query call sqlite3_release_memory(). The goal of this 1430190d1daSdanielk1977 # test is to make sure we don't free pages that are in use (specifically, 1440190d1daSdanielk1977 # the root of table abc). 145468c82bcSdanielk1977 sqlite3_release_memory 1460190d1daSdanielk1977 set nRelease 0 1470190d1daSdanielk1977 execsql { 1480190d1daSdanielk1977 BEGIN; 1490190d1daSdanielk1977 SELECT * FROM def; 1500190d1daSdanielk1977 } 1515591df55Sdanielk1977 set data [list] 1520190d1daSdanielk1977 db eval {SELECT * FROM abc} { 1536aafc29bSdrh incr nRelease [sqlite3_release_memory] 1540190d1daSdanielk1977 lappend data $a $b $c 1550190d1daSdanielk1977 } 1565591df55Sdanielk1977 execsql { 1575591df55Sdanielk1977 COMMIT; 1585591df55Sdanielk1977 } 1590190d1daSdanielk1977 list $nRelease $data 1600190d1daSdanielk1977} [list $pgalloc [list 1 2 3 4 5 6]] 1610190d1daSdanielk1977 1625591df55Sdanielk1977do_test malloc5-3.1 { 1635591df55Sdanielk1977 # Simple test to show that if two pagers are opened from within this 1645591df55Sdanielk1977 # thread, memory is freed from both when sqlite3_release_memory() is 1655591df55Sdanielk1977 # called. 1665591df55Sdanielk1977 execsql { 1675591df55Sdanielk1977 BEGIN; 1685591df55Sdanielk1977 SELECT * FROM abc; 1695591df55Sdanielk1977 } 1705591df55Sdanielk1977 execsql { 1715591df55Sdanielk1977 SELECT * FROM sqlite_master; 1725591df55Sdanielk1977 BEGIN; 1735591df55Sdanielk1977 SELECT * FROM def; 1745591df55Sdanielk1977 } db2 1756aafc29bSdrh sqlite3_release_memory 1765591df55Sdanielk1977} [expr $::pgalloc * 2] 1775591df55Sdanielk1977do_test malloc5-3.2 { 1785591df55Sdanielk1977 concat \ 1795591df55Sdanielk1977 [execsql {SELECT * FROM abc; COMMIT}] \ 1805591df55Sdanielk1977 [execsql {SELECT * FROM def; COMMIT} db2] 1815591df55Sdanielk1977} {1 2 3 4 5 6 7 8 9 10 11 12} 1825591df55Sdanielk1977 1835591df55Sdanielk1977db2 close 184ed138fb3Sdrhputs "Highwater mark: [sqlite3_memory_highwater]" 1855591df55Sdanielk1977 1865591df55Sdanielk1977# The following two test cases each execute a transaction in which 1875591df55Sdanielk1977# 10000 rows are inserted into table abc. The first test case is used 1885591df55Sdanielk1977# to ensure that more than 1MB of dynamic memory is used to perform 1895591df55Sdanielk1977# the transaction. 1905591df55Sdanielk1977# 1915591df55Sdanielk1977# The second test case sets the "soft-heap-limit" to 100,000 bytes (0.1 MB) 1925591df55Sdanielk1977# and tests to see that this limit is not exceeded at any point during 1935591df55Sdanielk1977# transaction execution. 1945591df55Sdanielk1977# 195aef0bf64Sdanielk1977# Before executing malloc5-4.* we save the value of the current soft heap 196aef0bf64Sdanielk1977# limit in variable ::soft_limit. The original value is restored after 197aef0bf64Sdanielk1977# running the tests. 198aef0bf64Sdanielk1977# 1996aafc29bSdrhset ::soft_limit [sqlite3_soft_heap_limit -1] 2003a7fb7c4Sdrhexecsql {PRAGMA cache_size=2000} 2015591df55Sdanielk1977do_test malloc5-4.1 { 2025591df55Sdanielk1977 execsql {BEGIN;} 2035591df55Sdanielk1977 execsql {DELETE FROM abc;} 2045591df55Sdanielk1977 for {set i 0} {$i < 10000} {incr i} { 2055591df55Sdanielk1977 execsql "INSERT INTO abc VALUES($i, $i, '[string repeat X 100]');" 2065591df55Sdanielk1977 } 2075591df55Sdanielk1977 execsql {COMMIT;} 208468c82bcSdanielk1977 sqlite3_release_memory 209468c82bcSdanielk1977 sqlite3_memory_highwater 1 210468c82bcSdanielk1977 execsql {SELECT * FROM abc} 211ed138fb3Sdrh set nMaxBytes [sqlite3_memory_highwater 1] 212ed138fb3Sdrh puts -nonewline " (Highwater mark: $nMaxBytes) " 213ed138fb3Sdrh expr $nMaxBytes > 1000000 2145591df55Sdanielk1977} {1} 2155591df55Sdanielk1977do_test malloc5-4.2 { 2166aafc29bSdrh sqlite3_release_memory 217468c82bcSdanielk1977 sqlite3_soft_heap_limit 100000 218ed138fb3Sdrh sqlite3_memory_highwater 1 219468c82bcSdanielk1977 execsql {SELECT * FROM abc} 220ed138fb3Sdrh set nMaxBytes [sqlite3_memory_highwater 1] 221ed138fb3Sdrh puts -nonewline " (Highwater mark: $nMaxBytes) " 222468c82bcSdanielk1977 expr $nMaxBytes <= 100000 2235591df55Sdanielk1977} {1} 2245591df55Sdanielk1977do_test malloc5-4.3 { 2255591df55Sdanielk1977 # Check that the content of table abc is at least roughly as expected. 2265591df55Sdanielk1977 execsql { 2275591df55Sdanielk1977 SELECT count(*), sum(a), sum(b) FROM abc; 2285591df55Sdanielk1977 } 229468c82bcSdanielk1977} [list 10000 [expr int(10000.0 * 4999.5)] [expr int(10000.0 * 4999.5)]] 2305591df55Sdanielk1977 231aef0bf64Sdanielk1977# Restore the soft heap limit. 2326aafc29bSdrhsqlite3_soft_heap_limit $::soft_limit 23352622828Sdanielk1977 234c551edc2Sdanielk1977# Test that there are no problems calling sqlite3_release_memory when 235c551edc2Sdanielk1977# there are open in-memory databases. 236c551edc2Sdanielk1977# 237c551edc2Sdanielk1977# At one point these tests would cause a seg-fault. 238c551edc2Sdanielk1977# 239c551edc2Sdanielk1977do_test malloc5-5.1 { 240c551edc2Sdanielk1977 db close 241c551edc2Sdanielk1977 sqlite3 db :memory: 242c551edc2Sdanielk1977 execsql { 243c551edc2Sdanielk1977 BEGIN; 244c551edc2Sdanielk1977 CREATE TABLE abc(a, b, c); 245c551edc2Sdanielk1977 INSERT INTO abc VALUES('abcdefghi', 1234567890, NULL); 246c551edc2Sdanielk1977 INSERT INTO abc SELECT * FROM abc; 247c551edc2Sdanielk1977 INSERT INTO abc SELECT * FROM abc; 248c551edc2Sdanielk1977 INSERT INTO abc SELECT * FROM abc; 249c551edc2Sdanielk1977 INSERT INTO abc SELECT * FROM abc; 250c551edc2Sdanielk1977 INSERT INTO abc SELECT * FROM abc; 251c551edc2Sdanielk1977 INSERT INTO abc SELECT * FROM abc; 252c551edc2Sdanielk1977 INSERT INTO abc SELECT * FROM abc; 253c551edc2Sdanielk1977 } 254c551edc2Sdanielk1977 sqlite3_release_memory 255c551edc2Sdanielk1977} 0 25684f786fcSdanielk1977do_test malloc5-5.2 { 257c551edc2Sdanielk1977 sqlite3_soft_heap_limit 5000 258c551edc2Sdanielk1977 execsql { 259c551edc2Sdanielk1977 COMMIT; 260c551edc2Sdanielk1977 PRAGMA temp_store = memory; 261c551edc2Sdanielk1977 SELECT * FROM abc ORDER BY a; 262c551edc2Sdanielk1977 } 263c551edc2Sdanielk1977 expr 1 264c551edc2Sdanielk1977} {1} 26584f786fcSdanielk1977sqlite3_soft_heap_limit $::soft_limit 26684f786fcSdanielk1977 26784f786fcSdanielk1977#------------------------------------------------------------------------- 26884f786fcSdanielk1977# The following test cases (malloc5-6.*) test the new global LRU list 26984f786fcSdanielk1977# used to determine the pages to recycle when sqlite3_release_memory is 27084f786fcSdanielk1977# called and there is more than one pager open. 27184f786fcSdanielk1977# 27284f786fcSdanielk1977proc nPage {db} { 27384f786fcSdanielk1977 set bt [btree_from_db $db] 27484f786fcSdanielk1977 array set stats [btree_pager_stats $bt] 27584f786fcSdanielk1977 set stats(page) 27684f786fcSdanielk1977} 27784f786fcSdanielk1977db close 278*fda06befSmistachkinforcedelete test.db test.db-journal test2.db test2.db-journal 27984f786fcSdanielk1977 28084f786fcSdanielk1977# This block of test-cases (malloc5-6.1.*) prepares two database files 28184f786fcSdanielk1977# for the subsequent tests. 28284f786fcSdanielk1977do_test malloc5-6.1.1 { 28384f786fcSdanielk1977 sqlite3 db test.db 28484f786fcSdanielk1977 execsql { 28584f786fcSdanielk1977 PRAGMA page_size=1024; 28684f786fcSdanielk1977 PRAGMA default_cache_size=10; 287801880f6Sdanielk1977 } 288801880f6Sdanielk1977 execsql { 289801880f6Sdanielk1977 PRAGMA temp_store = memory; 29084f786fcSdanielk1977 BEGIN; 29184f786fcSdanielk1977 CREATE TABLE abc(a PRIMARY KEY, b, c); 29284f786fcSdanielk1977 INSERT INTO abc VALUES(randstr(50,50), randstr(75,75), randstr(100,100)); 29384f786fcSdanielk1977 INSERT INTO abc 29484f786fcSdanielk1977 SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; 29584f786fcSdanielk1977 INSERT INTO abc 29684f786fcSdanielk1977 SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; 29784f786fcSdanielk1977 INSERT INTO abc 29884f786fcSdanielk1977 SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; 29984f786fcSdanielk1977 INSERT INTO abc 30084f786fcSdanielk1977 SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; 30184f786fcSdanielk1977 INSERT INTO abc 30284f786fcSdanielk1977 SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; 30384f786fcSdanielk1977 INSERT INTO abc 30484f786fcSdanielk1977 SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; 30584f786fcSdanielk1977 COMMIT; 30684f786fcSdanielk1977 } 307*fda06befSmistachkin forcecopy test.db test2.db 30884f786fcSdanielk1977 sqlite3 db2 test2.db 309fa18beceSdanielk1977 list \ 310fa18beceSdanielk1977 [expr ([file size test.db]/1024)>20] [expr ([file size test2.db]/1024)>20] 311fa18beceSdanielk1977} {1 1} 31284f786fcSdanielk1977do_test malloc5-6.1.2 { 31384f786fcSdanielk1977 list [execsql {PRAGMA cache_size}] [execsql {PRAGMA cache_size} db2] 31484f786fcSdanielk1977} {10 10} 31584f786fcSdanielk1977 31684f786fcSdanielk1977do_test malloc5-6.2.1 { 31784f786fcSdanielk1977 execsql {SELECT * FROM abc} db2 31884f786fcSdanielk1977 execsql {SELECT * FROM abc} db 319801880f6Sdanielk1977 expr [nPage db] + [nPage db2] 320801880f6Sdanielk1977} {20} 321801880f6Sdanielk1977 32284f786fcSdanielk1977do_test malloc5-6.2.2 { 32384f786fcSdanielk1977 # If we now try to reclaim some memory, it should come from the db2 cache. 32484f786fcSdanielk1977 sqlite3_release_memory 3000 325801880f6Sdanielk1977 expr [nPage db] + [nPage db2] 326801880f6Sdanielk1977} {17} 32784f786fcSdanielk1977do_test malloc5-6.2.3 { 32884f786fcSdanielk1977 # Access the db2 cache again, so that all the db2 pages have been used 32984f786fcSdanielk1977 # more recently than all the db pages. Then try to reclaim 3000 bytes. 33084f786fcSdanielk1977 # This time, 3 pages should be pulled from the db cache. 33184f786fcSdanielk1977 execsql { SELECT * FROM abc } db2 33284f786fcSdanielk1977 sqlite3_release_memory 3000 333801880f6Sdanielk1977 expr [nPage db] + [nPage db2] 334801880f6Sdanielk1977} {17} 33584f786fcSdanielk1977 33684f786fcSdanielk1977do_test malloc5-6.3.1 { 33784f786fcSdanielk1977 # Now open a transaction and update 2 pages in the db2 cache. Then 33884f786fcSdanielk1977 # do a SELECT on the db cache so that all the db pages are more recently 33984f786fcSdanielk1977 # used than the db2 pages. When we try to free memory, SQLite should 34084f786fcSdanielk1977 # free the non-dirty db2 pages, then the db pages, then finally use 34184f786fcSdanielk1977 # sync() to free up the dirty db2 pages. The only page that cannot be 34284f786fcSdanielk1977 # freed is page1 of db2. Because there is an open transaction, the 34384f786fcSdanielk1977 # btree layer holds a reference to page 1 in the db2 cache. 34484f786fcSdanielk1977 execsql { 34584f786fcSdanielk1977 BEGIN; 34684f786fcSdanielk1977 UPDATE abc SET c = randstr(100,100) 34784f786fcSdanielk1977 WHERE rowid = 1 OR rowid = (SELECT max(rowid) FROM abc); 34884f786fcSdanielk1977 } db2 34984f786fcSdanielk1977 execsql { SELECT * FROM abc } db 350801880f6Sdanielk1977 expr [nPage db] + [nPage db2] 351801880f6Sdanielk1977} {20} 35284f786fcSdanielk1977do_test malloc5-6.3.2 { 35384f786fcSdanielk1977 # Try to release 7700 bytes. This should release all the 35484f786fcSdanielk1977 # non-dirty pages held by db2. 35584f786fcSdanielk1977 sqlite3_release_memory [expr 7*1100] 35684f786fcSdanielk1977 list [nPage db] [nPage db2] 35784f786fcSdanielk1977} {10 3} 35884f786fcSdanielk1977do_test malloc5-6.3.3 { 35984f786fcSdanielk1977 # Try to release another 1000 bytes. This should come fromt the db 36084f786fcSdanielk1977 # cache, since all three pages held by db2 are either in-use or diry. 36184f786fcSdanielk1977 sqlite3_release_memory 1000 36284f786fcSdanielk1977 list [nPage db] [nPage db2] 36384f786fcSdanielk1977} {9 3} 36484f786fcSdanielk1977do_test malloc5-6.3.4 { 36584f786fcSdanielk1977 # Now release 9900 more (about 9 pages worth). This should expunge 36684f786fcSdanielk1977 # the rest of the db cache. But the db2 cache remains intact, because 36784f786fcSdanielk1977 # SQLite tries to avoid calling sync(). 36811809366Sdrh if {$::tcl_platform(wordSize)==8} { 36911809366Sdrh sqlite3_release_memory 10177 37011809366Sdrh } else { 37184f786fcSdanielk1977 sqlite3_release_memory 9900 37211809366Sdrh } 37384f786fcSdanielk1977 list [nPage db] [nPage db2] 37484f786fcSdanielk1977} {0 3} 37584f786fcSdanielk1977do_test malloc5-6.3.5 { 37684f786fcSdanielk1977 # But if we are really insistent, SQLite will consent to call sync() 377468c82bcSdanielk1977 # if there is no other option. UPDATE: As of 3.6.2, SQLite will not 378468c82bcSdanielk1977 # call sync() in this scenario. So no further memory can be reclaimed. 37984f786fcSdanielk1977 sqlite3_release_memory 1000 38084f786fcSdanielk1977 list [nPage db] [nPage db2] 381468c82bcSdanielk1977} {0 3} 38284f786fcSdanielk1977do_test malloc5-6.3.6 { 38384f786fcSdanielk1977 # The referenced page (page 1 of the db2 cache) will not be freed no 38484f786fcSdanielk1977 # matter how much memory we ask for: 38584f786fcSdanielk1977 sqlite3_release_memory 31459 38684f786fcSdanielk1977 list [nPage db] [nPage db2] 387468c82bcSdanielk1977} {0 3} 38884f786fcSdanielk1977 38984f786fcSdanielk1977db2 close 390c551edc2Sdanielk1977 391c551edc2Sdanielk1977sqlite3_soft_heap_limit $::soft_limit 392c551edc2Sdanielk1977finish_test 39352622828Sdanielk1977catch {db close} 394