-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling Gc.major_slice stalls gc'ing #7813
Comments
Comment author: anders.fugmann test file leak.ml does not exhibit the problem as it does a minor heap allocation also. Uploaded leak2.ml which does expose the bug. |
Comment author: @ivg I've looked into it and it looks like a race condition, since https://discuss.ocaml.org/t/bug-in-gc-major-slice/2174/2?u=ivg |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
The issue is still clearly reproducible. Just in case, the summary of the issue: GC is not triggered when a program allocates only large objects. The following program (attached to the issue report, repeated here for visibility) will eat all the memory. let rec alloc = function
| 100000 ->
Printf.printf "Allocated words: %d\n%!" (Gc.stat ()).Gc.live_words;
alloc 0
| n ->
Bytes.create 2048 |> ignore;
Gc.major_slice 0 |> ignore;
alloc (n + 1)
let () = alloc 0 and the output:
Although the code in the trunk has changed a bit due to the reentrant runtime changes, the write-through on Discuss is still actual, just some files have moved. |
major GC cycle instead of just calling caml_major_collection_slice. fixes ocaml#7813
major GC cycle instead of just calling caml_major_collection_slice. fixes ocaml#7813
major GC cycle instead of just calling caml_major_collection_slice. fixes ocaml#7813
Fix #7813 (major GC fails to start)
Original bug ID: 7813
Reporter: anders.fugmann
Status: new
Resolution: open
Priority: normal
Severity: minor
Version: 4.06.1
Category: runtime system and C interface
Monitored by: @nojb
Bug description
When only allocating data on the major heap, and continuously calling Gc.major_slice, the gc gets into a state where it stops collecting.
The attached test exposes the problem, and results in OOM after a while.
Removing the call to Gc.major_slice, or extending the test to do allocations on the minor heap avoids the gc stall, and memory pressure stabilizes to allow the test to run forever.
Steps to reproduce
The attached test exposes the problem on 4.06.1 and 4.07-trunk.
File attachments
The text was updated successfully, but these errors were encountered: