Basically, in these languages, you have to manually request every bit of memory that is not a local variable known at compile time, and you have to manually release it when you don't need it anymore. The are libraries (so-called smart pointers) that can automate this process to some degree, but they are not applicable everywhere. Furthermore, there are absolutely no limits to how you can (try to) access memory via pointer arithmetics.
Manual memory management can lead to a number of bugs:
- If you forget to release some memory, you have a memory leak
- If you use more memory than you've requested for a given pointer, you have a buffer overrun.
- If you release memory and keep using a "dangling pointer" to it, you have undefined behaviour (usually the program crashes)
- If you miscalculate your pointer arithmetics, you have a crash, or corrupted data
And many of these problems are very hard to diagnose and debug.
answered 2010-06-05T06:31:39.583