Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    One notable exception is Java processes. Search for "fork java memory" and you will find dozens of issues affecting large server JVM or embedded JVM trying to execute a small shell command and miserably crashing on a "Cannot allocate memory" exception (these are just random links, this issue is systemic to the Java environments). This SO answer accuses the JVM's garbage collector & JIT compiler from keeping processes memory from being shared. Commented Mar 2, 2017 at 13:12
  • 1
    Although this is absolutely correct, it may be useful to note that fork() used to copy the entire thing, so it wasn't always as lightweight as it is now. That's the reason for the existence of the vfork() system call which, nowadays, is largely useless and the speedup it provides is negligible. Commented Nov 20, 2021 at 0:36
  • @WhiteWinterWolf Wouldn’t shelling out immediately exec after the fork, thus not giving time to the garbage collector to dirty the memory pages? Commented Apr 24, 2022 at 19:13