1/33
Vocabulary flashcards summarizing key memory-management terms from the CMPSC 311 lecture.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Pointer
A variable that stores the memory address of another variable.
Pointer Arithmetic
Operations on pointers that add or subtract multiples of the pointed-to type’s size (e.g., int_ptr+1 advances by sizeof(int)).
Double Pointer (e.g., char **, int **)
A pointer whose value is the address of another pointer; used to reference pointers indirectly.
Stack Frame
Region of stack memory allocated for a single function call, holding its local variables and return info.
Heap
Large pool of memory used for dynamic (runtime) allocation via malloc/calloc/realloc and released with free.
Static Allocation
Memory allocated at program load time (e.g., global variables); freed only when program exits.
Automatic Allocation
Memory allocated when a function is called (locals on the stack) and freed when the function returns.
Dynamic Allocation
Memory explicitly requested at runtime that persists until the program frees it (heap memory).
malloc
C library function that allocates a raw block of memory of a given size and returns a void* pointer to it.
calloc
Like malloc but additionally sets the allocated memory to all zero bytes; takes element count and size.
realloc
Resizes a previously allocated heap block; may move the data to a new location and returns new pointer.
free
Releases a heap block previously obtained from malloc/calloc/realloc; pointer becomes invalid afterward.
Dangling Pointer
A pointer that references memory that has already been freed, leading to undefined behavior if dereferenced.
NULL
A guaranteed invalid pointer value (0x0 on Linux); dereferencing it causes a segmentation fault.
Memory Leak
Dynamically allocated memory that is never freed, causing a program’s memory usage to grow over time.
Memory Corruption
Unintended modification of memory due to bugs such as buffer overflows, invalid frees, or bad arithmetic.
Buffer
A contiguous block of memory used to temporarily hold data, typically referenced through a pointer.
Void Pointer (void *)
A generic, untyped pointer; must be cast to an appropriate type before dereferencing.
memcpy
Standard function that copies n bytes from a source buffer to a destination buffer.
memset
Fills n bytes of a buffer with a constant byte value.
memcmp
Compares two memory regions byte-by-byte for n bytes; returns
Program Break
The current end of the process’s heap region; moved up or down as the heap grows or shrinks.
sbrk
System call that increments (or decrements) the program break by a specified number of bytes.
brk
System call that sets the program break to an absolute address; dangerous if misused.
Garbage Collection
Automatic reclamation of unused memory by a runtime system (absent in C, present in Java, Python, etc.).
Buffer Splicing
Using memcpy to copy a smaller buffer into an offset inside a larger buffer (e.g., &buf1[2]).
AddressSanitizer
Compiler-integrated tool (-fsanitize=address) that detects memory errors such as leaks or out-of-bounds accesses.
Valgrind
Dynamic analysis tool that detects memory leaks, invalid accesses, and other memory errors at runtime.
Heap Allocator
Library implementation (e.g., dlmalloc, tcmalloc, jemalloc) that manages requests to malloc/free.
Overcommit (Linux)
Kernel feature where malloc may never fail immediately because the OS promises more memory than is physically available.
Buffer Overflow
Writing past the end of a buffer, potentially corrupting adjacent memory.
Endianess (Little Endian)
Byte order where least-significant byte is stored at the lowest address; affects pointer casting to char*.
Struct Allocation
Using sizeof(struct) with malloc/calloc to dynamically allocate space for structures.
Memory Debugger
Toolset used to detect memory misuse; examples include Purify, Valgrind, AddressSanitizer.