Memory: Divided into five regions
- The stack area-----------system allocations and reclaims memory. The variables created in the function body exist in the stack area
- Heap areas are------------allocated and recycled by users, and if a user forgets to recycle, the heap memory is reclaimed by the system if the memory is not sufficient and the program exits
- Constant area-------------The area of memory used to hold constants
- Static area-------------variables defined in the function body, the system opens up space, the program has been in operation for a long time, until the program exits, the system is recycled
- Code Area----------------storing code compilation results
---------------------------------------------------------------------------------
malloc function
void *malloc (unsigned int size);
The malloc function allocates a size contiguous memory space to the system but does not clear the allocated space by 0
Free ();//Release memory
-----------------------------------
void *calloc (unsigned n,unsigned size);
Allocate n sizes of size space
Unlike malloc, the memory space requested by Calloc is initialized to 0;
----------------------------------
void *realloc (void *p, unsigned newSize);
Re-allocating memory at new length
All three of these are released using free
------------------------------------------
Memory manipulation functions
void *memset (void *s, int c, size_t N);
memset (p,0,sizeof (Student));
s begins, all bytes of length n are assigned C;
Usually used for clear structure or array data
void *memcpy (void *dest,const void *source,size_t n);
Copy n bytes from source to Dest
int memcmp (const void *buf1,const void *buf2,unsigned int count);
The above memory manipulation functions can be used for heap memory pages that can be used for stack memory
IOS--DAY03---Memory allocation dynamic RAM allocation