/ Check-in [028ec36c]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem in test script malloc5.test. (CVS 4455)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 028ec36c71d6ac43c8f1cda77578d844c6955f68
User & Date: danielk1977 2007-10-03 09:43:55
Context
2007-10-03
15:02
Add a test case to malloc.test. (CVS 4456) check-in: 7d3f0b14 user: danielk1977 tags: trunk
09:43
Fix a problem in test script malloc5.test. (CVS 4455) check-in: 028ec36c user: danielk1977 tags: trunk
08:46
Add automatic recovery from the pager "error-state". Also add a new error code - SQLITE_IOERR_NOMEM. (CVS 4454) check-in: 12eca32a user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/malloc5.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
210
211
212
213
214
215
216
















217
218
219
220
221
222
223
224
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains test cases focused on the two memory-management APIs, 
# sqlite3_soft_heap_limit() and sqlite3_release_memory().
#
# $Id: malloc5.test,v 1.16 2007/09/03 16:12:10 drh Exp $

#---------------------------------------------------------------------------
# NOTES ON EXPECTED BEHAVIOUR
#
#---------------------------------------------------------------------------


................................................................................
  execsql {BEGIN;}
  for {set i 0} {$i < 10000} {incr i} {
    execsql "INSERT INTO abc VALUES($i, $i, '[string repeat X 100]');"
  }
  execsql {COMMIT;}
  set nMaxBytes [sqlite3_memory_highwater 1]
  puts -nonewline " (Highwater mark: $nMaxBytes) "
















  expr $nMaxBytes <= 100000
} {1}
do_test malloc5-4.3 {
  # Check that the content of table abc is at least roughly as expected.
  execsql {
    SELECT count(*), sum(a), sum(b) FROM abc;
  }
} [list 20000 [expr int(20000.0 * 4999.5)] [expr int(20000.0 * 4999.5)]]







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains test cases focused on the two memory-management APIs, 
# sqlite3_soft_heap_limit() and sqlite3_release_memory().
#
# $Id: malloc5.test,v 1.17 2007/10/03 09:43:55 danielk1977 Exp $

#---------------------------------------------------------------------------
# NOTES ON EXPECTED BEHAVIOUR
#
#---------------------------------------------------------------------------


................................................................................
  execsql {BEGIN;}
  for {set i 0} {$i < 10000} {incr i} {
    execsql "INSERT INTO abc VALUES($i, $i, '[string repeat X 100]');"
  }
  execsql {COMMIT;}
  set nMaxBytes [sqlite3_memory_highwater 1]
  puts -nonewline " (Highwater mark: $nMaxBytes) "

  # We used to test ($nMaxBytes<100000), because the soft-heap-limit is
  # 100000 bytes. But if an allocation that will exceed the 
  # soft-heap-limit is requested from within the only pager instance in 
  # the system, then there is no way to free memory and the limit has to 
  # be exceeded. An exception is memory allocated to store actual page
  # data (the code contains a special case for this).
  #
  # This is not a problem because all allocations apart from those
  # used to store cached page data are both small and transient.
  #
  # Summary: the actual high-water mark for memory usage may be slightly 
  # higher than the soft-heap-limit. The specific allocations that cause
  # the problem are the calls to sqlite3_malloc() inserted into selected
  # sqlite3OsXXX() functions in test builds.
  #
  expr $nMaxBytes <= 100100
} {1}
do_test malloc5-4.3 {
  # Check that the content of table abc is at least roughly as expected.
  execsql {
    SELECT count(*), sum(a), sum(b) FROM abc;
  }
} [list 20000 [expr int(20000.0 * 4999.5)] [expr int(20000.0 * 4999.5)]]