Possible Duplicate:
What REALLY happens when you don't free after malloc?
Is freeing allocated memory needed when exiting a program in C
During my first C class, it was drilled into me that I should call free()
after malloc()
or calloc()
as it releases the space after dynamically allocating memory or otherwise it will be gone (I assume until system reboot). However, recently I started reading on various coding sites that this memory will be released back when the program ends.
Which one is the correct statement?
I would look in the official spec, but I have no idea where to get it (tried Googling).
Thanks.