Skip to content

Out-of-memory crash when using a second domain #12042

@talex5

Description

@talex5

This program crashes after a few seconds with an out-of-memory error:

let main () =
  while true do
    ignore (Bytes.create (64 * 1024))
  done

let () =
  Domain.spawn main |> Domain.join
$ ocamlopt --version
5.0.0

$ ocamlopt -o test.exe test.ml && ./test.exe
fish: “./test.exe” terminated by signal SIGKILL (Forced quit)
[336325.516584] Out of memory: Killed process 221782 (test.exe) total-vm:103708848kB, anon-rss:6535600kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:202340kB oom_score_adj:0

If I remove the Domain.spawn bit and just run main () directly, then there is no problem.

I also tested with #11903 at @sadiqj's suggestion and it still fails, though @kit-ty-kate noted that:

I just tested with this branch, and while it ultimately still fails the same way, it does is significantly slower.

  • With 5.0.0 and trunk it takes just 3 seconds to OOM-kill with 32GB of RAM
  • With this branch it takes a whole good minute and some change

/cc @kayceesrk

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions