CN114365096A - Memory allocation method, device, terminal and computer readable storage medium - Google Patents

Memory allocation method, device, terminal and computer readable storage medium Download PDF

Info

Publication number
CN114365096A
CN114365096A CN201980100145.XA CN201980100145A CN114365096A CN 114365096 A CN114365096 A CN 114365096A CN 201980100145 A CN201980100145 A CN 201980100145A CN 114365096 A CN114365096 A CN 114365096A
Authority
CN
China
Prior art keywords
memory
file
terminal
synthesis stage
pool
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201980100145.XA
Other languages
Chinese (zh)
Inventor
卢阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Shenzhen Huantai Technology Co Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Shenzhen Huantai Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd, Shenzhen Huantai Technology Co Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Publication of CN114365096A publication Critical patent/CN114365096A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation

Abstract

A memory allocation method, a device, a terminal and a computer readable storage medium belong to the technical field of memory control, wherein the memory allocation method comprises the following steps: acquiring a predetermined memory requirement (101) of each file synthesis stage when files to be updated are subjected to incremental updating; analyzing the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage, and determining the size of each memory in a memory pool of each file synthesis stage (102); and applying and releasing (103) the system memory according to the size of each memory in the memory pool in each file synthesis stage, so that the use of the system memory is optimized when the increment of the file to be updated is updated.

Description

