For a Java program, it’s basically compiled bytecode that gets executed on a JVM runtime. The JVM runtime is configured with a certain amount of memory. If the program takes up more than that amount of memory it throws a OutOfMEmoryException. So i believe there is no way a Java program can take up all the system’s memory and bring it down in the process.
For GoLang, i believe there is still a GoLang Runtime that gets compiled into binary with the user written program. The runtime does things like Garbage collection. Is it also given a certain fixed amount of memory to work with? If not, can a GoLang program use up of a system’s memory and bring it to its knees?