Discussion
When we dynamically allocate memory is there any way to free memory during run time?
Answer: A
Correct answer: Yes
free returns a block to the allocator at any point during execution, and the storage becomes available for later allocations. That is the whole point of the heap: its lifetimes are under the program's control rather than tied to function entry and exit.
The control brings responsibility. Failing to free leaks memory, freeing twice corrupts the allocator's bookkeeping, and using a pointer after freeing it is undefined behaviour - the three faults that dominate debugging in C.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development