{"record":{"id":"3b46b5d595b89b6e","repo":"ben-manes/caffeine","slug":"fail-to-alloc-memory-n","errorCode":null,"errorMessage":"Fail to alloc memory!\\n","messagePattern":"Fail to alloc memory!\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"simulator/src/main/resources/com/github/benmanes/caffeine/cache/simulator/parser/lirs/lirs.c","lineNumber":101,"sourceCode":"    page_tbl[i].LIRS_prev = NULL;\n\n    page_tbl[i].HIR_rsd_next = NULL;\n    page_tbl[i].HIR_rsd_prev = NULL;\n\n    page_tbl[i].recency = S_STACK_OUT;\n  }\n\n  LRU_list_head = NULL;\n  LRU_list_tail = NULL;\n\n  HIR_list_head = NULL;\n  HIR_list_tail = NULL;\n\n  LIR_LRU_block_ptr = NULL;\n\n  evict_list = (unsigned long *)calloc(EVICT_LIST_SIZE, sizeof(unsigned long));\n  if (!evict_list) {\n    fprintf(stderr, \"Fail to alloc memory!\\n\");\n    exit(1);\n  }\n  evict_max_idx = EVICT_LIST_SIZE;\n  evict_cur_idx = 0;\n\n  /* the memory ratio for hirs is 1% */\n  HIR_block_portion_limit = (unsigned long)(HIR_RATE/100.0*mem_size);\n  if (HIR_block_portion_limit < LOWEST_HG_NUM)\n    HIR_block_portion_limit = LOWEST_HG_NUM;\n\n  LIRS_Repl(trace_fp);\n\n  printf(\"\\n\");\n  printf(\" Memory size                        = %ld\\n\", mem_size);\n//  printf(\" Llirs (record size for LIRS stack) = %ld\\n\", cur_lir_S_len);\n  printf(\" Lhirs (cache size for HIR blocks)  = %ld\\n\", HIR_block_portion_limit);\n  printf(\" Final blocks refs                  = %ld\\n\", total_pg_refs);\n  printf(\" Final number of misses             = %ld \\n\", num_pg_flt);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/ben-manes/caffeine/blob/9da6581ee366aa63c51e0dc96692d02f9c29ccff/simulator/src/main/resources/com/github/benmanes/caffeine/cache/simulator/parser/lirs/lirs.c#L83-L119","documentation":"This is a C runtime check in the bundled LIRS trace replay tool (lirs.c, used by the simulator's LIRS trace converter). At initialization it calloc's the evict_list array (EVICT_LIST_SIZE unsigned longs) that records the eviction sequence; if calloc returns NULL the process prints this message and exits with status 1. It means the process could not allocate the (small, fixed-size) eviction bookkeeping buffer, i.e. the heap is exhausted or the process hit an allocation limit.","triggerScenarios":"Running the LIRS parser/replayer when the process has exhausted its address space or memory quota; ulimit -v restrictions; a tiny embedded/container environment with a hard memory cap; extremely constrained memory after the caller has already allocated the page tables.","commonSituations":"Docker/Kubernetes containers with low memory limits running the simulator trace conversion; CI jobs with ulimit -v set; 32-bit builds where address space runs out; OOM conditions on the host.","solutions":["Free memory or raise the container/ulimit limit and rerun the trace conversion","Check with dmesg/top whether the host was OOM; if so, run on a machine with more RAM or process a smaller trace","If self-compiling, verify EVICT_LIST_SIZE was not accidentally set huge by local modifications"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# before running the LIRS conversion, confirm headroom\nrequired=$((EVICT_LIST_SIZE * 8))\navail=$(free -b | awk '/Mem:/{print $7}')\n[ \"$avail\" -gt \"$((required * 4))\" ] || { echo \"not enough memory\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run trace conversion in containers with memory limits sized to the trace (eviction log dominates memory)","Check free memory before launching long replays","Avoid 32-bit builds for large traces","Process oversized traces in chunks"],"tags":["c","memory","allocator","simulator","lirs","exit-on-error"],"backgroundTag":null,"analyzedSha":"9da6581ee366aa63c51e0dc96692d02f9c29ccff","analyzedAt":"2026-08-14T14:45:28.147Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}