/ Hex Artifact Content
Login

Artifact 7425272e263325fda7d32cb55706e52b5c09e7e0:


0000: 23 20 32 30 30 35 20 4e 6f 76 65 6d 62 65 72 20  # 2005 November 
0010: 33 30 0a 23 0a 23 20 54 68 65 20 61 75 74 68 6f  30.#.# The autho
0020: 72 20 64 69 73 63 6c 61 69 6d 73 20 63 6f 70 79  r disclaims copy
0030: 72 69 67 68 74 20 74 6f 20 74 68 69 73 20 73 6f  right to this so
0040: 75 72 63 65 20 63 6f 64 65 2e 20 20 49 6e 20 70  urce code.  In p
0050: 6c 61 63 65 20 6f 66 0a 23 20 61 20 6c 65 67 61  lace of.# a lega
0060: 6c 20 6e 6f 74 69 63 65 2c 20 68 65 72 65 20 69  l notice, here i
0070: 73 20 61 20 62 6c 65 73 73 69 6e 67 3a 0a 23 0a  s a blessing:.#.
0080: 23 20 20 20 20 4d 61 79 20 79 6f 75 20 64 6f 20  #    May you do 
0090: 67 6f 6f 64 20 61 6e 64 20 6e 6f 74 20 65 76 69  good and not evi
00a0: 6c 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20  l..#    May you 
00b0: 66 69 6e 64 20 66 6f 72 67 69 76 65 6e 65 73 73  find forgiveness
00c0: 20 66 6f 72 20 79 6f 75 72 73 65 6c 66 20 61 6e   for yourself an
00d0: 64 20 66 6f 72 67 69 76 65 20 6f 74 68 65 72 73  d forgive others
00e0: 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20 73  ..#    May you s
00f0: 68 61 72 65 20 66 72 65 65 6c 79 2c 20 6e 65 76  hare freely, nev
0100: 65 72 20 74 61 6b 69 6e 67 20 6d 6f 72 65 20 74  er taking more t
0110: 68 61 6e 20 79 6f 75 20 67 69 76 65 2e 0a 23 0a  han you give..#.
0120: 23 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  #***************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 2a 2a 2a 2a 2a 0a 23 0a 23 20 54 68 69  ********.#.# Thi
0170: 73 20 66 69 6c 65 20 63 6f 6e 74 61 69 6e 73 20  s file contains 
0180: 74 65 73 74 20 63 61 73 65 73 20 66 6f 63 75 73  test cases focus
0190: 65 64 20 6f 6e 20 74 68 65 20 74 77 6f 20 6d 65  ed on the two me
01a0: 6d 6f 72 79 2d 6d 61 6e 61 67 65 6d 65 6e 74 20  mory-management 
01b0: 41 50 49 73 2c 20 0a 23 20 73 71 6c 69 74 65 33  APIs, .# sqlite3
01c0: 5f 73 6f 66 74 5f 68 65 61 70 5f 6c 69 6d 69 74  _soft_heap_limit
01d0: 28 29 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 72  () and sqlite3_r
01e0: 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79 28 29 2e  elease_memory().
01f0: 0a 23 0a 23 20 24 49 64 3a 20 6d 61 6c 6c 6f 63  .#.# $Id: malloc
0200: 35 2e 74 65 73 74 2c 76 20 31 2e 37 20 32 30 30  5.test,v 1.7 200
0210: 36 2f 30 31 2f 31 39 20 30 38 3a 34 33 3a 33 32  6/01/19 08:43:32
0220: 20 64 61 6e 69 65 6c 6b 31 39 37 37 20 45 78 70   danielk1977 Exp
0230: 20 24 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d   $..#-----------
0240: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0250: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0260: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0270: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0280: 0a 23 20 4e 4f 54 45 53 20 4f 4e 20 45 58 50 45  .# NOTES ON EXPE
0290: 43 54 45 44 20 42 45 48 41 56 49 4f 55 52 0a 23  CTED BEHAVIOUR.#
02a0: 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .#--------------
02b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
02c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
02d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
02e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 0a  -------------...
02f0: 73 65 74 20 74 65 73 74 64 69 72 20 5b 66 69 6c  set testdir [fil
0300: 65 20 64 69 72 6e 61 6d 65 20 24 61 72 67 76 30  e dirname $argv0
0310: 5d 0a 73 6f 75 72 63 65 20 24 74 65 73 74 64 69  ].source $testdi
0320: 72 2f 74 65 73 74 65 72 2e 74 63 6c 0a 64 62 20  r/tester.tcl.db 
0330: 63 6c 6f 73 65 0a 0a 23 20 4f 6e 6c 79 20 72 75  close..# Only ru
0340: 6e 20 74 68 65 73 65 20 74 65 73 74 73 20 69 66  n these tests if
0350: 20 6d 65 6d 6f 72 79 20 64 65 62 75 67 67 69 6e   memory debuggin
0360: 67 20 69 73 20 74 75 72 6e 65 64 20 6f 6e 2e 0a  g is turned on..
0370: 69 66 20 7b 5b 69 6e 66 6f 20 63 6f 6d 6d 61 6e  if {[info comman
0380: 64 20 73 71 6c 69 74 65 5f 6d 61 6c 6c 6f 63 5f  d sqlite_malloc_
0390: 73 74 61 74 5d 3d 3d 22 22 7d 20 7b 0a 20 20 20  stat]==""} {.   
03a0: 70 75 74 73 20 22 53 6b 69 70 70 69 6e 67 20 6d  puts "Skipping m
03b0: 61 6c 6c 6f 63 20 74 65 73 74 73 3a 20 6e 6f 74  alloc tests: not
03c0: 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 68 20 2d   compiled with -
03d0: 44 53 51 4c 49 54 45 5f 4d 45 4d 44 45 42 55 47  DSQLITE_MEMDEBUG
03e0: 2e 2e 2e 22 0a 20 20 20 66 69 6e 69 73 68 5f 74  ...".   finish_t
03f0: 65 73 74 0a 20 20 20 72 65 74 75 72 6e 0a 7d 0a  est.   return.}.
0400: 0a 23 20 53 6b 69 70 20 74 68 65 73 65 20 74 65  .# Skip these te
0410: 73 74 73 20 69 66 20 4f 4d 49 54 5f 4d 45 4d 4f  sts if OMIT_MEMO
0420: 52 59 5f 4d 41 4e 41 47 45 4d 45 4e 54 20 77 61  RY_MANAGEMENT wa
0430: 73 20 64 65 66 69 6e 65 64 20 61 74 20 63 6f 6d  s defined at com
0440: 70 69 6c 65 20 74 69 6d 65 2e 0a 69 66 63 61 70  pile time..ifcap
0450: 61 62 6c 65 20 21 6d 65 6d 6f 72 79 6d 61 6e 61  able !memorymana
0460: 67 65 20 7b 0a 20 20 20 66 69 6e 69 73 68 5f 74  ge {.   finish_t
0470: 65 73 74 0a 20 20 20 72 65 74 75 72 6e 0a 7d 0a  est.   return.}.
0480: 0a 73 71 6c 69 74 65 33 20 64 62 20 74 65 73 74  .sqlite3 db test
0490: 2e 64 62 0a 0a 64 6f 5f 74 65 73 74 20 6d 61 6c  .db..do_test mal
04a0: 6c 6f 63 35 2d 31 2e 31 20 7b 0a 20 20 23 20 53  loc5-1.1 {.  # S
04b0: 69 6d 70 6c 65 73 74 20 70 6f 73 73 69 62 6c 65  implest possible
04c0: 20 74 65 73 74 2e 20 43 61 6c 6c 20 73 71 6c 69   test. Call sqli
04d0: 74 65 33 5f 72 65 6c 65 61 73 65 5f 6d 65 6d 6f  te3_release_memo
04e0: 72 79 20 77 68 65 6e 20 74 68 65 72 65 20 69 73  ry when there is
04f0: 20 65 78 61 63 74 6c 79 0a 20 20 23 20 6f 6e 65   exactly.  # one
0500: 20 75 6e 75 73 65 64 20 70 61 67 65 20 69 6e 20   unused page in 
0510: 61 20 73 69 6e 67 6c 65 20 70 61 67 65 72 20 63  a single pager c
0520: 61 63 68 65 2e 20 54 68 69 73 20 74 65 73 74 20  ache. This test 
0530: 63 61 73 65 20 73 65 74 27 73 20 74 68 65 20 0a  case set's the .
0540: 20 20 23 20 76 61 6c 75 65 20 6f 66 20 74 68 65    # value of the
0550: 20 3a 3a 70 67 61 6c 6c 6f 63 20 76 61 72 69 61   ::pgalloc varia
0560: 62 6c 65 2c 20 77 68 69 63 68 20 69 73 20 75 73  ble, which is us
0570: 65 64 20 69 6e 20 73 75 62 73 65 71 75 65 6e 74  ed in subsequent
0580: 20 74 65 73 74 73 2e 0a 20 20 23 0a 20 20 23 20   tests..  #.  # 
0590: 4e 6f 74 65 3a 20 45 76 65 6e 20 74 68 6f 75 67  Note: Even thoug
05a0: 68 20 65 78 65 63 75 74 69 6e 67 20 74 68 69 73  h executing this
05b0: 20 73 74 61 74 65 6d 65 6e 74 20 6f 6e 20 61 6e   statement on an
05c0: 20 65 6d 70 74 79 20 64 61 74 61 62 61 73 65 20   empty database 
05d0: 0a 20 20 23 20 6d 6f 64 69 66 69 65 73 20 32 20  .  # modifies 2 
05e0: 70 61 67 65 73 20 28 74 68 65 20 72 6f 6f 74 20  pages (the root 
05f0: 6f 66 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72  of sqlite_master
0600: 20 61 6e 64 20 74 68 65 20 6e 65 77 20 72 6f 6f   and the new roo
0610: 74 20 70 61 67 65 29 2c 20 0a 20 20 23 20 74 68  t page), .  # th
0620: 65 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 20  e sqlite_master 
0630: 72 6f 6f 74 20 28 70 61 67 65 20 31 29 20 69 73  root (page 1) is
0640: 20 6e 65 76 65 72 20 66 72 65 65 64 20 62 65 63   never freed bec
0650: 61 75 73 65 20 74 68 65 20 62 74 72 65 65 20 6c  ause the btree l
0660: 61 79 65 72 0a 20 20 23 20 72 65 74 61 69 6e 73  ayer.  # retains
0670: 20 61 20 72 65 66 65 72 65 6e 63 65 20 74 6f 20   a reference to 
0680: 69 74 20 66 6f 72 20 74 68 65 20 65 6e 74 69 72  it for the entir
0690: 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 2e 20 0a  e transaction. .
06a0: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
06b0: 42 45 47 49 4e 3b 0a 20 20 20 20 43 52 45 41 54  BEGIN;.    CREAT
06c0: 45 20 54 41 42 4c 45 20 61 62 63 28 61 2c 20 62  E TABLE abc(a, b
06d0: 2c 20 63 29 3b 0a 20 20 7d 0a 20 20 73 65 74 20  , c);.  }.  set 
06e0: 3a 3a 70 67 61 6c 6c 6f 63 20 5b 73 71 6c 69 74  ::pgalloc [sqlit
06f0: 65 33 5f 72 65 6c 65 61 73 65 5f 6d 65 6d 6f 72  e3_release_memor
0700: 79 5d 0a 20 20 65 78 70 72 20 24 3a 3a 70 67 61  y].  expr $::pga
0710: 6c 6c 6f 63 20 3e 20 30 0a 7d 20 7b 31 7d 0a 64  lloc > 0.} {1}.d
0720: 6f 5f 74 65 73 74 20 6d 61 6c 6c 6f 63 35 2d 31  o_test malloc5-1
0730: 2e 32 20 7b 0a 20 20 23 20 54 65 73 74 20 74 68  .2 {.  # Test th
0740: 61 74 20 74 68 65 20 74 72 61 6e 73 61 63 74 69  at the transacti
0750: 6f 6e 20 73 74 61 72 74 65 64 20 69 6e 20 74 68  on started in th
0760: 65 20 61 62 6f 76 65 20 74 65 73 74 20 69 73 20  e above test is 
0770: 73 74 69 6c 6c 20 61 63 74 69 76 65 2e 0a 20 20  still active..  
0780: 23 20 42 65 63 61 75 73 65 20 74 68 65 20 70 61  # Because the pa
0790: 67 65 20 66 72 65 65 64 20 68 61 64 20 62 65 65  ge freed had bee
07a0: 6e 20 77 72 69 74 74 65 6e 20 74 6f 2c 20 66 72  n written to, fr
07b0: 65 65 69 6e 67 20 69 74 20 72 65 71 75 69 72 65  eeing it require
07c0: 64 20 61 0a 20 20 23 20 6a 6f 75 72 6e 61 6c 20  d a.  # journal 
07d0: 73 79 6e 63 20 61 6e 64 20 65 78 63 6c 75 73 69  sync and exclusi
07e0: 76 65 20 6c 6f 63 6b 20 6f 6e 20 74 68 65 20 64  ve lock on the d
07f0: 61 74 61 62 61 73 65 20 66 69 6c 65 2e 20 54 65  atabase file. Te
0800: 73 74 20 74 68 65 20 66 69 6c 65 0a 20 20 23 20  st the file.  # 
0810: 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 6c 6f  appears to be lo
0820: 63 6b 65 64 2e 0a 20 20 73 71 6c 69 74 65 33 20  cked..  sqlite3 
0830: 64 62 32 20 74 65 73 74 2e 64 62 0a 20 20 63 61  db2 test.db.  ca
0840: 74 63 68 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c  tchsql {.    SEL
0850: 45 43 54 20 2a 20 46 52 4f 4d 20 61 62 63 3b 0a  ECT * FROM abc;.
0860: 20 20 7d 20 64 62 32 0a 7d 20 7b 31 20 7b 64 61    } db2.} {1 {da
0870: 74 61 62 61 73 65 20 69 73 20 6c 6f 63 6b 65 64  tabase is locked
0880: 7d 7d 0a 64 6f 5f 74 65 73 74 20 6d 61 6c 6c 6f  }}.do_test mallo
0890: 63 35 2d 31 2e 33 20 7b 0a 20 20 23 20 41 67 61  c5-1.3 {.  # Aga
08a0: 69 6e 20 63 61 6c 6c 20 5b 73 71 6c 69 74 65 33  in call [sqlite3
08b0: 5f 72 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79 5d  _release_memory]
08c0: 20 77 68 65 6e 20 74 68 65 72 65 20 69 73 20 65   when there is e
08d0: 78 61 63 74 6c 79 20 6f 6e 65 20 75 6e 75 73 65  xactly one unuse
08e0: 64 20 70 61 67 65 20 0a 20 20 23 20 69 6e 20 74  d page .  # in t
08f0: 68 65 20 63 61 63 68 65 2e 20 54 68 65 20 73 61  he cache. The sa
0900: 6d 65 20 61 6d 6f 75 6e 74 20 6f 66 20 6d 65 6d  me amount of mem
0910: 6f 72 79 20 69 73 20 72 65 71 75 69 72 65 64 2c  ory is required,
0920: 20 62 75 74 20 6e 6f 20 6a 6f 75 72 6e 61 6c 2d   but no journal-
0930: 73 79 6e 63 0a 20 20 23 20 6f 72 20 65 78 63 6c  sync.  # or excl
0940: 75 73 69 76 65 20 6c 6f 63 6b 20 73 68 6f 75 6c  usive lock shoul
0950: 64 20 62 65 20 65 73 74 61 62 6c 69 73 68 65 64  d be established
0960: 2e 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  ..  execsql {.  
0970: 20 20 43 4f 4d 4d 49 54 3b 0a 20 20 20 20 42 45    COMMIT;.    BE
0980: 47 49 4e 3b 0a 20 20 20 20 53 45 4c 45 43 54 20  GIN;.    SELECT 
0990: 2a 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 7d 0a  * FROM abc;.  }.
09a0: 20 20 73 71 6c 69 74 65 33 5f 72 65 6c 65 61 73    sqlite3_releas
09b0: 65 5f 6d 65 6d 6f 72 79 0a 7d 20 24 3a 3a 70 67  e_memory.} $::pg
09c0: 61 6c 6c 6f 63 0a 64 6f 5f 74 65 73 74 20 6d 61  alloc.do_test ma
09d0: 6c 6c 6f 63 35 2d 31 2e 34 20 7b 0a 20 20 23 20  lloc5-1.4 {.  # 
09e0: 44 61 74 61 62 61 73 65 20 73 68 6f 75 6c 64 20  Database should 
09f0: 6e 6f 74 20 62 65 20 6c 6f 63 6b 65 64 20 74 68  not be locked th
0a00: 69 73 20 74 69 6d 65 2e 0a 20 20 63 61 74 63 68  is time..  catch
0a10: 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54  sql {.    SELECT
0a20: 20 2a 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 7d   * FROM abc;.  }
0a30: 20 64 62 32 0a 7d 20 7b 30 20 7b 7d 7d 0a 64 6f   db2.} {0 {}}.do
0a40: 5f 74 65 73 74 20 6d 61 6c 6c 6f 63 35 2d 31 2e  _test malloc5-1.
0a50: 35 20 7b 0a 20 20 23 20 4d 61 6e 69 70 75 6c 61  5 {.  # Manipula
0a60: 74 65 20 74 68 65 20 63 61 63 68 65 20 73 6f 20  te the cache so 
0a70: 74 68 61 74 20 69 74 20 63 6f 6e 74 61 69 6e 73  that it contains
0a80: 20 74 77 6f 20 75 6e 75 73 65 64 20 70 61 67 65   two unused page
0a90: 73 2e 20 4f 6e 65 20 72 65 71 75 69 72 65 73 20  s. One requires 
0aa0: 0a 20 20 23 20 61 20 6a 6f 75 72 6e 61 6c 2d 73  .  # a journal-s
0ab0: 79 6e 63 20 74 6f 20 66 72 65 65 2c 20 74 68 65  ync to free, the
0ac0: 20 6f 74 68 65 72 20 64 6f 65 73 20 6e 6f 74 2e   other does not.
0ad0: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
0ae0: 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 61   SELECT * FROM a
0af0: 62 63 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54  bc;.    CREATE T
0b00: 41 42 4c 45 20 64 65 66 28 64 2c 20 65 2c 20 66  ABLE def(d, e, f
0b10: 29 3b 0a 20 20 7d 0a 20 20 73 71 6c 69 74 65 33  );.  }.  sqlite3
0b20: 5f 72 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79 20  _release_memory 
0b30: 35 30 30 0a 7d 20 24 3a 3a 70 67 61 6c 6c 6f 63  500.} $::pgalloc
0b40: 0a 64 6f 5f 74 65 73 74 20 6d 61 6c 6c 6f 63 35  .do_test malloc5
0b50: 2d 31 2e 36 20 7b 0a 20 20 23 20 44 61 74 61 62  -1.6 {.  # Datab
0b60: 61 73 65 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62  ase should not b
0b70: 65 20 6c 6f 63 6b 65 64 20 74 68 69 73 20 74 69  e locked this ti
0b80: 6d 65 2e 20 54 68 65 20 61 62 6f 76 65 20 74 65  me. The above te
0b90: 73 74 20 63 61 73 65 20 6f 6e 6c 79 0a 20 20 23  st case only.  #
0ba0: 20 72 65 71 75 65 73 74 65 64 20 35 30 30 20 62   requested 500 b
0bb0: 79 74 65 73 20 6f 66 20 6d 65 6d 6f 72 79 2c 20  ytes of memory, 
0bc0: 77 68 69 63 68 20 63 61 6e 20 62 65 20 6f 62 74  which can be obt
0bd0: 61 69 6e 65 64 20 62 79 20 66 72 65 65 69 6e 67  ained by freeing
0be0: 20 74 68 65 20 70 61 67 65 0a 20 20 23 20 74 68   the page.  # th
0bf0: 61 74 20 64 6f 65 73 20 6e 6f 74 20 72 65 71 75  at does not requ
0c00: 69 72 65 20 61 6e 20 66 73 79 6e 63 28 29 2e 0a  ire an fsync()..
0c10: 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20 20    catchsql {.   
0c20: 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 61   SELECT * FROM a
0c30: 62 63 3b 0a 20 20 7d 20 64 62 32 0a 7d 20 7b 30  bc;.  } db2.} {0
0c40: 20 7b 7d 7d 0a 64 6f 5f 74 65 73 74 20 6d 61 6c   {}}.do_test mal
0c50: 6c 6f 63 35 2d 31 2e 37 20 7b 0a 20 20 23 20 52  loc5-1.7 {.  # R
0c60: 65 6c 65 61 73 65 20 61 6e 6f 74 68 65 72 20 35  elease another 5
0c70: 30 30 20 62 79 74 65 73 20 6f 66 20 6d 65 6d 6f  00 bytes of memo
0c80: 72 79 2e 20 54 68 69 73 20 74 69 6d 65 20 77 65  ry. This time we
0c90: 20 72 65 71 75 69 72 65 20 61 20 73 79 6e 63 28   require a sync(
0ca0: 29 2c 20 0a 20 20 23 20 73 6f 20 74 68 65 20 64  ), .  # so the d
0cb0: 61 74 61 62 61 73 65 20 66 69 6c 65 20 77 69 6c  atabase file wil
0cc0: 6c 20 62 65 20 6c 6f 63 6b 65 64 20 61 66 74 65  l be locked afte
0cd0: 72 77 61 72 64 73 2e 0a 20 20 73 71 6c 69 74 65  rwards..  sqlite
0ce0: 33 5f 72 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79  3_release_memory
0cf0: 20 35 30 30 0a 7d 20 24 3a 3a 70 67 61 6c 6c 6f   500.} $::pgallo
0d00: 63 0a 64 6f 5f 74 65 73 74 20 6d 61 6c 6c 6f 63  c.do_test malloc
0d10: 35 2d 31 2e 38 20 7b 0a 20 20 63 61 74 63 68 73  5-1.8 {.  catchs
0d20: 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20  ql {.    SELECT 
0d30: 2a 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 7d 20  * FROM abc;.  } 
0d40: 64 62 32 0a 7d 20 7b 31 20 7b 64 61 74 61 62 61  db2.} {1 {databa
0d50: 73 65 20 69 73 20 6c 6f 63 6b 65 64 7d 7d 0a 64  se is locked}}.d
0d60: 6f 5f 74 65 73 74 20 6d 61 6c 6c 6f 63 35 2d 31  o_test malloc5-1
0d70: 2e 39 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b  .9 {.  execsql {
0d80: 0a 20 20 20 20 43 4f 4d 4d 49 54 3b 0a 20 20 7d  .    COMMIT;.  }
0d90: 0a 7d 20 7b 7d 0a 0a 64 6f 5f 74 65 73 74 20 6d  .} {}..do_test m
0da0: 61 6c 6c 6f 63 35 2d 32 2e 31 20 7b 0a 20 20 23  alloc5-2.1 {.  #
0db0: 20 50 75 74 20 73 6f 6d 65 20 64 61 74 61 20 69   Put some data i
0dc0: 6e 20 74 61 62 6c 65 73 20 61 62 63 20 61 6e 64  n tables abc and
0dd0: 20 64 65 66 2e 20 42 6f 74 68 20 74 61 62 6c 65   def. Both table
0de0: 73 20 61 72 65 20 73 74 69 6c 6c 20 77 68 6f 6c  s are still whol
0df0: 6c 79 20 0a 20 20 23 20 63 6f 6e 74 61 69 6e 65  ly .  # containe
0e00: 64 20 77 69 74 68 69 6e 20 74 68 65 69 72 20 72  d within their r
0e10: 6f 6f 74 20 70 61 67 65 73 2e 0a 20 20 65 78 65  oot pages..  exe
0e20: 63 73 71 6c 20 7b 0a 20 20 20 20 49 4e 53 45 52  csql {.    INSER
0e30: 54 20 49 4e 54 4f 20 61 62 63 20 56 41 4c 55 45  T INTO abc VALUE
0e40: 53 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20  S(1, 2, 3);.    
0e50: 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20  INSERT INTO abc 
0e60: 56 41 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b  VALUES(4, 5, 6);
0e70: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
0e80: 20 64 65 66 20 56 41 4c 55 45 53 28 37 2c 20 38   def VALUES(7, 8
0e90: 2c 20 39 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  , 9);.    INSERT
0ea0: 20 49 4e 54 4f 20 64 65 66 20 56 41 4c 55 45 53   INTO def VALUES
0eb0: 28 31 30 2c 31 31 2c 31 32 29 3b 0a 20 20 7d 0a  (10,11,12);.  }.
0ec0: 7d 20 7b 7d 0a 64 6f 5f 74 65 73 74 20 6d 61 6c  } {}.do_test mal
0ed0: 6c 6f 63 35 2d 32 2e 32 20 7b 0a 20 20 23 20 4c  loc5-2.2 {.  # L
0ee0: 6f 61 64 20 74 68 65 20 72 6f 6f 74 2d 70 61 67  oad the root-pag
0ef0: 65 20 66 6f 72 20 74 61 62 6c 65 20 64 65 66 20  e for table def 
0f00: 69 6e 74 6f 20 74 68 65 20 63 61 63 68 65 2e 20  into the cache. 
0f10: 54 68 65 6e 20 71 75 65 72 79 20 74 61 62 6c 65  Then query table
0f20: 20 61 62 63 2e 20 0a 20 20 23 20 48 61 6c 66 77   abc. .  # Halfw
0f30: 61 79 20 74 68 72 6f 75 67 68 20 74 68 65 20 71  ay through the q
0f40: 75 65 72 79 20 63 61 6c 6c 20 73 71 6c 69 74 65  uery call sqlite
0f50: 33 5f 72 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79  3_release_memory
0f60: 28 29 2e 20 54 68 65 20 67 6f 61 6c 20 6f 66 20  (). The goal of 
0f70: 74 68 69 73 0a 20 20 23 20 74 65 73 74 20 69 73  this.  # test is
0f80: 20 74 6f 20 6d 61 6b 65 20 73 75 72 65 20 77 65   to make sure we
0f90: 20 64 6f 6e 27 74 20 66 72 65 65 20 70 61 67 65   don't free page
0fa0: 73 20 74 68 61 74 20 61 72 65 20 69 6e 20 75 73  s that are in us
0fb0: 65 20 28 73 70 65 63 69 66 69 63 61 6c 6c 79 2c  e (specifically,
0fc0: 20 0a 20 20 23 20 74 68 65 20 72 6f 6f 74 20 6f   .  # the root o
0fd0: 66 20 74 61 62 6c 65 20 61 62 63 29 2e 0a 20 20  f table abc)..  
0fe0: 73 65 74 20 6e 52 65 6c 65 61 73 65 20 30 0a 20  set nRelease 0. 
0ff0: 20 65 78 65 63 73 71 6c 20 7b 20 0a 20 20 20 20   execsql { .    
1000: 42 45 47 49 4e 3b 0a 20 20 20 20 53 45 4c 45 43  BEGIN;.    SELEC
1010: 54 20 2a 20 46 52 4f 4d 20 64 65 66 3b 0a 20 20  T * FROM def;.  
1020: 7d 0a 20 20 73 65 74 20 64 61 74 61 20 5b 6c 69  }.  set data [li
1030: 73 74 5d 0a 20 20 64 62 20 65 76 61 6c 20 7b 53  st].  db eval {S
1040: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 61 62 63  ELECT * FROM abc
1050: 7d 20 7b 0a 20 20 20 20 69 6e 63 72 20 6e 52 65  } {.    incr nRe
1060: 6c 65 61 73 65 20 5b 73 71 6c 69 74 65 33 5f 72  lease [sqlite3_r
1070: 65 6c 65 61 73 65 5f 6d 65 6d 6f 72 79 5d 0a 20  elease_memory]. 
1080: 20 20 20 6c 61 70 70 65 6e 64 20 64 61 74 61 20     lappend data 
1090: 24 61 20 24 62 20 24 63 0a 20 20 7d 0a 20 20 65  $a $b $c.  }.  e
10a0: 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 43 4f 4d  xecsql {.    COM
10b0: 4d 49 54 3b 0a 20 20 7d 0a 20 20 6c 69 73 74 20  MIT;.  }.  list 
10c0: 24 6e 52 65 6c 65 61 73 65 20 24 64 61 74 61 0a  $nRelease $data.
10d0: 7d 20 5b 6c 69 73 74 20 24 70 67 61 6c 6c 6f 63  } [list $pgalloc
10e0: 20 5b 6c 69 73 74 20 31 20 32 20 33 20 34 20 35   [list 1 2 3 4 5
10f0: 20 36 5d 5d 0a 0a 64 6f 5f 74 65 73 74 20 6d 61   6]]..do_test ma
1100: 6c 6c 6f 63 35 2d 33 2e 31 20 7b 0a 20 20 23 20  lloc5-3.1 {.  # 
1110: 53 69 6d 70 6c 65 20 74 65 73 74 20 74 6f 20 73  Simple test to s
1120: 68 6f 77 20 74 68 61 74 20 69 66 20 74 77 6f 20  how that if two 
1130: 70 61 67 65 72 73 20 61 72 65 20 6f 70 65 6e 65  pagers are opene
1140: 64 20 66 72 6f 6d 20 77 69 74 68 69 6e 20 74 68  d from within th
1150: 69 73 0a 20 20 23 20 74 68 72 65 61 64 2c 20 6d  is.  # thread, m
1160: 65 6d 6f 72 79 20 69 73 20 66 72 65 65 64 20 66  emory is freed f
1170: 72 6f 6d 20 62 6f 74 68 20 77 68 65 6e 20 73 71  rom both when sq
1180: 6c 69 74 65 33 5f 72 65 6c 65 61 73 65 5f 6d 65  lite3_release_me
1190: 6d 6f 72 79 28 29 20 69 73 0a 20 20 23 20 63 61  mory() is.  # ca
11a0: 6c 6c 65 64 2e 0a 20 20 65 78 65 63 73 71 6c 20  lled..  execsql 
11b0: 7b 0a 20 20 20 20 42 45 47 49 4e 3b 0a 20 20 20  {.    BEGIN;.   
11c0: 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 61   SELECT * FROM a
11d0: 62 63 3b 0a 20 20 7d 0a 20 20 65 78 65 63 73 71  bc;.  }.  execsq
11e0: 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 2a  l {.    SELECT *
11f0: 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73   FROM sqlite_mas
1200: 74 65 72 3b 0a 20 20 20 20 42 45 47 49 4e 3b 0a  ter;.    BEGIN;.
1210: 20 20 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f      SELECT * FRO
1220: 4d 20 64 65 66 3b 0a 20 20 7d 20 64 62 32 0a 20  M def;.  } db2. 
1230: 20 73 71 6c 69 74 65 33 5f 72 65 6c 65 61 73 65   sqlite3_release
1240: 5f 6d 65 6d 6f 72 79 0a 7d 20 5b 65 78 70 72 20  _memory.} [expr 
1250: 24 3a 3a 70 67 61 6c 6c 6f 63 20 2a 20 32 5d 0a  $::pgalloc * 2].
1260: 64 6f 5f 74 65 73 74 20 6d 61 6c 6c 6f 63 35 2d  do_test malloc5-
1270: 33 2e 32 20 7b 0a 20 20 63 6f 6e 63 61 74 20 5c  3.2 {.  concat \
1280: 0a 20 20 20 20 5b 65 78 65 63 73 71 6c 20 7b 53  .    [execsql {S
1290: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 61 62 63  ELECT * FROM abc
12a0: 3b 20 43 4f 4d 4d 49 54 7d 5d 20 5c 0a 20 20 20  ; COMMIT}] \.   
12b0: 20 5b 65 78 65 63 73 71 6c 20 7b 53 45 4c 45 43   [execsql {SELEC
12c0: 54 20 2a 20 46 52 4f 4d 20 64 65 66 3b 20 43 4f  T * FROM def; CO
12d0: 4d 4d 49 54 7d 20 64 62 32 5d 0a 7d 20 7b 31 20  MMIT} db2].} {1 
12e0: 32 20 33 20 34 20 35 20 36 20 37 20 38 20 39 20  2 3 4 5 6 7 8 9 
12f0: 31 30 20 31 31 20 31 32 7d 0a 0a 64 62 32 20 63  10 11 12}..db2 c
1300: 6c 6f 73 65 0a 73 71 6c 69 74 65 5f 6d 61 6c 6c  lose.sqlite_mall
1310: 6f 63 5f 6f 75 74 73 74 61 6e 64 69 6e 67 20 2d  oc_outstanding -
1320: 63 6c 65 61 72 6d 61 78 62 79 74 65 73 0a 0a 23  clearmaxbytes..#
1330: 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 74   The following t
1340: 77 6f 20 74 65 73 74 20 63 61 73 65 73 20 65 61  wo test cases ea
1350: 63 68 20 65 78 65 63 75 74 65 20 61 20 74 72 61  ch execute a tra
1360: 6e 73 61 63 74 69 6f 6e 20 69 6e 20 77 68 69 63  nsaction in whic
1370: 68 20 0a 23 20 31 30 30 30 30 20 72 6f 77 73 20  h .# 10000 rows 
1380: 61 72 65 20 69 6e 73 65 72 74 65 64 20 69 6e 74  are inserted int
1390: 6f 20 74 61 62 6c 65 20 61 62 63 2e 20 54 68 65  o table abc. The
13a0: 20 66 69 72 73 74 20 74 65 73 74 20 63 61 73 65   first test case
13b0: 20 69 73 20 75 73 65 64 0a 23 20 74 6f 20 65 6e   is used.# to en
13c0: 73 75 72 65 20 74 68 61 74 20 6d 6f 72 65 20 74  sure that more t
13d0: 68 61 6e 20 31 4d 42 20 6f 66 20 64 79 6e 61 6d  han 1MB of dynam
13e0: 69 63 20 6d 65 6d 6f 72 79 20 69 73 20 75 73 65  ic memory is use
13f0: 64 20 74 6f 20 70 65 72 66 6f 72 6d 0a 23 20 74  d to perform.# t
1400: 68 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 2e 20  he transaction. 
1410: 0a 23 0a 23 20 54 68 65 20 73 65 63 6f 6e 64 20  .#.# The second 
1420: 74 65 73 74 20 63 61 73 65 20 73 65 74 73 20 74  test case sets t
1430: 68 65 20 22 73 6f 66 74 2d 68 65 61 70 2d 6c 69  he "soft-heap-li
1440: 6d 69 74 22 20 74 6f 20 31 30 30 2c 30 30 30 20  mit" to 100,000 
1450: 62 79 74 65 73 20 28 30 2e 31 20 4d 42 29 0a 23  bytes (0.1 MB).#
1460: 20 61 6e 64 20 74 65 73 74 73 20 74 6f 20 73 65   and tests to se
1470: 65 20 74 68 61 74 20 74 68 69 73 20 6c 69 6d 69  e that this limi
1480: 74 20 69 73 20 6e 6f 74 20 65 78 63 65 65 64 65  t is not exceede
1490: 64 20 61 74 20 61 6e 79 20 70 6f 69 6e 74 20 64  d at any point d
14a0: 75 72 69 6e 67 20 0a 23 20 74 72 61 6e 73 61 63  uring .# transac
14b0: 74 69 6f 6e 20 65 78 65 63 75 74 69 6f 6e 2e 0a  tion execution..
14c0: 23 0a 23 20 42 65 66 6f 72 65 20 65 78 65 63 75  #.# Before execu
14d0: 74 69 6e 67 20 6d 61 6c 6c 6f 63 35 2d 34 2e 2a  ting malloc5-4.*
14e0: 20 77 65 20 73 61 76 65 20 74 68 65 20 76 61 6c   we save the val
14f0: 75 65 20 6f 66 20 74 68 65 20 63 75 72 72 65 6e  ue of the curren
1500: 74 20 73 6f 66 74 20 68 65 61 70 20 0a 23 20 6c  t soft heap .# l
1510: 69 6d 69 74 20 69 6e 20 76 61 72 69 61 62 6c 65  imit in variable
1520: 20 3a 3a 73 6f 66 74 5f 6c 69 6d 69 74 2e 20 54   ::soft_limit. T
1530: 68 65 20 6f 72 69 67 69 6e 61 6c 20 76 61 6c 75  he original valu
1540: 65 20 69 73 20 72 65 73 74 6f 72 65 64 20 61 66  e is restored af
1550: 74 65 72 20 0a 23 20 72 75 6e 6e 69 6e 67 20 74  ter .# running t
1560: 68 65 20 74 65 73 74 73 2e 0a 23 0a 73 65 74 20  he tests..#.set 
1570: 3a 3a 73 6f 66 74 5f 6c 69 6d 69 74 20 5b 73 71  ::soft_limit [sq
1580: 6c 69 74 65 33 5f 73 6f 66 74 5f 68 65 61 70 5f  lite3_soft_heap_
1590: 6c 69 6d 69 74 20 2d 31 5d 0a 64 6f 5f 74 65 73  limit -1].do_tes
15a0: 74 20 6d 61 6c 6c 6f 63 35 2d 34 2e 31 20 7b 0a  t malloc5-4.1 {.
15b0: 20 20 65 78 65 63 73 71 6c 20 7b 42 45 47 49 4e    execsql {BEGIN
15c0: 3b 7d 0a 20 20 65 78 65 63 73 71 6c 20 7b 44 45  ;}.  execsql {DE
15d0: 4c 45 54 45 20 46 52 4f 4d 20 61 62 63 3b 7d 0a  LETE FROM abc;}.
15e0: 20 20 66 6f 72 20 7b 73 65 74 20 69 20 30 7d 20    for {set i 0} 
15f0: 7b 24 69 20 3c 20 31 30 30 30 30 7d 20 7b 69 6e  {$i < 10000} {in
1600: 63 72 20 69 7d 20 7b 0a 20 20 20 20 65 78 65 63  cr i} {.    exec
1610: 73 71 6c 20 22 49 4e 53 45 52 54 20 49 4e 54 4f  sql "INSERT INTO
1620: 20 61 62 63 20 56 41 4c 55 45 53 28 24 69 2c 20   abc VALUES($i, 
1630: 24 69 2c 20 27 5b 73 74 72 69 6e 67 20 72 65 70  $i, '[string rep
1640: 65 61 74 20 58 20 31 30 30 5d 27 29 3b 22 0a 20  eat X 100]');". 
1650: 20 7d 0a 20 20 65 78 65 63 73 71 6c 20 7b 43 4f   }.  execsql {CO
1660: 4d 4d 49 54 3b 7d 0a 20 20 73 65 74 20 3a 3a 6e  MMIT;}.  set ::n
1670: 4d 61 78 42 79 74 65 73 20 5b 73 71 6c 69 74 65  MaxBytes [sqlite
1680: 5f 6d 61 6c 6c 6f 63 5f 6f 75 74 73 74 61 6e 64  _malloc_outstand
1690: 69 6e 67 20 2d 6d 61 78 62 79 74 65 73 5d 0a 20  ing -maxbytes]. 
16a0: 20 69 66 20 7b 24 3a 3a 6e 4d 61 78 42 79 74 65   if {$::nMaxByte
16b0: 73 3d 3d 22 22 7d 20 7b 73 65 74 20 3a 3a 6e 4d  s==""} {set ::nM
16c0: 61 78 42 79 74 65 73 20 31 30 30 30 30 30 31 7d  axBytes 1000001}
16d0: 0a 20 20 65 78 70 72 20 24 3a 3a 6e 4d 61 78 42  .  expr $::nMaxB
16e0: 79 74 65 73 20 3e 20 31 30 30 30 30 30 30 0a 7d  ytes > 1000000.}
16f0: 20 7b 31 7d 0a 64 6f 5f 74 65 73 74 20 6d 61 6c   {1}.do_test mal
1700: 6c 6f 63 35 2d 34 2e 32 20 7b 0a 20 20 73 71 6c  loc5-4.2 {.  sql
1710: 69 74 65 33 5f 72 65 6c 65 61 73 65 5f 6d 65 6d  ite3_release_mem
1720: 6f 72 79 0a 20 20 73 71 6c 69 74 65 5f 6d 61 6c  ory.  sqlite_mal
1730: 6c 6f 63 5f 6f 75 74 73 74 61 6e 64 69 6e 67 20  loc_outstanding 
1740: 2d 63 6c 65 61 72 6d 61 78 62 79 74 65 73 0a 20  -clearmaxbytes. 
1750: 20 73 71 6c 69 74 65 33 5f 73 6f 66 74 5f 68 65   sqlite3_soft_he
1760: 61 70 5f 6c 69 6d 69 74 20 31 30 30 30 30 30 0a  ap_limit 100000.
1770: 20 20 65 78 65 63 73 71 6c 20 7b 42 45 47 49 4e    execsql {BEGIN
1780: 3b 7d 0a 20 20 66 6f 72 20 7b 73 65 74 20 69 20  ;}.  for {set i 
1790: 30 7d 20 7b 24 69 20 3c 20 31 30 30 30 30 7d 20  0} {$i < 10000} 
17a0: 7b 69 6e 63 72 20 69 7d 20 7b 0a 20 20 20 20 65  {incr i} {.    e
17b0: 78 65 63 73 71 6c 20 22 49 4e 53 45 52 54 20 49  xecsql "INSERT I
17c0: 4e 54 4f 20 61 62 63 20 56 41 4c 55 45 53 28 24  NTO abc VALUES($
17d0: 69 2c 20 24 69 2c 20 27 5b 73 74 72 69 6e 67 20  i, $i, '[string 
17e0: 72 65 70 65 61 74 20 58 20 31 30 30 5d 27 29 3b  repeat X 100]');
17f0: 22 0a 20 20 7d 0a 20 20 65 78 65 63 73 71 6c 20  ".  }.  execsql 
1800: 7b 43 4f 4d 4d 49 54 3b 7d 0a 20 20 73 65 74 20  {COMMIT;}.  set 
1810: 3a 3a 6e 4d 61 78 42 79 74 65 73 20 5b 73 71 6c  ::nMaxBytes [sql
1820: 69 74 65 5f 6d 61 6c 6c 6f 63 5f 6f 75 74 73 74  ite_malloc_outst
1830: 61 6e 64 69 6e 67 20 2d 6d 61 78 62 79 74 65 73  anding -maxbytes
1840: 5d 0a 20 20 69 66 20 7b 24 3a 3a 6e 4d 61 78 42  ].  if {$::nMaxB
1850: 79 74 65 73 3d 3d 22 22 7d 20 7b 73 65 74 20 3a  ytes==""} {set :
1860: 3a 6e 4d 61 78 42 79 74 65 73 20 30 7d 0a 20 20  :nMaxBytes 0}.  
1870: 65 78 70 72 20 24 3a 3a 6e 4d 61 78 42 79 74 65  expr $::nMaxByte
1880: 73 20 3c 3d 20 31 30 30 30 30 30 0a 7d 20 7b 31  s <= 100000.} {1
1890: 7d 0a 64 6f 5f 74 65 73 74 20 6d 61 6c 6c 6f 63  }.do_test malloc
18a0: 35 2d 34 2e 33 20 7b 0a 20 20 23 20 43 68 65 63  5-4.3 {.  # Chec
18b0: 6b 20 74 68 61 74 20 74 68 65 20 63 6f 6e 74 65  k that the conte
18c0: 6e 74 20 6f 66 20 74 61 62 6c 65 20 61 62 63 20  nt of table abc 
18d0: 69 73 20 61 74 20 6c 65 61 73 74 20 72 6f 75 67  is at least roug
18e0: 68 6c 79 20 61 73 20 65 78 70 65 63 74 65 64 2e  hly as expected.
18f0: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
1900: 20 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 2a 29   SELECT count(*)
1910: 2c 20 73 75 6d 28 61 29 2c 20 73 75 6d 28 62 29  , sum(a), sum(b)
1920: 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 7d 0a 7d   FROM abc;.  }.}
1930: 20 5b 6c 69 73 74 20 32 30 30 30 30 20 5b 65 78   [list 20000 [ex
1940: 70 72 20 69 6e 74 28 32 30 30 30 30 2e 30 20 2a  pr int(20000.0 *
1950: 20 34 39 39 39 2e 35 29 5d 20 5b 65 78 70 72 20   4999.5)] [expr 
1960: 69 6e 74 28 32 30 30 30 30 2e 30 20 2a 20 34 39  int(20000.0 * 49
1970: 39 39 2e 35 29 5d 5d 0a 0a 23 20 52 65 73 74 6f  99.5)]]..# Resto
1980: 72 65 20 74 68 65 20 73 6f 66 74 20 68 65 61 70  re the soft heap
1990: 20 6c 69 6d 69 74 2e 0a 73 71 6c 69 74 65 33 5f   limit..sqlite3_
19a0: 73 6f 66 74 5f 68 65 61 70 5f 6c 69 6d 69 74 20  soft_heap_limit 
19b0: 24 3a 3a 73 6f 66 74 5f 6c 69 6d 69 74 0a 66 69  $::soft_limit.fi
19c0: 6e 69 73 68 5f 74 65 73 74 0a 0a 63 61 74 63 68  nish_test..catch
19d0: 20 7b 64 62 20 63 6c 6f 73 65 7d 0a 0a            {db close}..