How memory leak occurs?

Memory leak is a problem that happens in programs when there is some unnecessary memory consumption or when program forgets to release the memory it used.
For example

void karthi(void)
int *ngk = malloc(20);

int main(void)

In this program from the main function we are calling the function called karthi(). Inside that function we are allocating 10 bytes for a integer pointer using malloc function. But before using that allocated memory space that function ends and the allocated space doesn’t used and it still remains in memory as unused. This is called as memory leak.

By intrepidkarthi

I am Karthikeyan, working as a software professional, interested in Travelling, Bike riding, PC Gaming, Reading Novels, Blogging, Writing thamizh poems.

Leave a Reply

Your email address will not be published.