Interviewer And Interviewee Guide

Unix/Linux programming Interview Question:

Give examples of how memory leaks can occur with c programs?

Submitted by: Administrator
Memory leaks can be occured if no allocated memory is freed. for example,malloc() and free().It is always a good practice to release the memory because it can be dangerous. it could afftect the whole program and lead to very difficult situtation. Make sure that you are releasing the allocated memory at time. so next time you write program, think twice before allocating memory. I always writedown a notes before i start program. so i know whats going on.


Momery leak example occurs when a developer allocates memory, assigns it to a pointer, and then assigns a different value to the pointer without freeing the first block of memory. In this example, overwriting the address in the pointer erases the reference to the original block of memory, making it impossible to release.
Submitted by: Administrator

Read Online Unix/Linux programming Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.