Memory allocation method, device, terminal and computer-readable storage medium
By analyzing the memory requirements during the file synthesis stage and dynamically adjusting the size of each memory segment in the memory pool, the problems of memory thrashing and resource waste in incremental file updates are solved, thus optimizing the system's memory utilization efficiency.
Patent Information
- Application Number
- CN201980100145.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-04
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2039-11-04
AI Technical Summary
Existing technologies cannot effectively optimize system memory usage during incremental file updates, leading to memory thrashing and resource waste, which affects file update efficiency.
By analyzing the memory requirements of each file synthesis stage and combining the memory requirements of multiple file synthesis stages that are consecutive in time, the size of each memory segment in the memory pool is dynamically adjusted to optimize the allocation and release of system memory.
It achieves efficient use of system memory without reducing the efficiency of incremental file updates, avoiding memory thrashing and resource waste, and improving the efficiency of system memory utilization.
Smart Images

Figure CN114365096B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of memory control technology, and in particular, relates to a memory allocation method, device, terminal and computer-readable storage medium. Background Art
[0002] The statements here only provide background information related to the present application and do not necessarily constitute prior art. Incremental update is a data update method that generally synthesizes the file before the incremental update with the differential file to obtain the file after the incremental update. Summary of the invention
[0003] Embodiments of the present application provide a memory allocation method, device, terminal, and computer-readable storage medium, which can optimize the use of system memory when performing incremental file updates.
[0004] A first aspect of an embodiment of the present application provides a memory allocation method, comprising:
[0005] Obtaining predetermined memory requirements for each file synthesis phase when incrementally updating the file to be updated;
[0006] Analyzing the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determining the size of each piece of memory in the memory pool of each file synthesis stage;
[0007] The system memory is applied for and released according to the size of each piece of memory in the memory pool at each file synthesis stage.
[0008] A second aspect of an embodiment of the present application provides a memory allocation device, including:
[0009] An acquisition unit, used for acquiring a predetermined memory requirement of each file synthesis stage when performing an incremental update on a file to be updated;
[0010] A determination unit, configured to analyze the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determine the size of each piece of memory in the memory pool of each file synthesis stage;
[0011] The allocation unit is used to apply for and release system memory according to the size of each piece of memory in the memory pool at each file synthesis stage.
[0012] A third aspect of an embodiment 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, wherein the steps of the above method are implemented when the processor executes the computer program.
[0013] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the above method are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0015] Figure 1 This is a schematic diagram of a first implementation flow of a memory allocation method provided in an embodiment of the present application;
[0016] Figure 2 This is a schematic diagram of a specific implementation flow of step 103 of a memory allocation method provided in an embodiment of the present application;
[0017] Figure 3 This is a schematic diagram of a specific implementation flow of step 101 of a memory allocation method provided in an embodiment of the present application;
[0018] Figure 4 is a schematic diagram of the structure of a memory allocation device provided in an embodiment of the present application;
[0019] Figure 5 It is a schematic diagram of the structure of the terminal provided in the embodiment of the present application. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. At the same time, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0021] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0022] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0023] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0024] In order to illustrate the above technical solution of the present application, a specific embodiment is provided below for illustration.
[0025] Incremental update is a data update method. When updating data, this data update method generally synthesizes the file before the incremental update with the differential file to obtain the file after the incremental update.
[0026] With the continuous development of terminal technology, terminal applications are constantly updated, and terminals often need to perform incremental update operations on files in image libraries or application software. In addition, in the process of incremental updating of files, more memory space is generally required.
[0027] However, currently, the terminal can only allocate a fixed amount of memory space for incremental file updates, which cannot ensure the efficiency of incremental file updates while achieving reasonable use of system memory. In addition, during the incremental file update process, frequent memory requests and releases may cause memory jitter.
[0028] In response to the above problems, an embodiment of the present application provides a memory allocation method that can optimize the use of system memory when performing incremental updates of files. In addition, an embodiment of the present application provides a memory allocation method that can also solve the problem of memory jitter caused by frequent memory application and release during the incremental update process of files.
[0029] Specifically, Figure 1 A schematic diagram of the implementation flow of a memory allocation method provided in an embodiment of the present application is shown. The method is applied to a terminal and can be executed by a memory allocation device configured on the terminal. The terminal can be a smart terminal such as a mobile phone, a tablet, a wearable device, etc. The memory allocation method can include steps 101 to 103.
[0030] Step 101 : obtaining a predetermined memory requirement for each file synthesis stage when performing incremental update on a file to be updated.
[0031] In an embodiment of the present application, when incrementally updating the files to be updated, the incremental update process can be divided into multiple stages, that is, multiple file synthesis stages, and the next file synthesis stage needs to wait until the previous file synthesis stage is completed.
[0032] The above memory requirement at each file synthesis stage when incrementally updating the files to be updated refers to the actual memory requirement at each file synthesis stage.
[0033] For example, in the synthesis stage of a certain file, a 50M file and a 30M file need to be copied respectively, and the memory requirement of the synthesis stage of the file is a 50M memory and a 30M memory.
[0034] Step 102: Analyze the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determine the size of each memory piece in the memory pool of each file synthesis stage.
[0035] Since the predetermined memory requirement of each file synthesis stage when the file to be updated is incrementally updated can only represent the actual memory requirement of each file synthesis stage, and is not determined in combination with the memory requirements of other file synthesis stages, after obtaining the predetermined memory requirement of each file synthesis stage when the file to be updated is incrementally updated, the memory requirements of two or more file synthesis stages that are temporally consecutive in each file synthesis stage can be analyzed to obtain the size of each memory piece in the memory pool of each file synthesis stage determined by combining the memory requirements of other file synthesis stages, so that the terminal can effectively avoid the problem of memory jitter caused by frequent memory application and release.
[0036] For example, a file synthesis stage requires two 20M memory chips and one 10M memory chip, and the next file synthesis stage that is temporally continuous with the file synthesis stage (i.e., the file synthesis stage entered after completing the tasks of the file synthesis stage) requires one 20M memory chip and one 30M memory chip. When entering the next file synthesis stage, the three memory chips that have been applied for can be directly used without first releasing two 20M memory chips and one 10M memory chip, and then reapplying for one 20M memory chip and one 30M memory chip. This eliminates the need for frequent memory application and release during the file synthesis process, effectively avoiding the problem of memory jitter caused by frequent memory application and release.
[0037] For another example, when a certain file synthesis stage requires 50M of memory, and the next file synthesis stage that is temporally continuous with the file synthesis stage requires 40M of memory, and the next-to-next file synthesis stage requires 50M of memory, then when entering the next file synthesis stage, the system memory may not be requested or released, so that when entering the next-to-next file synthesis stage, the system memory may not be requested or released, thereby reducing the number of times the system memory is requested and released.
[0038] It should be noted that, in the above process of analyzing the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, it can be combined with the actual application scenario for comprehensive analysis. For example, by calculating the difference between the size of each piece of memory in the memory pool in the previous file synthesis stage and the size of each piece of memory in the memory pool in the next file synthesis stage, or the difference with the size of each piece of memory in the memory pool in the next file synthesis stage, it can be determined whether it is necessary to apply for and release system memory.
[0039] Step 103 , applying for and releasing system memory according to the size of each piece of memory in the memory pool at each file synthesis stage.
[0040] In an embodiment of the present application, by obtaining a predetermined memory requirement for each file synthesis stage when incrementally updating the file to be updated, and then analyzing the memory requirement for each file synthesis stage, the size of each piece of memory in the memory pool at each file synthesis stage is determined; the terminal can apply for and release system memory according to the size of each piece of memory in the memory pool at each file synthesis stage, realize dynamic update of each piece of memory in the memory pool, and ensure that the size of each piece of memory in the memory pool can be adapted to each file synthesis stage, rather than a fixed size of memory; when the terminal applies for and releases system memory according to the size of each piece of memory in the memory pool at each file synthesis stage, it will not cause waste of system resources due to excessive application of system memory, nor will it cause a reduction in the efficiency of incremental file updates due to too little application of system memory, thereby realizing reasonable use of system memory without reducing the efficiency of incremental file updates, that is, achieving a balance between efficiency and resources.
[0041] In addition, when applying for and releasing system memory, the present application analyzes the memory requirements of two or more file synthesis stages that are temporally consecutive in each file synthesis stage, and determines the memory according to the size of each piece of memory in the memory pool of each file synthesis stage. Therefore, when applying for and releasing system memory according to the size of each piece of memory in the memory pool of each file synthesis stage, the memory to be applied for or released in each file synthesis stage can be pre-planned according to the memory requirements of two or more file synthesis stages that are temporally consecutive. Therefore, when applying for and releasing system memory according to the size of each piece of memory in the memory pool of each file synthesis stage, the problem of memory jitter caused by frequent memory applications and releases can be avoided.
[0042] In some embodiments of the present application, Figure 2 As shown, in the above step 103, the application for system memory is performed according to the size of each memory in the memory pool in each file synthesis stage, and can also include: steps 201 to 203.
[0043] Step 201, before entering the next file synthesis phase, detecting the remaining memory space of the terminal.
[0044] Because when the terminal system is running, while implementing the incremental update of the file to be updated, it may also be running other applications or performing other tasks, which require a certain amount of memory. Therefore, in order to avoid occupying too much memory when performing incremental updates of the file to be updated and affecting the operation of other applications or other tasks, it is necessary to detect the remaining memory space of the terminal before entering the next file synthesis stage each time during the incremental update of the file to be updated to determine whether the remaining memory space of the terminal is sufficient.
[0045] Specifically, in some embodiments of the present application, the above-mentioned detection of the remaining memory space of the terminal may include: detecting the remaining memory space of the terminal through a task manager of the system; or detecting the remaining memory space of the terminal through a memory monitoring application.
[0046] It should be noted that in some embodiments of the present application, the task manager can also detect the memory size occupied by each application currently running on the terminal. The memory monitoring application refers to an application used to detect the remaining memory space of the terminal. Specifically, when the memory monitoring application is started, the remaining memory space of the terminal can be detected.
[0047] Step 202: judging whether the system memory to be applied for is less than or equal to the remaining memory space of the terminal according to the size of each memory in the memory pool at each file synthesis stage.
[0048] In an embodiment of the present application, since the size of each piece of memory in the memory pool of each file synthesis stage has been obtained by analyzing the memory requirements of two or more file synthesis stages that are temporally consecutive in each file synthesis stage, when entering the next file synthesis stage, the system memory that needs to be applied for can be determined, and then it can be determined whether the system memory that needs to be applied for is less than or equal to the remaining memory space of the terminal.
[0049] Step 203: If the system memory to be applied for is less than or equal to the remaining memory space of the terminal, the system memory is applied for according to the size of each memory in the memory pool at each file synthesis stage.
[0050] In an embodiment of the present application, when the system memory to be applied for is less than or equal to the remaining memory space of the terminal, it means that the remaining memory space of the terminal is relatively sufficient, and when the updated file is incrementally updated, it will not affect the operation of other applications of the terminal. Therefore, the system memory can be applied directly according to the size of each piece of memory in the memory pool in each file synthesis stage to improve the efficiency of incremental updates.
[0051] However, when the system memory required is larger than the remaining memory space of the terminal, it means that the remaining memory space of the terminal is relatively tight, and it is possible that the incremental update of the updated file will occupy too much memory, affecting the operation of the terminal application. Figure 2 As shown, in some embodiments of the present application, after judging whether the system memory to be applied for 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 synthesis stage, steps 204 to 205 may also be included to ensure that the operation of certain applications of the terminal is not affected by incremental updates.
[0052] Step 204: If the system memory to be applied for is larger than the remaining memory space of the terminal, determine the memory upper limit value of the memory pool according to the remaining memory space of the terminal.
[0053] Among them, the above-mentioned determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal may include: calculating the difference between the remaining memory space of the terminal and a preset memory threshold, and determining the sum of the difference and the total memory space of the memory pool as the memory upper limit value of the memory pool.
[0054] The preset memory threshold can be the remaining memory space to ensure that the terminal's system applications will not be killed due to sudden memory occupation. That is, the minimum memory that the terminal needs to reserve. The total memory space of the memory pool refers to the sum of the size of each system memory that has been applied for in the memory pool before entering the next file synthesis stage.
[0055] In some embodiments of the present application, before determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal, it may also include: if the system memory to be applied for is greater than the remaining memory space of the terminal, detecting the application whose priority among the applications currently running on the terminal is lower than that of file synthesis, and releasing the memory occupied by the application whose priority is lower than that of file synthesis; thereby increasing the remaining memory space of the above-mentioned terminal, and correspondingly, the memory upper limit value of the memory pool will also increase, thereby increasing the memory space allocated to the incremental update process and improving the speed of incremental updates.
[0056] Step 205: adjust 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.
[0057] In an embodiment of the present application, when the system memory to be applied for is greater than the remaining memory space of the terminal and the remaining memory space of the terminal is relatively tight, in order to avoid occupying too much memory when performing incremental updates of the files to be updated, thereby affecting the operation of the terminal application, after determining the memory upper limit value of the memory pool according to the remaining memory space of the above-mentioned terminal, the size of each piece of memory in the memory pool can be adjusted according to the above-mentioned memory upper limit value and the memory requirement of the next file synthesis stage, so as to maximize the efficiency of incremental updates and optimize the use of system memory.
[0058] Specifically, adjusting the size of each memory slice in the memory pool according to the memory upper limit value and the memory requirement of the next file synthesis stage refers to reducing the size of some memory slices according to the actual memory requirement of the next file synthesis stage without exceeding the memory upper limit value.
[0059] For example, when the memory upper limit is 50M, and the actual memory requirement of the next file synthesis stage is one 40M memory and three 10M memory, the above 40M memory can be adjusted to 20M memory.
[0060] like Figure 3 As shown, in some implementations of the present application, the above step 101, obtaining the predetermined memory requirement of each file synthesis stage when incrementally updating the file to be updated, may include: steps 301 to 303.
[0061] Step 301, obtaining a differential file; the differential file records the processing task of each file to be processed when the file to be updated is incrementally updated.
[0062] A differential file refers to a file that records the changes in the contents of two files. When the terminal performs an incremental update on a file to be updated, it must first obtain the differential file corresponding to the file to be updated, and then synthesize the incremental file with the file to be updated to obtain the file after the incremental update of the file to be updated.
[0063] In the embodiment of the present application, obtaining the differential file may include: obtaining a file obtained by performing differential calculation on the file before the incremental update and the file after the incremental update. That is, the differential file is obtained by directly performing differential calculation on the file before the incremental update and the file after the incremental update.
[0064] However, the differential file obtained by directly performing differential calculation on the file before the incremental update and the file after the update often has the problem of too large a data volume.
[0065] For example, the content of the file before the incremental update is the binary character obtained by compressing the characters "aaabbb", and the compression dictionary of the compression algorithm is 0 for aaa and 1 for bbb, then the file before the incremental update is "01". At this time, if the file before the incremental update is incrementally updated, the content of the file after the incremental update is the binary character obtained by compressing the characters "aaabb". Then, due to the change of the file content, the compression dictionary corresponding to the same compression algorithm will change. For example, the compression dictionary changes to 0 for a and 1 for b, then the file after the incremental update will be changed to "00011". It can be seen that when the file before the incremental update is incrementally updated, although only one character is changed in the pre-compression characters "aaabbb" corresponding to the file before the incremental update, that is, "aaabbb" is changed to "aaabb", the binary character obtained after compression corresponding to the file after the incremental update will be greatly changed, that is, from "01" to "00011". Therefore, the differential file obtained by directly performing differential calculation on the file before the incremental update and the file after the incremental update has the problem of too large a data volume.
[0066] In view of this, in some other embodiments of the present application, obtaining the above-mentioned differential file may also include: obtaining a differential file obtained by performing differential calculation on a first restored file and a second restored file; the first restored file is a file obtained by restoring the file before the incremental update; the second restored file is a file obtained by restoring the file after the incremental update.
[0067] Specifically, when the file before the incremental update is a file in a preset compression format, the first restored 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.
[0068] When the file before the incremental update is a file in another preset format, the first restored file is a file obtained by converting the format of the file before the incremental update; the second restored file is a file obtained by converting the format of the compressed file after the incremental update.
[0069] For example, when the file before the incremental update is a picture file in JPG format or a picture file in PNG format, the first restored file is a file in BMP bitmap format obtained by converting the format of the file before the incremental update.
[0070] It should be noted that this is merely an example, and the above-mentioned other files in preset formats may also include files in various other formats.
[0071] In an embodiment of the present application, a differential file is obtained by performing differential calculation on a first restored file and a second restored file, so that the amount of data of the differential file obtained can be smaller, which is beneficial to improving the download speed of the differential file. However, this will make it necessary to first decompress the file to be updated when incrementally updating the file to be updated, and then synthesize the decompressed file with the differential file, and finally compress the synthesized file to obtain the final incremental updated file. This series of compression, synthesis and decompression operations requires a large amount of system memory. Therefore, in order to reasonably use the system memory, it is necessary to predetermine the memory requirements of each file synthesis stage when the file to be updated is incrementally updated, and then analyze the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determine the size of each piece of memory in the memory pool of each file synthesis stage, so that when applying for and releasing system memory according to the size of each piece of memory in the memory pool of each file synthesis stage, flexible memory application and reuse can be achieved to optimize the use of system memory.
[0072] Step 302: Determine the memory space required for processing each to-be-processed file task according to the processing task of each to-be-processed file recorded in the differential file.
[0073] In an embodiment of the present application, when the above-mentioned differential file is a differential file obtained by directly performing differential calculation on the file before the incremental update and the file after the update, the above-mentioned file to be processed refers to each file after the incremental update, and the above-mentioned determination of the memory space required to be occupied during the task processing of each file to be processed refers to determining the memory space required to be occupied by each file after each incremental update.
[0074] When the above-mentioned differential file is a differential file obtained by performing differential calculation on the first restored file and the second restored file, and the above-mentioned first restored file is a file obtained by decompressing the file before the incremental update, then the above-mentioned files to be processed refer to each file to be decompressed in the compressed file before the incremental update, each file to be synthesized that needs to be synthesized with the differential file after decompression, and each file to be compressed after synthesis with the differential file.
[0075] That is to say, the memory space required to be occupied during the processing of each of the above-mentioned to-be-processed file tasks includes the memory space required to be occupied by the processing tasks of each file to be decompressed, each file to be synthesized, and each file to be compressed.
[0076] Step 303 , predetermine the memory requirement of each file synthesis stage when incrementally updating the files to be updated according to the memory space required to be occupied during the processing of each file to be processed task and the processing order of each file to be processed.
[0077] When incrementally updating the files to be updated, there is a certain processing order for each file to be processed. For example, during incremental updating, it is necessary to first decompress the compressed file before the incremental update, and then synthesize the decompressed file and the differential file to obtain the synthesized file, and then compress the synthesized file to obtain the compressed file after the incremental update. That is, the above-mentioned file synthesis stage can be divided into a decompression stage, a synthesis stage, and a compression stage in sequence. Therefore, when determining the memory requirement of each file synthesis stage when incrementally updating the files to be updated, it is necessary to determine it based on the memory space required to be occupied during the processing of each file task to be processed and the processing order of each file to be processed.
[0078] In order to further improve the efficiency of incremental updates and avoid incremental update failures due to incomplete differential files, in some embodiments of the present application, before determining the memory space required for processing each file to be processed task based on the processing tasks of each file to be processed recorded in the differential file, it includes: performing an integrity check on the differential file.
[0079] Specifically, due to the influence of various factors during the data transmission process, the differential file received by the terminal processor may be inconsistent with the differential file sent by the server, that is, an error occurred in the differential file during the transmission process. Therefore, in order to avoid the failure of incremental updates caused by errors in data transmission and improve the efficiency of incremental updates, in some implementations of the present application, before the incremental update of the file to be updated, the differential file received by the terminal can be compared with the differential file sent by the server to determine whether the received differential file is consistent with the differential file sent by the server.
[0080] For example, a cyclic redundancy check (CRC) method 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 may also use data verification methods such as direct comparison method, parity check method, XOR check method, Hamming code check method, 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 all belong to the concept of the present application.
[0081] It should be noted that, for the sake of simplicity of description, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps may be performed in other orders.
[0082] Figure 4 A schematic structural diagram of a memory allocation device 400 provided in an embodiment of the present application is shown. The memory allocation device 400 is configured in a terminal and includes an acquisition unit 401, a determination unit 402 and an allocation unit 403.
[0083] An acquisition unit 401 is used to acquire a predetermined memory requirement for each file synthesis stage when performing incremental update on the file to be updated;
[0084] The determining unit 402 is used to analyze the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determine the size of each memory in the memory pool of each file synthesis stage;
[0085] The allocation unit 403 is used to apply for and release system memory according to the size of each memory piece in the memory pool at each file synthesis stage.
[0086] It should be noted that, for the convenience and simplicity of description, the specific working process of the memory allocation device 400 described above can refer to the above Figures 1 to 3 The corresponding process of the method described in will not be repeated here.
[0087] like Figure 5 As shown, the present application provides a terminal for implementing the above-mentioned memory allocation method, including: a processor 51, a memory 52, and a computer program stored in the memory and executable on the processor. When the processor 51 executes the computer program, the following steps are implemented:
[0088] Obtaining predetermined memory requirements for each file synthesis phase when incrementally updating the file to be updated;
[0089] Analyzing the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determining the size of each piece of memory in the memory pool of each file synthesis stage;
[0090] The system memory is applied for and released according to the size of each piece of memory in the memory pool at each file synthesis stage.
[0091] Assuming that the above is the first possible implementation, in a second possible implementation provided on the basis of the first possible implementation, the processor further implements the following steps when executing the computer program:
[0092] Before entering the next file synthesis phase, check the remaining memory space of the terminal;
[0093] Determining whether the system memory to be applied for is less than or equal to the remaining memory space of the terminal according to the size of each memory in the memory pool at each file synthesis stage;
[0094] If the system memory to be applied for is less than or equal to the remaining memory space of the terminal, the system memory is applied for according to the size of each memory in the memory pool at each file synthesis stage.
[0095] In a third possible implementation provided on the basis of the second possible implementation, the processor further implements the following steps when executing the computer program:
[0096] If the system memory required to be applied for is greater 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;
[0097] The size of each piece of memory in the memory pool is adjusted according to the memory upper limit value and the memory requirement of the next file synthesis stage.
[0098] In a fourth possible implementation provided on the basis of the third possible implementation, the processor further implements the following steps when executing the computer program:
[0099] The difference between the remaining memory space of the terminal and a preset memory threshold is calculated, and the sum of the difference and the total memory space of the memory pool is determined as the memory upper limit value of the memory pool.
[0100] In a fifth possible implementation provided on the basis of the third possible implementation, the processor further implements the following steps when executing the computer program:
[0101] If the system memory to be applied for is larger than the remaining memory space of the terminal, an application with a lower priority than file synthesis among the applications currently running on the terminal is detected, and the memory occupied by the application with a lower priority than file synthesis is released.
[0102] In a sixth possible implementation provided on the basis of the second possible implementation, the third possible implementation, the fourth possible implementation, and the fifth possible implementation, the processor further implements the following steps when executing the computer program:
[0103] Check the remaining memory space of the terminal through the system's task manager; or,
[0104] Use the memory monitoring application to check the remaining memory space on the terminal.
[0105] In a seventh possible implementation provided on the basis of the first possible implementation, the processor further implements the following steps when executing the computer program:
[0106] Obtaining a differential file; the differential file records the processing task of each file to be processed when the file to be updated is incrementally updated;
[0107] Determine the memory space required for processing each to-be-processed file task according to the processing task of each to-be-processed file recorded in the differential file;
[0108] The memory requirement of each file synthesis stage when the to-be-processed file is incrementally updated is predetermined according to the memory space required to be occupied during the processing of each to-be-processed file task and the processing order of each to-be-processed file.
[0109] In an eighth possible implementation provided on the basis of the seventh possible implementation, the processor further implements the following steps when executing the computer program:
[0110] Get a file obtained by performing differential calculation on a file before the incremental update and a file after the incremental update.
[0111] In a ninth possible implementation provided on the basis of the seventh possible implementation, the processor further implements the following steps when executing the computer program:
[0112] Obtain a differential file obtained by performing differential calculation on a first restored file and a second restored file; the first restored file is a file obtained by restoring the file before the incremental update; the second restored file is a file obtained by restoring the file after the incremental update.
[0113] In a tenth possible implementation provided on the basis of the eighth possible implementation and the ninth possible implementation, when the processor executes the computer program, the processor further implements the following steps:
[0114] Performing integrity check on the differential file;
[0115] The determining, according to the processing task of each to-be-processed file recorded in the differential file, the memory space required to be occupied during the processing of each to-be-processed file task includes:
[0116] If the integrity check succeeds, the memory space required to be occupied during the processing of each to-be-processed file task is determined according to the processing task of each to-be-processed file recorded in the differential file.
[0117] Furthermore, if Figure 5 As shown, the terminal described above may also include: one or more input devices 53 ( Figure 5 only one is shown) and one or more output devices 54 ( Figure 5 The processor 51, the memory 52, the input device 53 and the output device 54 are connected via a bus 55.
[0118] 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-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0119] The input device 53 may include a virtual keyboard, a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint direction information), a microphone, etc., and the output device 54 may include a display, a speaker, etc.
[0120] The memory 52 may include a read-only memory and a random access memory, and provides instructions and data to the processor 51. A part or all of the memory 52 may also include a non-volatile random access memory. For example, the memory 52 may also store information on the device type.
[0121] The memory 52 stores a computer program, which can be run on the processor 51. For example, the computer program is a program for a memory allocation method. When the processor 51 executes the computer program, the steps in the memory allocation method embodiment are implemented. For example, Figure 1 Alternatively, when the processor 51 executes the computer program, the functions of each module / unit in the above-mentioned device embodiments are realized, for example, Figure 4 The functions of units 401 to 403 are shown.
[0122] The above-mentioned computer program can be divided into one or more modules / units, and the above-mentioned one or more modules / units are stored in the above-mentioned memory 52 and executed by the above-mentioned processor 51 to complete the present application. The above-mentioned one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the above-mentioned computer program in the first terminal for performing the above-mentioned memory allocation method. For example, the above-mentioned computer program can be divided into an acquisition unit, a determination unit and an allocation unit, and the specific functions of each unit are as follows:
[0123] An acquisition unit, used for acquiring a predetermined memory requirement of each file synthesis stage when performing an incremental update on a file to be updated;
[0124] A determination unit, configured to analyze the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determine the size of each piece of memory in the memory pool of each file synthesis stage;
[0125] The allocation unit is used to apply for and release system memory according to the size of each piece of memory in the memory pool at each file synthesis stage.
[0126] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0127] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0128] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0129] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are only schematic. For example, the division of the above modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0130] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0131] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0132] If the above-mentioned integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form. The above-mentioned computer-readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (RandomAccess Memory, RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the above-mentioned computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0133] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some of the technical features therein by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A memory allocation method, characterized in that: include: Obtaining predetermined memory requirements for each file synthesis phase when incrementally updating the file to be updated; Analyzing the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determining the size of each piece of memory in the memory pool of each file synthesis stage; The system memory is applied for and released according to the size of each piece of memory in the memory pool at each file synthesis stage.
2. The memory allocation method according to claim 1, characterized in that: The applying for system memory according to the size of each piece of memory in the memory pool at each file synthesis stage includes: Before entering the next file synthesis phase, check the remaining memory space of the terminal; Determining whether the system memory to be applied for is less than or equal to the remaining memory space of the terminal according to the size of each memory in the memory pool at each file synthesis stage; If the system memory to be applied for is less than or equal to the remaining memory space of the terminal, the system memory is applied for according to the size of each memory in the memory pool at each file synthesis stage.
3. The memory allocation method according to claim 2, characterized in that: After judging whether the system memory to be applied for is less than or equal to the remaining memory space of the terminal according to the size of each memory in the memory pool in each file synthesis stage, the method includes: If the system memory required to be applied for is greater 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 size of each piece of memory in the memory pool is adjusted 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, characterized in that: The determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal includes: The difference between the remaining memory space of the terminal and a preset memory threshold is calculated, and the sum of the difference and the total memory space of the memory pool is determined as the memory upper limit value of the memory pool.
5. The memory allocation method according to claim 3, characterized in that: Before determining the memory upper limit value of the memory pool according to the remaining memory space of the terminal, the method includes: If the system memory to be applied for is larger than the remaining memory space of the terminal, an application with a lower priority than file synthesis among the applications currently running on the terminal is detected, and the memory occupied by the application with a lower priority than file synthesis is released.
6. The memory allocation method according to any one of claims 2 to 5, characterized in that: The remaining memory space of the detection terminal includes: Check the remaining memory space of the terminal through the system's task manager; or, Use the memory monitoring application to check the remaining memory space on the terminal.
7. The memory allocation method according to claim 1, characterized in that: The obtaining of the predetermined memory requirement of each file synthesis stage when performing incremental update on the file to be updated includes: Obtaining a differential file; the differential file records the processing task of each file to be processed when the file to be updated is incrementally updated; Determine the memory space required for processing each to-be-processed file task according to the processing task of each to-be-processed file recorded in the differential file; The memory requirement of each file synthesis stage when the to-be-processed file is incrementally updated is predetermined according to the memory space required to be occupied during the processing of each to-be-processed file task and the processing order of each to-be-processed file.
8. The memory allocation method according to claim 7, characterized in that: The obtaining of the differential file comprises: Get a file obtained by performing differential calculation on a file before the incremental update and a file after the incremental update.
9. The memory allocation method according to claim 7, characterized in that: The obtaining of the differential file comprises: Obtain a differential file obtained by performing differential calculation on a first restored file and a second restored file; the first restored file is a file obtained by restoring the file before the incremental update; the second restored file is a file obtained by restoring the file after the incremental update.
10. The memory allocation method according to claim 8 or 9, characterized in that: Before determining the memory space required to be occupied in the processing of each to-be-processed file task according to the processing task of each to-be-processed file recorded in the differential file, the method includes: Performing integrity check on the differential file; The determining, according to the processing task of each to-be-processed file recorded in the differential file, the memory space required to be occupied during the processing of each to-be-processed file task includes: If the integrity check succeeds, the memory space required to be occupied during the processing of each to-be-processed file task is determined according to the processing task of each to-be-processed file recorded in the differential file.
11. A memory allocation device, characterized in that: include: An acquisition unit, used for acquiring a predetermined memory requirement of each file synthesis stage when performing an incremental update on a file to be updated; A determination unit, configured to analyze the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determine the size of each piece of memory in the memory pool of each file synthesis stage; The allocation unit is used to apply for and release system memory according to the size of each piece of memory in the memory pool at 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, characterized in that: When the processor executes the computer program, the following steps are implemented: Obtaining predetermined memory requirements for each file synthesis phase when incrementally updating the file to be updated; Analyzing the memory requirements of two or more file synthesis stages that are consecutive in time in each file synthesis stage, and determining the size of each piece of memory in the memory pool of each file synthesis stage; The system memory is applied for and released according to the size of each piece of memory in the memory pool at each file synthesis stage.
13. The terminal according to claim 12, characterized in that: When the processor executes the computer program, the following steps are also implemented: Before entering the next file synthesis phase, check the remaining memory space of the terminal; Determining whether the system memory to be applied for is less than or equal to the remaining memory space of the terminal according to the size of each memory in the memory pool at each file synthesis stage; If the system memory to be applied for is less than or equal to the remaining memory space of the terminal, the system memory is applied for according to the size of each memory in the memory pool at each file synthesis stage.
14. The terminal according to claim 13, characterized in that: When the processor executes the computer program, the following steps are also implemented: If the system memory required to be applied for is greater 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 size of each piece of memory in the memory pool is adjusted according to the memory upper limit value and the memory requirement of the next file synthesis stage.
15. The terminal according to claim 14, characterized in that When the processor executes the computer program, the following steps are also implemented: The difference between the remaining memory space of the terminal and a preset memory threshold is calculated, and the sum of the difference and the total memory space of the memory pool is determined as the memory upper limit value of the memory pool.
16. The terminal according to claim 14, characterized in that When the processor executes the computer program, the following steps are also implemented: If the system memory to be applied for is larger than the remaining memory space of the terminal, an application with a lower priority than file synthesis among the applications currently running on the terminal is detected, and the memory occupied by the application with a lower priority than file synthesis is released.
17. The terminal according to any one of claims 13 to 16, characterized in that: When the processor executes the computer program, the following steps are also implemented: Check the remaining memory space of the terminal through the system's task manager; or, Use the memory monitoring application to check the remaining memory space on the terminal.
18. The terminal according to claim 12, characterized in that: When the processor executes the computer program, the following steps are also implemented: Obtaining a differential file; the differential file records the processing task of each file to be processed when the file to be updated is incrementally updated; Determine the memory space required for processing each to-be-processed file task according to the processing task of each to-be-processed file recorded in the differential file; The memory requirement of each file synthesis stage when the to-be-processed file is incrementally updated is predetermined according to the memory space required to be occupied during the processing of each to-be-processed file task and the processing order of each to-be-processed file.
19. The terminal according to claim 18, characterized in that When the processor executes the computer program, the following steps are also implemented: Get a file obtained by performing differential calculation on a file before the incremental update and a file after the incremental update.
20. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
On-orbit maintenance method of satellite-borne embedded software
CN102799502A
Fragmented-file storage method based on distributed storage system
CN103488685A