Memory allocation method, device, terminal and computer readable storage medium Technical Field
The present application belongs to the technical field of memory control, and in particular, to a memory allocation method, an apparatus, a terminal, and a computer-readable storage medium.
Background
The statements herein merely provide background information related to the present application and may not necessarily constitute prior art. The incremental update is a data update mode, and when data is updated, a file before the incremental update is generally synthesized with a differential file to obtain a file after the incremental update.
Disclosure of Invention
The embodiment of the application provides a memory allocation method, a memory allocation device, a terminal and a computer-readable storage medium, which can optimize the use of a system memory when performing file increment updating.
A first aspect of the embodiments of the present application provides a memory allocation method, including:
acquiring the memory requirement of each file synthesis stage when the increment updating is carried out on the file to be updated which is determined in advance;
analyzing the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage, and determining the size of each memory in a memory pool in each file synthesis stage;
and applying and releasing the system memory according to the size of each memory in the memory pool of each file synthesis stage.
A second aspect of the present application provides a memory allocation apparatus, including:
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring the predetermined memory requirement of each file synthesis stage when the files to be updated are subjected to incremental updating;
a determining unit, configured to analyze memory requirements of two or more temporally consecutive file synthesis stages in each file synthesis stage, and determine a size of each memory in a memory pool in each file synthesis stage;
and the distribution unit is used for applying and releasing the system memory according to the size of each memory in the memory pool of each file synthesis stage.
A third aspect of the embodiments of the present application provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method when executing the computer program.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the above method.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic flowchart illustrating a first implementation flow of a memory allocation method according to an embodiment of the present application;
fig. 2 is a schematic flowchart illustrating a specific implementation of step 103 of a memory allocation method according to an embodiment of the present application;
fig. 3 is a schematic flowchart illustrating a specific implementation of step 101 of a memory allocation method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a memory allocation apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a terminal according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
In order to explain the technical solution of the present application, the following description will be given by way of specific examples.
The incremental update is a data update mode, and when data is updated, a file before the incremental update is generally synthesized with a differential file to obtain a file after the incremental update.
With the continuous development of terminal technology, terminal applications are continuously updated, a terminal often needs to perform incremental update operations on files in a picture library or application software, and generally occupies more memory space during the incremental update of the files.
However, at present, a terminal can only allocate a memory space of a fixed size for incremental update of a file, and cannot reasonably use a system memory while ensuring the efficiency of incremental update of the file. In addition, there is a possibility that memory jitter is caused by frequent application and release of the memory during the incremental update of the file.
In view of the above problems, an embodiment of the present application provides a memory allocation method, which can optimize the use of a system memory when performing file increment update, and in addition, the memory allocation method provided by the embodiment of the present application can also solve the problem of memory jitter caused by frequent application and release of a memory during the file increment update.
Specifically, as shown in fig. 1, an implementation flow diagram of a memory allocation method provided in the embodiment of the present application is shown, and the method is applied to a terminal and can be executed by a memory allocation device configured on the terminal, where the terminal may be an intelligent terminal such as a mobile phone, a tablet, a wearable device, and the memory allocation method may include steps 101 to 103.
Step 101, obtaining a predetermined memory requirement of each file synthesis stage when incremental updating is performed on a file to be updated.
In the embodiment of the present application, when performing incremental update on a file to be updated, the process of incremental update may be divided into multiple stages, that is, multiple file synthesis stages, and a next file synthesis stage needs to wait until a previous file synthesis stage is completed.
The memory requirement of each file synthesis stage when the file to be updated is subjected to incremental updating refers to the actual memory requirement of each file synthesis stage.
For example, in a certain file composition stage, a 50M file and a 30M file need to be copied respectively, and the memory requirements of the file composition stage are a piece of 50M memory and a piece of 30M memory.
Step 102, analyzing the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage, and determining the size of each memory in the memory pool of each file synthesis stage.
Because the predetermined memory requirement of each file synthesis stage only represents the respective actual memory requirement of each file synthesis stage when the file to be updated is subjected to incremental updating, and is not determined by combining the memory requirements of other file synthesis stages, after the respective memory requirement of each file synthesis stage when the predetermined file to be updated is subjected to incremental updating is obtained, the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage can be analyzed, the size of each memory in the memory pool of each file synthesis stage determined by combining the memory requirements of other file synthesis stages is obtained, and the problem of memory jitter caused by frequent memory application and release can be effectively avoided by the terminal.
For example, a certain file synthesis stage needs 2 pieces of 20M memories and one piece of 10M memories, and a next file synthesis stage (i.e., a file synthesis stage entered after a task of the file synthesis stage is completed) that is temporally continuous with the file synthesis stage needs 1 piece of 20M memories and one piece of 30M memories, so that the 3 pieces of memories that have been applied can be directly used when entering the next file synthesis stage, without first releasing the 2 pieces of 20M memories and one piece of 10M memories, and then reapplying the 1 piece of 20M memories and one piece of 30M memories, so that frequent memory application and release are not needed in the file synthesis process, and the problem of memory jitter caused by frequent memory application and release is effectively avoided.
For another example, when a certain file synthesis stage needs 50M of memory, a next file synthesis stage temporally continuous to the file synthesis stage needs 40M of memory, and a next file synthesis stage needs 50M of memory, when entering the next file synthesis stage, application and release of the system memory may not be performed, so that when entering the next file synthesis stage, application and release of the system memory may not be performed, thereby reducing the number of times of applying and releasing the system memory.
It should be noted that, in the process of analyzing the memory requirements of two or more temporally consecutive file synthesis stages in each file synthesis stage, the process may be combined with an actual application scenario to perform comprehensive analysis, for example, it may be determined whether to apply for and release the system memory by calculating a difference between a size of each memory in the memory pool in the last file synthesis stage and a size of each memory in the memory pool in the next file synthesis stage, or calculating a difference between a size of each memory in the memory pool in the last file synthesis stage and a size of each memory in the memory pool in the next file synthesis stage.
And 103, applying and releasing the system memory according to the size of each memory in the memory pool in each file synthesis stage.
In the embodiment of the application, the memory requirement of each file synthesis stage when the increment updating is carried out on the file to be updated is obtained; then analyzing the memory requirement of each file synthesis stage, and determining the size of each memory in the memory pool of each file synthesis stage; the terminal can apply and release the system memory according to the size of each memory in the memory pool of each file synthesis stage, so that the dynamic update of each memory in the memory pool is realized, and the size of each memory in the memory pool can be adapted to each file synthesis stage instead of a memory with a fixed size; when the terminal applies and releases the system memory according to the size of each memory in the memory pool in each file synthesis stage, system resource waste caused by too much applied system memory can be avoided, and the efficiency of updating the file increment can not be reduced caused by too small applied system memory, so that the system memory can be reasonably used under the condition of not reducing the efficiency of updating the file increment, namely, the balance between the efficiency and the resource is realized.
In addition, when the application and the release of the system memory are carried out, after the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage are analyzed, according to the size of each memory in the memory pool of each file synthesis stage, when the application and release of the system memory are carried out according to the size of each memory in the memory pool of each file synthesis stage, the memory required to be applied or released in each file synthesis phase can be planned in advance according to the memory requirements of two or more than two continuous file synthesis phases in time, so that when the application and release of the system memory are carried out according to the size of each piece of memory in the memory pool in each file synthesis stage, the problem of memory jitter caused by frequent memory application and release can be avoided.
In some embodiments of the present application, as shown in fig. 2, in the step 103, applying for a system memory according to the size of each piece of memory in the memory pool in each file composition phase may further include: step 201 to step 203.
Step 201, before entering the next file synthesis stage, the remaining memory space of the terminal is detected.
When the system of the terminal is running, while the file to be updated is being incrementally updated, other applications may be running, or other tasks may be executed, and a certain memory needs to be occupied, so that in order to avoid that the running of other applications or other tasks is affected by occupying too much memory when the file to be updated is incrementally updated, the remaining memory space of the terminal needs to be detected before entering the next file synthesis stage each time in the process of incrementally updating the file to be updated, so as to determine whether the remaining memory space of the terminal is sufficient.
Specifically, in some embodiments of the present application, the detecting the remaining memory space of the terminal may include: detecting the residual memory space of the terminal through a task manager of the system; or, detecting the residual memory space of the terminal through the memory monitoring application.
It should be noted that, in some embodiments of the present application, the task manager may further detect a size of a memory occupied by each application currently running on the terminal. The memory monitoring application refers to an application for detecting a remaining memory space of the terminal, and specifically, when the memory monitoring application is started, the remaining memory space of the terminal may be detected.
Step 202, judging whether the system memory required to be applied is smaller than or equal to the remaining memory space of the terminal according to the size of each memory in the memory pool of each file synthesis stage.
In the embodiment of the present application, since the size of each memory in the memory pool of each file synthesis phase is obtained by analyzing the memory requirements of two or more temporally consecutive file synthesis phases in each file synthesis phase, when entering the next file synthesis phase, the system memory to be applied can be determined, and it can be further determined whether the system memory to be applied is less than or equal to the remaining memory space of the terminal.
Step 203, if the system memory required to be applied is less than or equal to the remaining memory space of the terminal, applying for the system memory according to the size of each memory in the memory pool of each file synthesis stage.
In the embodiment of the application, when the system memory required to be applied is less than or equal to the remaining memory space of the terminal, it indicates that the remaining memory space of the terminal is sufficient, and when the file to be updated is subjected to incremental update, the operation of other applications of the terminal is not affected, so that the application of the system memory can be directly performed according to the size of each memory in the memory pool in each file synthesis stage, so as to improve the efficiency of incremental update.
However, when the system memory required to be applied is larger than the remaining memory space of the terminal, it indicates that the remaining memory space of the terminal is relatively tight, and it may affect the operation of the terminal application because the file to be updated occupies too large memory when performing incremental update. Therefore, as shown in fig. 2, in some embodiments of the present application, after determining whether the system memory required to be applied is less than or equal to the remaining memory space of the terminal according to the size of each piece of memory in the memory pool in each file composition phase, steps 204 to 205 may be further included to ensure that the operation of some applications of the terminal is not affected by the incremental update.
Step 204, if the system memory required to be applied is larger than the remaining memory space of the terminal, determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal.
The determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal may include: and calculating a difference value between the residual memory space of the terminal and a preset memory threshold value, and determining the sum of the difference value and the total memory space of the memory pool as the memory upper limit value of the memory pool.
The preset memory threshold may be a remaining memory space that ensures that the system application of the terminal is not killed due to the burst memory occupation. I.e. the terminal needs a minimum memory to reserve. The total memory space of the memory pool refers to the sum of the memory sizes of each system that have been applied for in the memory pool before the next file synthesis stage is entered.
In some embodiments of the present application, before determining the upper limit value of the memory pool according to the remaining memory space of the terminal, the method may further include: if the system memory required to be applied is larger than the residual memory space of the terminal, detecting that the priority of the application currently running by the terminal is lower than the application synthesized by the file, and releasing the memory occupied by the application with the priority lower than the application synthesized by the file; therefore, the residual memory space of the terminal is increased, and correspondingly, the memory upper limit value of the memory pool is also increased, so that the memory space allocated to the incremental updating process can be increased, and the incremental updating speed is increased.
Step 205, adjusting the size of each memory in the memory pool according to the memory upper limit value and the memory requirement of the next file synthesis stage.
In the embodiment of the application, when the system memory required to be applied is larger than the remaining memory space of the terminal and the remaining memory space of the terminal is relatively tight, in order to avoid that the operation of the terminal application is affected due to the fact that the terminal occupies too large memory when the file to be updated is subjected to incremental updating, after the memory upper limit value of the memory pool is determined according to the remaining memory space of the terminal, the size of each piece of memory in the memory pool can be adjusted according to the memory upper limit value and the memory requirement of the next file synthesis stage, so that the incremental updating efficiency is improved to the maximum extent, and the use of the system memory is optimized.
Specifically, the adjusting the size of each memory slice in the memory pool according to the upper limit value of the memory and the memory requirement of the next file synthesis stage means that the size of a part of the memory slices is reduced according to the actual memory requirement of the next file synthesis stage under the condition that the actual memory requirement does not exceed the upper limit value of the memory.
For example, when the upper limit of the memory is 50M, and the actual memory requirement of the next file composition stage is one 40M memory and 3 10M memories, the 40M memory may be adjusted to 20M memory.
As shown in fig. 3, in some embodiments of the present application, in the step 101, obtaining a predetermined memory requirement of each file synthesis phase when performing incremental update on a file to be updated may include: step 301 to step 303.
Step 301, obtaining a difference file; and the differential file records the processing task of each file to be processed when the file to be updated is subjected to incremental updating.
The differential file is a file for recording the content of the two files which are changed, when the terminal performs incremental update on the file to be updated, the terminal firstly acquires the differential file corresponding to the file to be updated, and the incremental file is synthesized with the file to be updated to obtain the file after the file to be updated is subjected to incremental update.
In this embodiment of the application, the obtaining of the differential file may include: and acquiring a file obtained by performing differential calculation on the file before the incremental update and the file after the incremental update. Namely, the differential file is obtained by directly performing differential calculation on the file before incremental update and the file after incremental update.
However, the differential file obtained by directly performing differential calculation on the file before incremental update and the file after incremental update often has a problem of an excessively large data amount.
For example, if the content of the file before the incremental update is a binary character obtained by compressing the character "aaabbb", and the compression dictionary of the compression algorithm is 0 representing aaa and 1 representing bbb, then the file before the incremental update is "01", and if the content of the file before the incremental update is a binary character obtained by compressing the character "aaabbb", then the content of the file after the incremental update is changed by the same compression algorithm, for example, if the compression dictionary is changed to 0 representing a and 1 representing b, then the file after the incremental update is changed to "00011", because the content of the file is changed, when the file before the incremental update is incrementally updated, only the character "aaabbb" before the compression corresponding to the file before the incremental update is changed by one character, that is, changing "aaabbb" to "aaabbb" will result in a large change in the compressed binary character corresponding to the incrementally updated file, i.e., from "01" to "00011". Therefore, the differential file obtained by directly performing differential calculation on the file before incremental update and the file after incremental update has a problem of an excessively large data amount.
In view of this, in some other embodiments of the present application, the obtaining of the differential file may further include: obtaining a differential file obtained by performing differential calculation on the first reduction file and the second reduction file; the first reduction file is obtained by reducing the file before incremental updating; the second reduction file is obtained by reducing the file after the increment updating.
Specifically, when the file before the incremental update is a file in a preset compression format, the first restore file is a file obtained by decompressing the compressed file before the incremental update; the second restored file is a file obtained by decompressing the compressed file after the incremental update.
When the file before the incremental update is a file in another preset format, the first restore file is a file obtained by converting the format of the file before the incremental update; the second restoration file is obtained by converting the format of the compressed file after the increment updating.
For example, when the file before the incremental update is a picture file in a JPG format or a picture file in a PNG format, the first restore file is a file in a BMP bitmap format obtained by converting the format of the file before the incremental update.
It should be noted that, this is merely an example, and the files in other preset formats may also include files in other various formats.
In the embodiment of the application, the obtained differential file obtained by performing differential calculation on the first reduced file and the second reduced file can make the data volume of the obtained differential file smaller, which is beneficial to improving the downloading speed of the differential file, however, when the file to be updated is subjected to incremental updating, the file to be updated needs to be decompressed first, then the decompressed file and the differential file are synthesized, finally the synthesized file needs to be compressed to obtain the final file subjected to incremental updating, and a large amount of system memory needs to be consumed by the series of compression, synthesis and decompression operations, so that in order to reasonably use the system memory, the memory requirement of each file synthesis stage when the file to be updated is subjected to incremental updating needs to be predetermined, then the memory requirements of two or more than two file synthesis stages which are continuous in time in each file synthesis stage are analyzed, and determining the size of each memory in the memory pool of each file synthesis stage, so that when the application and release of the system memory are carried out according to the size of each memory in the memory pool of each file synthesis stage, the memory can be flexibly applied and reused, and the use of the system memory is optimized.
Step 302, determining the memory space required to be occupied in the task processing process of each file to be processed according to the processing task of each file to be processed recorded by the differential file.
In this embodiment of the present application, when the differential file is a differential file obtained by directly performing differential calculation on a file before incremental update and a file after incremental update, the to-be-processed file refers to each file after incremental update, and the determining of the memory space that needs to be occupied in the task processing process of each to-be-processed file refers to determining the memory space that needs to be occupied by each file after incremental update.
When the differential file is a differential file obtained by performing differential calculation on the first restored file and the second restored file, and the first restored file is a file obtained by decompressing a file before incremental update, the to-be-processed files refer to each to-be-decompressed file in the compressed file before incremental update, each to-be-synthesized file required to be synthesized with the differential file after decompression, and each to-be-compressed file obtained after synthesis with the differential file.
That is to say, the memory space required to be occupied in the task processing process of each to-be-processed file includes the memory space required to be occupied by the processing task of each file to be decompressed, each file to be synthesized, and each file to be compressed.
Step 303, predetermining the memory requirement of each file synthesis stage when performing incremental update on the files to be updated according to the memory space required to be occupied in the task processing process of each file to be processed and the processing sequence of each file to be processed.
When incremental update is performed on files to be updated, each file to be processed directly has a certain processing sequence, for example, when incremental update is performed, a compressed file before incremental update needs to be decompressed first, then, the decompressed file of the compressed file before incremental update is synthesized with a differential file to obtain a synthesized file, and then, the synthesized file is compressed to obtain the compressed file after incremental update. That is, the file composition stage may be sequentially divided into a decompression stage, a composition stage, and a compression stage. Therefore, when determining the memory requirement of each file synthesis stage when performing incremental update on the files to be updated, the memory requirement needs to be determined according to the memory space required to be occupied in the task processing process of each file to be processed and the processing sequence of each file to be processed.
In order to further improve the efficiency of incremental update and avoid failure of incremental update due to incomplete differential files, in some embodiments of the present application, before determining, according to the processing task of each to-be-processed file recorded in the differential file, a memory space that needs to be occupied in the processing process of each to-be-processed file task, the method includes: and carrying out integrity check on the differential file.
Specifically, because the differential file received by the processor of the terminal may be inconsistent with the differential file sent by the server due to various factors in the data transmission process, that is, the differential file has an error in the transmission process, so that in order to avoid an incremental update failure caused by an error in data transmission, the incremental update efficiency is improved.
For example, Cyclic Redundancy Check (CRC) may be used to verify whether the differential file received by the terminal is consistent with the differential file sent by the server. However, those skilled in the art can also adopt data verification methods such as direct comparison, parity check, xor check, hamming code check, etc. to verify that the differential file received by the processor of the terminal is consistent with the differential file sent by the server, which should be considered as the present application.
It should be noted that for simplicity of description, the aforementioned method embodiments are all presented as a series of combinations of acts, but those skilled in the art will appreciate that the present invention is not limited by the order of acts described, as some steps may occur in other orders in accordance with the present invention.
Fig. 4 shows a schematic structural diagram of a memory allocation apparatus 400 according to an embodiment of the present application, where the memory allocation apparatus 400 is configured in a terminal and includes an obtaining unit 401, a determining unit 402, and an allocating unit 403.
An obtaining unit 401, configured to obtain a predetermined memory requirement of each file synthesis stage when performing incremental update on a file to be updated;
a determining unit 402, configured to analyze memory requirements of two or more temporally consecutive file synthesis stages in each file synthesis stage, and determine a size of each memory in a memory pool in each file synthesis stage;
the allocating unit 403 is configured to apply for and release the system memory according to the size of each piece of memory in the memory pool in each file composition stage.
It should be noted that, for convenience and simplicity of description, the specific working process of the memory allocation apparatus 400 described above may refer to the corresponding process of the method described in fig. 1 to fig. 3, and is not described herein again.
As shown in fig. 5, the present application provides a terminal for implementing the memory allocation method, including: a processor 51, a memory 52 and a computer program stored in the memory and executable on the processor, the processor 51 implementing the following steps when executing the computer program:
acquiring the memory requirement of each file synthesis stage when the increment updating is carried out on the file to be updated which is determined in advance;
analyzing the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage, and determining the size of each memory in a memory pool in each file synthesis stage;
and applying and releasing the system memory according to the size of each memory in the memory pool of each file synthesis stage.
Assuming that the above is the first possible implementation manner, in a second possible implementation manner provided as a basis for the first possible implementation manner, the processor executes the computer program to further implement the following steps:
detecting the residual memory space of the terminal before entering the next file synthesis stage;
judging whether the system memory required to be applied is smaller than or equal to the residual memory space of the terminal or not according to the size of each memory in the memory pool of each file synthesis stage;
and if the system memory required to be applied is smaller than or equal to the residual memory space of the terminal, applying for the system memory according to the size of each memory in the memory pool of each file synthesis stage.
In a third possible implementation manner provided as the basis for the second possible implementation manner, the processor, when executing the computer program, further implements the following steps:
if the system memory required to be applied is larger than the residual memory space of the terminal, determining the memory upper limit value of the memory pool according to the residual memory space of the terminal;
and adjusting the size of each memory in the memory pool according to the memory upper limit value and the memory requirement of the next file synthesis stage.
In a fourth possible implementation manner provided as the basis for the third possible implementation manner, the processor, when executing the computer program, further implements the following steps:
and calculating a difference value between the residual memory space of the terminal and a preset memory threshold value, and determining the sum of the difference value and the total memory space of the memory pool as the memory upper limit value of the memory pool.
In a fifth possible implementation manner provided as a basis for the third possible implementation manner, the processor, when executing the computer program, further implements the following steps:
and if the system memory required to be applied is larger than the residual memory space of the terminal, detecting that the priority of the application currently running in the terminal is lower than that of the application synthesized by the file, and releasing the memory occupied by the application with the priority lower than that of the synthesized file.
In a sixth possible implementation manner provided on the basis of the second possible implementation manner, the third possible implementation manner, the fourth possible implementation manner, and the fifth possible implementation manner, the processor executes the computer program to further implement the following steps:
detecting the residual memory space of the terminal through a task manager of the system; alternatively, the first and second electrodes may be,
and detecting the residual memory space of the terminal through the memory monitoring application.
In a seventh possible implementation manner provided as the basis for the first possible implementation manner, the processor, when executing the computer program, further implements the following steps:
acquiring a difference file; the differential file records the processing task of each file to be processed when the file to be updated is subjected to incremental updating;
determining the memory space required to be occupied in the task processing process of each file to be processed according to the processing task of each file to be processed recorded by the differential file;
and predetermining the memory requirement of each file synthesis stage when the files to be updated are subjected to incremental updating according to the memory space required to be occupied in the task processing process of each file to be processed and the processing sequence of each file to be processed.
In an eighth possible implementation manner provided as the basis for the seventh possible implementation manner, the processor, when executing the computer program, further implements the following steps:
and acquiring a file obtained by performing differential calculation on the file before the incremental update and the file after the incremental update.
In a ninth possible implementation manner provided on the basis of the seventh possible implementation manner, the processor, when executing the computer program, further implements the following steps:
obtaining a differential file obtained by performing differential calculation on the first reduction file and the second reduction file; the first reduction file is obtained by reducing the file before the increment updating; the second reduction file is obtained by reducing the file after the increment updating.
In a tenth possible implementation manner provided on the basis of the eighth possible implementation manner and the ninth possible implementation manner, the processor executes the computer program to further implement the following steps:
carrying out integrity check on the differential file;
the determining, according to the processing task of each to-be-processed file recorded by the differential file, a memory space that needs to be occupied in the processing process of each to-be-processed file task includes:
and if the integrity check is successful, determining the memory space required to be occupied in the processing process of each file task to be processed according to the processing task of each file to be processed recorded by the differential file.
Further, as shown in fig. 5, the terminal described above may further include: one or more input devices 53 (only one shown in fig. 5) and one or more output devices 54 (only one shown in fig. 5). The processor 51, memory 52, input device 53 and output device 54 are connected by a bus 55.
It should be understood that, in the embodiment of the present Application, the Processor 51 may be a Central Processing Unit (CPU), and the Processor may also be other general processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The input device 53 may include a virtual keyboard, a touch pad, a fingerprint sensor (for collecting fingerprint information of a user and direction information of the fingerprint), a microphone, etc., and the output device 54 may include a display, a speaker, etc.
The memory 52 may include a read-only memory and a random access memory, and provides instructions and data to the processor 51. Some or all of the memory 52 may also include non-volatile random access memory. For example, the memory 52 may also store device type information.
The memory 52 stores a computer program that can be executed by the processor 51, and the computer program is, for example, a program of a memory allocation method. The processor 51 implements the steps of the memory allocation method embodiment when executing the computer program, such as steps 101 to 103 shown in fig. 1. Alternatively, the processor 51 implements the functions of the modules/units in the device embodiments, such as the functions of the units 401 to 403 shown in fig. 4, when executing the computer program.
The computer program may be divided into one or more modules/units, which are stored in the memory 52 and executed by the processor 51 to complete the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used for describing the execution process of the computer program in the first terminal for performing the memory allocation method. For example, the computer program may be divided into an acquisition unit, a determination unit, and an allocation unit, and each unit may specifically function as follows:
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring the predetermined memory requirement of each file synthesis stage when the files to be updated are subjected to incremental updating;
a determining unit, configured to analyze memory requirements of two or more temporally consecutive file synthesis stages in each file synthesis stage, and determine a size of each memory in a memory pool in each file synthesis stage;
and the distribution unit is used for applying and releasing the system memory according to the size of each memory in the memory pool of each file synthesis stage.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the apparatus may be divided into different functional units or modules to implement all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal are merely illustrative, and for example, the division of the above-described modules or units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units described above, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above may be implemented by a computer program, which may be stored in a computer readable storage medium and used by a processor to implement the steps of the embodiments of the methods described above. The computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file or some intermediate form. The computer readable medium may include: any entity or device capable of carrying the above-described computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium described above may include content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media that does not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (20)

  1. A method for allocating memory, comprising:
    acquiring the memory requirement of each file synthesis stage when the increment updating is carried out on the file to be updated which is determined in advance;
    analyzing the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage, and determining the size of each memory in a memory pool in each file synthesis stage;
    and applying and releasing the system memory according to the size of each memory in the memory pool of each file synthesis stage.
  2. The method according to claim 1, wherein the applying for the system memory according to the size of each piece of memory in the memory pool in each file composition stage comprises:
    detecting the residual memory space of the terminal before entering the next file synthesis stage;
    judging whether the system memory required to be applied is smaller than or equal to the residual memory space of the terminal or not according to the size of each memory in the memory pool of each file synthesis stage;
    and if the system memory required to be applied is smaller than or equal to the residual memory space of the terminal, applying for the system memory according to the size of each memory in the memory pool of each file synthesis stage.
  3. The method according to claim 2, wherein after determining whether the system memory required to be applied is less than or equal to the remaining memory space of the terminal according to the size of each piece of memory in the memory pool in each file composition stage, the method comprises:
    if the system memory required to be applied is larger than the residual memory space of the terminal, determining the memory upper limit value of the memory pool according to the residual memory space of the terminal;
    and adjusting the size of each memory in the memory pool according to the memory upper limit value and the memory requirement of the next file synthesis stage.
  4. The memory allocation method according to claim 3, wherein the determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal comprises:
    and calculating a difference value between the residual memory space of the terminal and a preset memory threshold value, and determining the sum of the difference value and the total memory space of the memory pool as the memory upper limit value of the memory pool.
  5. The memory allocation method according to claim 3, before determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal, comprising:
    and if the system memory required to be applied is larger than the residual memory space of the terminal, detecting that the priority of the application currently running in the terminal is lower than that of the application synthesized by the file, and releasing the memory occupied by the application with the priority lower than that of the synthesized file.
  6. The memory allocation method according to any one of claims 2 to 5, wherein the detecting the remaining memory space of the terminal comprises:
    detecting the residual memory space of the terminal through a task manager of the system; alternatively, the first and second electrodes may be,
    and detecting the residual memory space of the terminal through the memory monitoring application.
  7. The memory allocation method according to claim 1, wherein the obtaining of the predetermined memory requirement of each file synthesis phase when performing incremental update on the file to be updated comprises:
    acquiring a difference file; the differential file records the processing task of each file to be processed when the file to be updated is subjected to incremental updating;
    determining the memory space required to be occupied in the task processing process of each file to be processed according to the processing task of each file to be processed recorded by the differential file;
    and predetermining the memory requirement of each file synthesis stage when the files to be updated are subjected to incremental updating according to the memory space required to be occupied in the task processing process of each file to be processed and the processing sequence of each file to be processed.
  8. The memory allocation method according to claim 7, wherein the obtaining the differential file comprises:
    and acquiring a file obtained by performing differential calculation on the file before the incremental update and the file after the incremental update.
  9. The memory allocation method according to claim 7, wherein the obtaining the differential file comprises:
    obtaining a differential file obtained by performing differential calculation on the first reduction file and the second reduction file; the first reduction file is obtained by reducing the file before the increment updating; the second reduction file is obtained by reducing the file after the increment updating.
  10. The memory allocation method according to claim 8 or 9, wherein before determining, according to the processing task of each to-be-processed file recorded by the differential file, a memory space that needs to be occupied in the processing process of each to-be-processed file task, the method includes:
    carrying out integrity check on the differential file;
    the determining, according to the processing task of each to-be-processed file recorded by the differential file, a memory space that needs to be occupied in the processing process of each to-be-processed file task includes:
    and if the integrity check is successful, determining the memory space required to be occupied in the processing process of each file task to be processed according to the processing task of each file to be processed recorded by the differential file.
  11. A memory allocation apparatus, comprising:
    the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring the predetermined memory requirement of each file synthesis stage when the files to be updated are subjected to incremental updating;
    a determining unit, configured to analyze memory requirements of two or more temporally consecutive file synthesis stages in each file synthesis stage, and determine a size of each memory in a memory pool in each file synthesis stage;
    and the distribution unit is used for applying and releasing the system memory according to the size of each memory in the memory pool of each file synthesis stage.
  12. A terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor when executing the computer program implements the steps of:
    acquiring the memory requirement of each file synthesis stage when the increment updating is carried out on the file to be updated which is determined in advance;
    analyzing the memory requirements of two or more than two temporally continuous file synthesis stages in each file synthesis stage, and determining the size of each memory in a memory pool in each file synthesis stage;
    and applying and releasing the system memory according to the size of each memory in the memory pool of each file synthesis stage.
  13. The terminal of claim 12, wherein the processor, when executing the computer program, further performs the steps of:
    detecting the residual memory space of the terminal before entering the next file synthesis stage;
    judging whether the system memory required to be applied is smaller than or equal to the residual memory space of the terminal or not according to the size of each memory in the memory pool of each file synthesis stage;
    and if the system memory required to be applied is smaller than or equal to the residual memory space of the terminal, applying for the system memory according to the size of each memory in the memory pool of each file synthesis stage.
  14. The terminal of claim 13, wherein the processor, when executing the computer program, further performs the steps of:
    if the system memory required to be applied is larger than the residual memory space of the terminal, determining the memory upper limit value of the memory pool according to the residual memory space of the terminal;
    and adjusting the size of each memory in the memory pool according to the memory upper limit value and the memory requirement of the next file synthesis stage.
  15. The terminal of claim 14, wherein the processor, when executing the computer program, further performs the steps of:
    and calculating a difference value between the residual memory space of the terminal and a preset memory threshold value, and determining the sum of the difference value and the total memory space of the memory pool as the memory upper limit value of the memory pool.
  16. The terminal of claim 14, wherein the processor, when executing the computer program, further performs the steps of:
    and if the system memory required to be applied is larger than the residual memory space of the terminal, detecting that the priority of the application currently running by the terminal is lower than that of the application synthesized by the file, and releasing the memory occupied by the application with the priority lower than that of the synthesized file.
  17. A terminal according to any of claims 13-16, wherein the processor, when executing the computer program, further performs the steps of:
    detecting the residual memory space of the terminal through a task manager of the system; alternatively, the first and second electrodes may be,
    and detecting the residual memory space of the terminal through the memory monitoring application.
  18. The terminal of claim 12, wherein the processor, when executing the computer program, further performs the steps of:
    acquiring a difference file; the differential file records the processing task of each file to be processed when the file to be updated is subjected to incremental updating;
    determining the memory space required to be occupied in the task processing process of each file to be processed according to the processing task of each file to be processed recorded by the differential file;
    and predetermining the memory requirement of each file synthesis stage when the files to be updated are subjected to incremental updating according to the memory space required to be occupied in the task processing process of each file to be processed and the processing sequence of each file to be processed.
  19. The terminal of claim 18, wherein the processor, when executing the computer program, further performs the steps of:
    and acquiring a file obtained by performing differential calculation on the file before the incremental update and the file after the incremental update.
  20. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 10.
