![]() In below program programmer forget to free the allocated memory, it can cause a memory leak. It is very hard to predict this type of bug because if you reset the device (power off), it works fine like previously. It might be the effect of this bug reflect after the receiving of 500 or more response packet (run out of memory) it depends on the storage of the device. The device is allocating the memory every time when it gets the signal of the response packet, but the problem is created when the developer forgets to free the allocated memory. In that situation, you need to create a dynamic buffer using the memory management function to store the response packets. Suppose a device is receiving a response packet from the server and the length of the response packet is dynamic. Let’s take an example for the better understanding. Note: once you allocate a memory than allocated memory does not allocate to another program or process until it gets free. In C language, a memory leak occurs when you allocate a block of memory using the memory management function and forget to release it. Memory LeakĪs we have described in the beginning of the article, a memory leak is a common and dangerous problem. In below section, I am describing some problem of dynamic memory allocation with their solution. There is one major problem with dynamic allocation, if you freed the memory before completed its task, then it can create hidden bug which is difficult to identify and can be a cause of the system crash or unpredictable value. ![]() It is not only causes of memory leak but if you do not use the memory allocation properly, it can be the cause of the of memory fragmentation that is also serious issues. ![]() If we cannot release the allocated memory, it can because of memory leak and make your machine slow. The problem with dynamic memory allocation is that it is not deallocated itself, developer responsibility to deallocate the allocated memory explicitly. We know that in the real world everything has a positive and negative effect, in this article we will see the problem which generally arises if we do not use the dynamic memory properly. The allocation of memory at the runtime is great features because it resolves a lot of problems that are faced by the developer at the time of application running. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |