In cpp, do I have to always "free" the primitive variables?
c++
Solution
Here are the memory manegement commandments for you
- Thou shalt free only what thou hast malloc'ed or calloc'ed
- Thou shalt delete only what thou hast new'ed
- Thou shalt delete[] only what thou hast new[]'ed
- Thou shalt use RAII whenever possible
Problem
If I have a `function` that declares an `int`, in the end of this `function` I need to "free" that `int` to save memory? Example: ``` void doSomething() { int x = 0; // do something with x free(x); // needed? } ```