1) When a program ends and you haven't freed you dynamically allocated memory, what are the consequenses? Does the program free memory when main returns? Does it try to and hope for the best? Will it try to if it crashes?
2) Another question about memory. How do languages that have a garbage collect, like Java, but don't let you free memory, manage memory? Do they wait for the object not to be used anymore, so no harm done? Is that possible? Do the use a more sophisticated way?
Would there be a benefit of having the ability to manually free memory in languages like Java, or they do the work for you without disadvantages? If they have disadvantages what are those?