Lesson 21 of 23
Dynamic Memory: malloc மற்றும் freeDynamic Memory: malloc and free
10 min 35 XP
Array அளவு run நேரத்தில் மட்டுமே தெரிந்தால் malloc மூலம் heap-ல் memory கேட்கலாம். பயன்பாடு முடிந்தவுடன் free செய்ய வேண்டும்; இல்லையெனில் memory leak.
When the size is only known at run time, ask for heap memory with malloc. Release it with free when you're done, or you leak memory.
Example: edit me and press Run
Press Run to see the result here.malloc vs calloc: calloc memory-ஐ 0 ஆக்கும். realloc அளவை மாற்றும். Stack vs heap வேறுபாடு interview-ல் அடிக்கடி கேட்கப்படும்.
malloc vs calloc: calloc also zeroes the memory; realloc resizes it. Stack vs heap is a frequent interview question.