Pergunta de entrevista da empresa Cisco

What do you know about memory leaks in C?

Resposta da entrevista

Sigiloso

25 de mar. de 2012

Memory leaks are the biggest overhead for a programmer. basically it is due to the re initialization of a block of memory or because of not freeing it. for ex *memory1 = malloc(100); //100 bytes allocted to memory1 say A blocks *memory2 = malloc(100); //10 bytes allocated to memory2 say B blocks memory1 = memory2; //Mow memory1 too is pointing to B blocks so the Block //A memory pointed by none of the ptrs 1.e 100bytes leak is created.

1