Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scbl exception Heap exhausted during garbage collection

When our application run for some time, for example , run for hours, the sbcl will throw heap exhausted exception.

Heap exhausted during garbage collection: 1968 bytes available, 2128 requested.
 Gen StaPg UbSta LaSta LUbSt Boxed Unboxed LB   LUB  !move  Alloc  Waste   Trig    WP  GCs Mem-age
   0:     0     0     0     0     0     0     0     0     0        0     0  5368709    0   0  0.0000
   1:     0     0     0     0     0     0     0     0     0        0     0  5368709    0   0  0.0000
   2:     0     0     0     0     0     0     0     0     0        0     0  5368709    0   0  0.0000
   3: 101912 101913     0     0 19362 20536     0     0     0 162867456 554752 102714709    0   1  1.4405
   4: 130984 131071     0     0 29240 18868     0     0    25 191196152 5854216 128537781 14785   1  0.6442
   5: 75511 81013     0     0 16567 17127    92    99    36 132974568 5818392  2000000 16565   0  0.0000
   6:     0     0     0     0  7949  1232     0     0     0 37605376     0  2000000 7766   0  0.0000
   Total bytes allocated    = 524643552
   Dynamic-space-size bytes = 536870912
GC control variables:
   *GC-INHIBIT* = true
   *GC-PENDING* = true
   *STOP-FOR-GC-PENDING* = false
fatal error encountered in SBCL pid 3281(tid 3067845440):
Heap exhausted, game over.

Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb> 

Any suggestion?

like image 429
Amitabha Avatar asked Aug 05 '15 01:08

Amitabha


1 Answers

SBCL does not allow you to allocate more than (sb-ext:dynamic-space-size) bytes on the heap. Here you have a 512MB default size (536870912 bytes) and the Lisp program already was using nearly that amount when it attempted to make another allocation.

You could double the amount of heap space available to 1024MB by starting SBCL with --dynamic-space-size 1024. However, as several comments point out, there may be a memory leak, where objects are referenced somehow proportional to the time that the system has been running, so this will offer only a temporary respite.

The (room t) standard Common Lisp function call might help debug this, if you call it periodically.

More advanced code like this http://dwim.hu/darcsweb/darcsweb.cgi?r=HEAD%20hu.dwim.debug;a=headblob;f=/source/path-to-root.lisp#l42 which delves into the SB-VM internal map of allocations could shed more light, and SBCL has a statistical profiler, http://www.sbcl.org/manual/#Statistical-Profiler that supports reporting on allocations too.

like image 136
John Fremlin Avatar answered Oct 13 '22 02:10

John Fremlin