Just wondered what happens to the memory of local vars in a C program? I have a console application that runs 24hrs a day and want to make sure I free up memory safely.
Thanks Pete
Just wondered what happens to the memory of local vars in a C program? I have a console application that runs 24hrs a day and want to make sure I free up memory safely.
Thanks Pete
If you do not use dynamic memory allocations, nothing to worry about.
Local variables are created on the stack.
Stack is a preallocated memory region, you can think this way: local variables are mapped to stack.
In some cases, it makes sense to nullify local variables for security reasons.
You can also run Memory Sanitizer to check if memory leaks exist in the program.