I am relatively new to memory management concepts and having programmed a little bit in Java, C++ and Swift, I was curious about the differences between the memory management techniques used by each.
From what I know in Java and Swift, objects can only be created on the heap memory. When the object is out of scope, the reference is magically removed. How does this work? I kinda understand how it works in C++, but I would really appreciate if you could shed some light on how memory management works in Java and Swift.