Comment 5 for bug 1446962

Revision history for this message
Pascal J. Bourguignon (pjb-informatimago) wrote :

Here is another use case. Basically: allocate a TEMPORARY string of 200M characters, (it's not referenced after the form is evaluated, not even in *); then allocate a vector of 200M octets. There is no exhaustion, because the 200M character string is garbage and it should be collected SILENTLY!

[pjb@despina :0.0 ~]$ sbcl --no-userinit
This is SBCL 1.4.1, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (let ((string (make-string (* 200 1024 1024) :initial-element #\a))
        (pattern "07123E1F482356C415F684407A3B8723E10B2CBBC0B8FCD6282C49D37C9C1ABC"))
     (replace string pattern :start1 (- (length string) (length pattern)))
     (time (search pattern string)))

Evaluation took:
  2.012 seconds of real time
  2.010401 seconds of total run time (2.007339 user, 0.003062 system)
  99.90% CPU
  8,065,801,078 processor cycles
  0 bytes consed

209715136
* (let ((string (make-array (* 200 1024 1024) :element-type '(unsigned-byte 8) :initial-element (char-code #\a)))
        (pattern (map '(vector (unsigned-byte 8)) 'char-code "07123E1F482356C415F684407A3B8723E10B2CBBC0B8FCD6282C49D37C9C1ABC")))
    (replace string pattern :start1 (- (length string) (length pattern)))
    (time (search pattern string)))
Heap exhausted during allocation: 204046336 bytes available, 209715216 requested.
 Gen StaPg UbSta LaSta Boxed Unbox LB LUB !move Alloc Waste Trig WP GCs Mem-age
   0: 26538 0 0 45 0 0 0 0 1405408 69152 10737418 0 0 0.0000
   1: 26524 26512 0 19 2 0 25601 25608 839364224 217472 2000000 7 0 0.0000
   2: 0 0 0 0 0 0 0 0 0 0 2000000 0 0 0.0000
   3: 0 0 0 0 0 0 0 0 0 0 2000000 0 0 0.0000
   4: 0 0 0 0 0 0 0 0 0 0 2000000 0 0 0.0000
   5: 0 0 0 0 0 0 0 0 0 0 2000000 0 0 0.0000
   6: 0 0 0 570 304 0 0 0 27930768 708464 2000000 553 0 0.0000
   7: 875 876 0 0 0 0 0 0 0 0 2000000 0 0 0.0000
   Total bytes allocated = 868700400
   Dynamic-space-size bytes = 1073741824
GC control variables:
   *GC-INHIBIT* = false
   *GC-PENDING* = true
   *STOP-FOR-GC-PENDING* = false

debugger invoked on a SB-KERNEL::HEAP-EXHAUSTED-ERROR in thread
#<THREAD "main thread" RUNNING {1001B50083}>:
  Heap exhausted (no more space for allocation).
204046336 bytes available, 209715216 requested.

PROCEED WITH CAUTION.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-KERNEL::HEAP-EXHAUSTED-ERROR 102023168 104857608)
0] :a

* (let ((string (make-array (* 200 1024 1024) :element-type '(unsigned-byte 8) :initial-element (char-code #\a)))
        (pattern (map '(vector (unsigned-byte 8)) 'char-code "07123E1F482356C415F684407A3B8723E10B2CBBC0B8FCD6282C49D37C9C1ABC")))
    (replace string pattern :start1 (- (length string) (length pattern)))
    (time (search pattern string)))

Evaluation took:
  1.895 seconds of real time
  1.889737 seconds of total run time (1.885292 user, 0.004445 system)
  99.74% CPU
  7,595,260,962 processor cycles
  0 bytes consed

209715136
* (quit)
[pjb@despina :0.0 ~]$