主权项 |
1. A method for releasing memory, comprising:
obtaining, by an application program without requesting permissions from a system kernel level API (Application Programming Interface) controlling memory releasing in a terminal system, a first memory space value of the terminal system, wherein the first memory space value represents a total size of current idle memory space on the terminal system, and the application program is a user-installed non-system program; requesting, by the application program, a memory space whose size equals to a second memory space value from the terminal system, wherein the second memory space value is greater than the first memory space value; after receiving the memory space request and detecting that the second memory space value is greater than the first memory space value, releasing, by the terminal system, certain occupied memory; confirming, by the terminal system, allocation of the memory space whose size equals to the second memory space value; receiving, by the application program, the allocation of the memory space directed to the application program from the terminal system, wherein a size of the allocation equals to the second memory space; and after receiving allocation confirmation of the memory space of the terminal system, releasing, by the application program, the memory space whose size equals to the second memory space value allocated for the application program into the current idle memory space, wherein before requesting the memory space whose size equals to the second memory space value from the terminal system, the method further comprises: identifying system programs and non-system programs, wherein system programs are kernel level programs that control an operation of the terminal system, and non-system programs are user-installed programs that do not control system operations; obtaining a third memory space value, wherein the third memory space value represents a memory space that is occupied by non-system programs and unused for a preset time period; and obtaining the second memory space value by multiplying a sum of the first memory space value and the third memory space value by a preset ratio, wherein the preset ratio is determined according to the first memory space and the third memory space, to produce a multiplication result greater than the first memory space value. |