Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Memory leaks: If the allocated memory blocks are not deallocated using free(), it can cause memory leaks in the program. This can lead to an eventual and unpredictable crash of the program due to lack of memory.

  2. Fragmentation: Allocating and deallocating memory frequently can result in fragmentation of memory, which means there are small free spaces between the allocated memory blocks, but not enough contiguous space to fulfill larger memory requests.

  3. Overlapping memory: If two or more pointer variables point to the same memory location, it can cause data corruption and unexpected results when reading or writing to memory.

  4. Dangling pointers: If a pointer variable is created to point to a dynamically allocated memory block, and the memory is deallocated using free(), the pointer variable still points to that block of memory, leading to undefined behavior if the pointer is dereferenced.

  5. Memory allocation errors: When allocating memory dynamically, there is a possibility that insufficient memory is available. The program has to handle such cases carefully to avoid unexpected behavior or crashes.