1. Technical Field
The present disclosure relates to a memory management system and a method thereof.
2. Description of Related Art
With developments in technology, portable devices such as mobile phones, personal digital assistants (PDAs), and digital still cameras (DSCs), etc. are generally used. In order to enhance the performance of the portable devices, memory management is very important.
Presently, a common method to manage the memory of portable devices allocates a capacity of a memory block and corresponding number of the memory block in advance. However, such memory management is limited to a fixed capacity and number of memory blocks. Efficiency is affected, with some memory blocks not large enough to be used or too large to be wasted.
In general, the word “unit” as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as, for example, Java, C, or assembly. One or more software instructions in the unit may be integrated in firmware, such as an EPROM. It will be appreciated that module may comprise connected logic units, such as gates and flip-flops, and may comprise programmable units, such as programmable gate arrays or processors. The unit described herein may be implemented as either software and/or hardware unit and may be stored in any type of computer-readable medium or other computer storage device.
The storage unit 20 stores a default allocation list 21 and a dynamic allocation list 22. The calculation unit 30 is operable to calculate a real time usage status of a memory 2 of the portable device 1 and store the real time usage status in the storage unit 20. The memory 2 may be a random access memory (RAM) or a flash memory, for example. The determination unit 40 is operable to determine whether the electronic device 1 is turned on for the first time. The allocation unit 5 is operable to allocate memory blocks in a partition of the memory 2 according to the default allocation list 21 if the electronic device 1 is turned on for the first time, and to adjust the partition of the memory 2 according to the dynamic allocation list 22 if the electronic device 1 is not turned on for the first time. The term, “allocation list” means a list of allocated memory blocks in the partition of the memory for different programs.
The real time usage status of the memory 2 includes the usage peak and the usage frequency of the memory blocks. The allocation unit 50 updates the dynamic allocation list 22 based on the real time usage status of the memory 2 before the electronic device 1 is turned off.
To adjust the partition of the memory 2 according to the dynamic allocation list 22 is explained as follows. The allocation unit 50 divides the usage peak of the memory block by a constant k to obtain a quotient, which is defined as a number of memory blocks after adjusting the partition. After obtaining the number of memory blocks after adjusting the partition, the calculation unit 30 calculates a surplus memory capacity after adjusting the partition, which is how much memory is left after adjusting the partition. The determination unit 40 determines N memory blocks with usage frequencies ranked top N, where N is a default value. The allocation unit 50 allocates the surplus memory capacity to the N memory blocks based on the usage frequencies.
Dynamic memory management is accomplished by the formula as follows:
number of memory blocks after adjusting the partition=usage peak of memory block/k, where 0<k<1″.
The number of memory blocks after adjusting the partition may be more than the usage peak of memory blocks to be spared. k can not be less than 0.5, otherwise the number of memory blocks after adjusting the partition will be twice as many as the usage peak of the memory blocks. Once the number of memory blocks after adjusting the partition is twice the usage peak of memory blocks, the capacity after adjusting the partition will exceed the total memory capacity. In the embodiment, k is defined as 0.8.
For example, as shown in
After adjusting the number of each memory block, the capacity of the memory block is 248750 bytes and surplus memory capacity is 7250 bytes. The usage peak of memory block with 50 bytes, 200 bytes, and 80 bytes is ranked top 3 and a ratio of each usage frequency of the memory block with 50 bytes, 200 bytes, and 80 bytes is 2:2:1. The surplus capacity, that is, 7250 bytes, is allocated to the 3 memory blocks according to the ratio. The memory block with 50 bytes may further gain 2900 bytes, equaling 58 memory blocks with 50 bytes. Similarly, the memory block with 200 bytes and 80 bytes may respectively gain 14 memory blocks of 200 bytes and 18 memory blocks of 80 bytes.
In block S01, the portable device 1 is turned on. In block S02, the determination unit 40 determines whether the electronic device 1 is turned on for the first time.
In block S03, the allocation unit 50 loads the default allocation list 21 if the portable device 1 is turned on for the first time. In block S05, the allocation unit 50 allocates the partition of the memory 2 according to the default allocation list 21.
If the portable device 1 is not turned on for the first time, in block S04, the allocation unit 50 loads the dynamic allocation list 22. In block S06, the allocation unit 50 allocates the partition of the memory 2 according to the dynamic allocation list 22. The dynamic allocation list 22 is accomplished by the formula:
number of memory blocks after adjusting the partition=usage peak of memory block/k, where 0<k<1″.
In block S08, the calculation unit 30 calculates the real time usage status of the memory 2. In block S10, the determination unit 40 determines whether the electronic device 1 is turned off.
If the electronic device 1 is not turned off, block S08 is repeated. If the electronic device 1 receives the order to turn off, in block S12, the allocation unit 50 updates the dynamic allocation list 22 based on the real time usage status.
The present disclosure adjusts dynamically partition of a memory according to the real time usage status so that the memory of an electronic device can be used efficiently.
Although certain inventive embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
200910303821.1 | Jun 2009 | CN | national |