CN201980100145.XA 2019-11-04 2019-11-04 Memory allocation method, device, terminal and computer readable storage medium Pending CN114365096A (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/115319 WO2021087662A1 (en) 2019-11-04 2019-11-04 Memory allocation method and apparatus, terminal, and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN114365096A true CN114365096A (en) 2022-04-15

Family

ID=75848693

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201980100145.XA Pending CN114365096A (en) 2019-11-04 2019-11-04 Memory allocation method, device, terminal and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN114365096A (en)
WO (1) WO2021087662A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113986141A (en) * 2021-11-08 2022-01-28 北京奇艺世纪科技有限公司 Server model updating method, system, electronic device and readable storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1327348C (en) * 2005-09-16 2007-07-18 浙江大学 Method for resolving frequently distributing and releasing equal size internal memory
US7694102B2 (en) * 2006-03-30 2010-04-06 International Business Machines Corporation Systems and methods for self-tuning memory
JP2011175395A (en) * 2010-02-24 2011-09-08 Canon Electronics Inc Information processor, image reading device, portable terminal, memory control method for information processor, and program
CN103544063B (en) * 2013-09-30 2017-02-08 三星电子(中国)研发中心 Method and device for removing processes applied to Android platform
CN107153618A (en) * 2016-03-02 2017-09-12 阿里巴巴集团控股有限公司 A kind of processing method and processing device of Memory Allocation
CN108762919A (en) * 2018-05-17 2018-11-06 桂林长海发展有限责任公司 A kind of program internal memory processing system and method

Also Published As

Publication number Publication date
WO2021087662A1 (en) 2021-05-14

Similar Documents

Publication Publication Date Title
CN107516534B (en) Voice information comparison method and device and terminal equipment
CN110830437B (en) Data compression method, device, equipment and storage medium for high-frequency service data
CN109684008B (en) Card rendering method, device, terminal and computer readable storage medium
CN107315729B (en) Data processing method, medium, device and computing equipment for chart
CN112165331A (en) Data compression method and device, data decompression method and device, storage medium and electronic equipment
CN108228344B (en) Multi-process memory processing method and device, computer device and readable storage medium
CN111880967A (en) File backup method, device, medium and electronic equipment in cloud scene
CN109828859B (en) Mobile terminal memory analysis method and device, storage medium and electronic equipment
CN113391947B (en) SSD RAID stripe power failure rapid recovery method, device, computer equipment and storage medium
US10802719B2 (en) Method and system for data compression and data storage optimization
CN111125033A (en) Space recovery method and system based on full flash memory array
CN111597158A (en) Log file rolling method and device, storage medium and terminal
CN114996173A (en) Method and device for managing write operation of storage equipment
CN111338759A (en) Virtual disk check code generation method, device, equipment and storage medium
CN114365096A (en) Memory allocation method, device, terminal and computer readable storage medium
CN112035401A (en) Model data processing method and device, electronic equipment and readable medium
CN109088636B (en) Data processing method and system, electronic equipment and storage medium
CN108053034B (en) Model parameter processing method and device, electronic equipment and storage medium
CN107577474B (en) Processing method and device for upgrading file and electronic equipment
CN111220876B (en) Transient recording data compression method, device, equipment and storage medium
CN110569114B (en) Service processing method, device, equipment and storage medium
CN107748711B (en) Method for automatically optimizing Storm parallelism, terminal equipment and storage medium
CN115454343A (en) Data processing method, device and medium based on RAID chip
CN111125467A (en) Method, system and equipment for outputting log file and readable storage medium
CN104598278B (en) A kind of data processing method and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination