---
title: "What is memory leak?"  
description: "What is memory leak?"  
author: "Tarun Gautam"  
published: 2017-11-13  
canonical: https://answers.mindstick.com/qa/30448/what-is-memory-leak  
category: "programming"  
tags: ["computer memory", "memory"]  
reading_time: 1 minute  

---

# What is memory leak?

What is [memory leak](https://www.mindstick.com/forum/23182/creating-a-memory-leak-with-java)?

## Answers

### Answer by Arti Mishra

**Memory Leak :** A Memory leak occurs when we **create a memory in heap areas and forget to delete it**. And it also happens when we **create any objects multiple times and we can’t accessed by the running source code.** And the most powerful disadvantage of memory leak is, it **reduces the performance** of the computer system and also **waste the space of memory**.\
Here is the C Language example where we can demonstrate the concept of memory leak. **Code for allocation of Memory Leak** **\**#include <stdlib.h>; void memoryLeakFunction() { int *ptr = (int *) malloc(sizeof(int)); // allocate dynamic memory ................... ..................... // Write some code here .................... return; /* Return without freeing ptr* var/ }\
**Code for avoiding Memory Leak allocated on heap area.** **\**#include <stdlib.h>; void avoidMemoryLeak() { int *ptr = (int *) malloc(sizeof(int)); // allocate dynamic memory ................. ................... // Write some code here ................... free(ptr); // free() is used for deallocate the memory return; } \


---

Original Source: https://answers.mindstick.com/qa/30448/what-is-memory-leak

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
