1. Field of the Invention
The present invention relates to a memory management method in an embedded system which prevents memory fragmentation during dynamic memory allocation in the embedded system.
2. Description of the Related Art
After dynamic memory allocation, an operating system (OS) is required to determine which part of the memory is in use. For this purpose, two methods are used. One memory management method uses a bitmap, whereas the other memory management method uses a list
First, the memory management method using a bitmap manages memory by dividing the memory into a plurality of allocation units. For instance, one bit corresponds to each of the allocation units. Each of the units is regarded as being available when the bit is 0 and as being in use when the bit is 1. In particular, an important issue is to which size each of the allocation units is to be set. When 4 bytes are set as the allocation unit, a total of 33 bits is required since every one bit corresponds to every four bytes: 4 bytes+1 bit=33 bits. In other words, 32n bits require a bitmap having an n size. In conclusion, it can be appreciated that the bitmap occupies a substantial amount of memory. As a drawback of the memory management method using a bitmap, when a program requests for an n number of allocation units, a memory manager is required to find an n number of continuous sections each of which has 0 bits, which causes a time delay.
In the method using a list, the entry of the list consists of information with which a space can be identified to be hollow or not, a starting address, a length and a next entry pointer. When the memory is in use, P is marked. When the memory is empty, H that represents “hole” is marked. Further, 0 indicates the starting address of the memory, and 5 indicates the size of the memory that is in use and the next entry. When H is marked, the next entry is a hollow space that starts from an address 5 and is empty by the size 3. In addition, when continuous Hs are generated, the number of the entire list may be reduced by incorporating and managing the continuous hollow spaces together. Since this may form a substantially large space, this method may be effective when a substantial amount of space is required. When memory is managed and aligned in this manner, various types of algorithms for allocating the memory space are applied.
However, even in the case of the dynamic memory management using a list, memory may be fragmented, concurrently increasing the maximum memory requirement that must be obtained for processing the operation. Accordingly, in some cases, it may not be possible to properly use resources.
The information disclosed in this section is merely for the enhancement of understanding of the background of the invention, and should not be taken as an acknowledgment or any form of suggestion that this information forms a prior art that would already be known to a person skilled in the art.