I've been doing my best to learn C++ but my previous training will fall short in one major issue: memory management. My primary languages all have automatic garbage collection, so keeping track of everything has never really been necessary. I've tried reading up on memory management in C++ online, but I have this shaking suspicion that I am strill missing something.
So, here's a multi-part question:
- What is the bare minimum I need to know about memory management? (or, where do I go to find that out)?
- Where do I go for intermediate and advanced knowledge/tutorials/etc (once I am done with the basics)?
- What is the performance difference between pointers and references?
- I've heard that in loops, you need to make sure that you call
delete
on any new pointers before the loop re-iterates. Is this correct? Do you need to do something with references? - What are some classic examples of memory leaks?
- What do I need to know about the following (and will I ever realistically need to use them -- if so, where?):
malloc
free
calloc
realloc
More specifically:
******************* UPDATE ***************
This is to address a reference to lmgtfy in comment one (by Ewan). If you start reading the information which is available there, it is not useful to the beginner. It is great theory, I think, but it is neither pertinent or useful to this question.