Memory management method and device, equipment and storage medium

By generating submodule information tables and elimination tables, memory is given priority, which solves the problems of inconsistent memory elimination mechanisms and high CPU consumption in existing memory management systems, improves system performance and overcomes differences in hardware environment and database versions.

CN119322674APending Publication Date: 2025-01-17GUANGZHOU AVA ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411288105.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-13
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

When facing a large amount of data storage, the existing memory management system lacks a unified memory management mechanism, resulting in limited types of memory elimination mechanisms, high CPU consumption, and inconsistent memory management caused by differences in hardware environment and database versions, affecting system performance.

Method used

By generating and maintaining information tables for each submodule, generating an obsolete table based on access time and memory size usage, priority is given to freeing memory, avoiding CPU shocks, and dumping data to the hard disk when necessary to free up memory.

Benefits of technology

The overall performance improvement of the system has been achieved, the CPU impact caused by the timing and regular elimination mechanisms is avoided, the problems of hardware environment differences and database version inconsistent, and the unity and efficiency of memory management are overcome.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119322674A_ABST
    Figure CN119322674A_ABST
Patent Text Reader

Abstract

The invention discloses a memory management method and device, equipment and a storage medium. The method comprises the following steps: generating and maintaining an information table of each sub-module; generating an elimination table according to the information table of each sub-module; according to the information table of each sub-module, judging whether the total memory usage amount used by all the sub-modules is greater than or equal to a total available memory preset threshold value or not; when the total memory usage amount is greater than or equal to a total available memory preset threshold value, selecting a to-be-processed sub-module according to the elimination table; and calling the API of the to-be-processed sub-module, and enabling the to-be-processed sub-module to empty the corresponding memory content according to the cleaning rule of the to-be-processed sub-module. According to the method, the memory is orderly released according to the priorities of the memory sub-modules, CPU impact caused by timed and regular elimination mechanisms in a data structure and a memory database in the prior art is avoided, and the overall performance of the system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer storage, and more specifically, to a memory management method, device, equipment and storage medium. Background Art

[0002] In software systems, some data that need to be frequently searched is often stored in memory. This data is managed in data structures, Redis, Memcached, Tair, FastDB, SAP HANA, Oracle TimesTen, VoltDB, Apache Ignite, MongoDB, etc. With long-term operation and the growth of business volume, the data in memory will become larger and larger, and it is easy to exceed the storage memory limit MemThreshold set by the system. At this time, if the memory is not released in time, on the one hand, it will affect the subsequent data storage, and on the other hand, it will cause a sharp decline in data query performance.

[0003] Although data structures or in-memory databases such as Redis, Memcached, and MongoDB all have built-in memory elimination mechanisms, these mechanisms still have several major problems:

[0004] 1. There are limited types of built-in elimination mechanisms, and each has its own advantages and disadvantages. For example, scheduled elimination will cause a surge in CPU usage when elimination is started, seriously affecting business; inert expiration elimination will result in a large amount of expired data that cannot be eliminated and memory cannot be released in extreme cases.

[0005] 2. The built-in elimination mechanism has requirements for the database version and the hardware environment, so the built-in elimination mechanism that can take effect on different devices for the same set of programs may be different.

[0006] 3. Modern software programs often use multiple databases and a large number of data structures at the same time, but there is currently a lack of a unified memory management mechanism to coordinate the management of these storage modules. Summary of the invention

[0007] In order to overcome at least one of the above-mentioned defects of the prior art, the present invention provides a method, device, equipment and storage medium for memory management. The technical solution adopted by the present invention is as follows.

[0008] In a first aspect, the present invention provides a memory management method, comprising:

[0009] Generate and maintain an information table for each submodule, wherein each submodule is a business type, and the information table includes: the access time and memory size usage of each submodule, wherein each time a submodule is accessed, the access time needs to be updated to the system time when the submodule is accessed, and if there is an increase or decrease in the content involved, the memory size usage needs to be updated;

[0010] Generate an elimination table according to the information table of each submodule, wherein the elimination table is a table of the order of clearing the memory of each submodule based on the access time and memory size usage of each submodule;

[0011] According to the information table of each sub-module, determine whether the total memory usage used by all sub-modules is greater than or equal to the total available memory preset threshold;

[0012] When the total memory usage is greater than or equal to a preset threshold of the total available memory, selecting a submodule to be processed according to the elimination table;

[0013] Call the API of the submodule to be processed, so that the submodule to be processed clears the corresponding memory content according to its own cleaning rules.

[0014] In one implementation, the process of generating an elimination table according to the information table of each submodule includes:

[0015] Calculate the time interval of each submodule, wherein the time interval is the interval between the access time and the current time;

[0016] Sort the lists from largest to smallest using time interval as the primary keyword. If the time intervals are the same, sort the lists from smallest to largest using memory usage as the secondary keyword to get the sorted list.

[0017] An elimination table is generated according to the sorted list.

[0018] In one embodiment, it further includes:

[0019] If after the process of calling the API of the sub-module to be processed and allowing the sub-module to be processed to clear the corresponding memory content according to its own cleaning rules, the total memory usage is still greater than or equal to the total available memory preset threshold, continue to select the sub-module to be processed from the unselected sub-modules according to the elimination table, and call the API of the sub-module to be processed, so that the sub-module to be processed can clear the corresponding memory content according to its own cleaning rules, until the total memory usage is less than the total available memory preset threshold.

[0020] In one embodiment, it further includes:

[0021] After calling the API of the submodule to be processed and clearing its own corresponding memory content, update the memory size usage in the information table of the corresponding submodule;

[0022] After all sub-modules have been selected as sub-modules to be processed and their corresponding memory contents have been emptied according to their respective cleaning rules, when the total memory usage is still greater than or equal to the total available memory preset threshold, the elimination table is regenerated according to the information table of each sub-module;

[0023] Select the submodule to be processed for the second time according to the regenerated elimination table;

[0024] Dump the content in the submodule to be processed for the second time to a hard disk or other peripheral device, and clear the content in the submodule to be processed for the second time.

[0025] In one embodiment, it further includes:

[0026] If after the process of dumping the content of the sub-module to be processed for the second time to the hard disk or other peripheral device and clearing the content of the sub-module to be processed for the second time, the total memory usage is still greater than or equal to the total available memory preset threshold, continue to select the sub-module to be processed for the second time from the sub-modules that have not been selected according to the regenerated elimination table, dump the content of the sub-module to be processed for the second time to the hard disk or other peripheral device, and clear the content of the sub-module to be processed for the second time, until the total memory usage is less than the total available memory preset threshold.

[0027] In one implementation, the process of regenerating the elimination table according to the information table of each submodule includes:

[0028] Sort the lists from largest to smallest using time interval as the primary keyword. If the time intervals are the same, sort the lists from smallest to largest using memory usage as the secondary keyword to get the re-sorted list.

[0029] The elimination table is regenerated according to the reordered list.

[0030] In a second aspect, the present invention provides a memory management device, comprising:

[0031] A management module is used to generate and maintain an information table for each submodule, wherein each submodule is a service type, and the information table includes: the access time and memory size usage of each submodule, wherein each time a submodule is accessed, the access time needs to be updated to the system time when the submodule is accessed, and if there is an increase or decrease in the content involved, the memory size usage needs to be updated;

[0032] A generation module, used to generate an elimination table according to the information table of each sub-module, wherein the elimination table is a table of the order of clearing the memory of each sub-module based on the access time and memory size usage of each sub-module;

[0033] The analysis module is used to determine whether the total memory usage used by all sub-modules is greater than or equal to a preset threshold of total available memory according to the information table of each sub-module;

[0034] The execution module is used to select the sub-module to be processed according to the elimination table when the total memory usage is greater than or equal to the preset threshold of the total available memory, call the API of the sub-module to be processed, and let the sub-module to be processed clear the corresponding memory content according to its own cleaning rules.

[0035] In one embodiment, it includes: the execution module is also used to continue to select the sub-module to be processed from the unselected sub-modules according to the elimination table, and call the API of the sub-module to be processed, so that the sub-module to be processed can clear the corresponding memory content according to its own cleaning rules, if the total memory usage is still greater than or equal to the total available memory preset threshold after the process of calling the API of the sub-module to be processed and allowing the sub-module to be processed to clear the corresponding memory content according to its own cleaning rules, until the total memory usage is less than the total available memory preset threshold.

[0036] In a third aspect, the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned methods when executing the program.

[0037] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method of any of the above-mentioned embodiments.

[0038] In the present invention, by monitoring the memory usage in each business submodule, the order in which each business submodule needs to clean up the memory is coordinated in general, and the total memory usage of each business submodule is checked. Once it is greater than or equal to a preset threshold, the business module is immediately arranged to clean up according to its own existing rules according to the coordinated order. In the present invention, the memory is released in an orderly manner according to the priority of the memory submodule, and on the basis of limiting the memory usage, the overall performance of the system is improved, and the memory management is triggered every time the memory changes, and the triggering timing is discretized, thereby avoiding the CPU impact caused by the timing, periodicity and other elimination mechanisms in the data structure of the prior art, and finally overcomes the problems of hardware environment differences, inconsistent database versions and inconsistent built-in elimination mechanisms. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a schematic diagram of the overall process of an implementation method of Example 1 of the present invention.

[0040] Figure 2 It is a software architecture module diagram of the first embodiment of the present invention.

[0041] Figure 3 It is a schematic diagram of a judgment flow of an implementation method of the first embodiment of the present invention.

[0042] Figure 4 It is a schematic diagram of a judgment flow of another implementation method of the first embodiment of the present invention.

[0043] Figure 5 It is a schematic diagram of the overall structure of the second embodiment of the present invention. DETAILED DESCRIPTION

[0044] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0045] It should be noted that the terms "first\second\..." involved in the embodiments of the present invention are only used to distinguish similar objects, and do not represent a specific order for the objects. It is understandable that the specific order or sequence of "first\second\..." can be interchanged where permitted. It should be understood that the objects distinguished by "first\second\..." can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein.

[0046] Embodiment 1

[0047] See also Figure 1 , Figure 1 1 is a flow chart of a memory management method provided in Embodiment 1 of the present invention, the method comprising step S110, step S120, step S130, step S140 and step S150. It should be noted that step S110, step S120, step S130, step S140 and step S150 are merely reference numerals for the purpose of clearly explaining the embodiment and the appendix. Figure 1 The corresponding relationship does not limit the order of the steps in this embodiment.

[0048] Step S110, generating and maintaining an information table for each submodule, wherein each submodule is a service type, and the information table includes: the access time and memory size usage of each submodule, wherein each time a submodule is accessed, the access time needs to be updated to the system time when the submodule is accessed, and if there is an increase or decrease in the content involved, the memory size usage needs to be updated;

[0049] Step S120, generating an elimination table according to the information table of each submodule, wherein the elimination table is a table of the order of clearing the memory of each submodule based on the access time and memory size usage of each submodule;

[0050] Step S130, judging whether the total memory usage used by all submodules is greater than or equal to a preset threshold of total available memory according to the information table of each submodule;

[0051] Step S140, when the total memory usage is greater than or equal to the total available memory preset threshold, selecting a submodule to be processed according to the elimination table;

[0052] Step S150, calling the API of the submodule to be processed, so that the submodule to be processed clears the corresponding memory content according to its own cleaning rules.

[0053] like Figure 2 As shown, Figure 2 This is the software architecture module diagram of this method. The memory management module obtains the total memory usage MemUsed used by each memory sub-module through the API. These memory sub-modules include data structure table items, Redis, Memcached, Tair and other memory databases. In addition, the total size of device memory Total Memory, currently used memory Used Memory, and remaining available memory Free Memory can all be read through / proc / meminfo and other methods. According to the actual situation of the system, a preset threshold MemThreshold of the total available memory that can be used by all memory sub-modules is set.

[0054] It should be noted that the total available memory preset threshold MemThreshold is not equal to the total device memory size Total Memory. This preset threshold can be directly used as the total device memory size Total Memory, or can be obtained by multiplying the total device memory size Total Memory by a safety factor. As described below, this preset threshold MemThreshold is used for early warning, so those skilled in the art can reasonably set a preset threshold suitable for the current environment according to actual conditions.

[0055] In step S110, a set of two-dimensional information tables is maintained for each memory submodule, and the two-dimensional information table includes: the access time of each submodule and the memory size usage. Each time a submodule is accessed, the access time needs to be updated to the system time when it is accessed. If there is an increase or decrease in the content involved, the memory size usage needs to be updated.

[0056] Taking the RB-Tree module as an example, a record is added at time t[i], and the memory size occupied by the record is k1. The total memory size after adding this record is m[i], and m[i]=k1.

[0057] Then the latest record of RB-Tree is: (t[i], m[i]).

[0058] If, after a period of time, at time t[j], you only go to RB-Tree to query a certain record, then the memory occupied does not change, and the record at this time is updated to: (t[j], m[j]), where m[j] = m[i].

[0059] If, after a period of time, t[a] deletes a record whose size is k2, then m[a]=m[i]-k2; the record is updated to: (t[a], m[a]).

[0060] Since this triggering is still based on the access frequency of all memory sub-modules, it is still discrete and will not form a performance bottleneck where multiple sub-modules are triggered independently but at the same time.

[0061] In step S120, a memory elimination table is generated through two-dimensional information with memory sub-modules as units. The elimination table is a table of the order of clearing the memory of each sub-module. The algorithm principle for generating the elimination table is that "the older the time and the smaller the memory usage", the earlier the order is, the sooner it is eliminated and cleared, that is, "the oldest time and the smallest memory usage" is eliminated and cleared first.

[0062] Step S110 and step S120 are both preparatory processes, and step S130 is a judgment process. In the current prior art, each business submodule manages memory "separately". For example, the system has two submodules A and B. The system currently has no free memory allocation, and submodules A and B also have no free space. If submodules A and B are to be written, they all need to vacate space according to their internal elimination rules before writing content. A problem will arise at this time. Since submodules A and B do not know each other's existence and have no communication in business, it is possible that the two will be eliminated at the same time to clear the space, which will cause the CPU to soar and seriously affect the business. In view of this, this method is to arrange the two to clean up in advance in an orderly manner when the two have a tendency to clean up, so as to avoid the two from being eliminated and clearing up space at the same time. Step S130 is the step of finding out whether there is a tendency to clean up.

[0063] In step S130, the total memory usage of each submodule is checked. If it is greater than or equal to the total available memory preset threshold, that is, MemUsed>=MemThreshold, an early warning is required, and it is considered that each submodule has a tendency to clean up its own memory, and measures must be taken at this time. The total available memory preset threshold MemThreshold has been mentioned in the previous text and will not be described here.

[0064] It should be noted that the triggering time of step S130 can be synchronously triggered according to the frequency of the application layer accessing the submodule, that is, it is triggered when the application layer accesses any submodule maintained by the system, or it can be triggered when the cumulative number of times the application layer accesses the submodule maintained by the system exceeds the counting threshold according to the actual triggering frequency. In this method, it is a random trigger, so it avoids the accumulation of redundant data and CPU impact caused by the untimely response of the timing and periodic elimination mechanism, as well as the CPU waste caused by the frequency triggering when the data becomes less, which is different from the timing and periodic elimination mechanism in the data structure and memory data of the prior art.

[0065] It should also be noted that the timing of generating the elimination table in step S120 is preferably synchronized with step S130, that is, when the check in step S130 is triggered, a corresponding elimination table is also generated at the same time.

[0066] Step S140 and step S150 are the process of taking measures to allow each submodule to clean up its own memory in advance and in an orderly manner.

[0067] Step S140 is an orderly arrangement process. Step S140 is to arrange which submodule to clean up first and which submodule to clean up later according to the order in the elimination table. Specifically, step S140 is to select the submodule to be cleaned up first according to the order in the elimination table. Step S150 is a specific cleaning method. In step S150, the API of the submodule to be processed is called to allow the submodule to be processed to clear its own memory content. The cleaning method used is still the cleaning rule of the submodule itself, that is, after selecting which submodule, the submodule does its original work of releasing memory and cleans up according to its own cleaning rule, and does not take additional methods to clean up each submodule. Since the cleaning rules of each submodule are used in this method, which are implemented at the application layer, the problems of hardware environment differences, inconsistent database versions and inconsistent built-in elimination mechanisms are overcome.

[0068] This method proposes a method for managing all memory databases and data structures in a coordinated manner. The application layer generates various business data, serializes the business data, and writes it to the storage layer by calling the API, which is the memory referred to in this method. Similarly, the application layer reads the serialized data from the storage layer through the API, and restores it to obtain the original data. This method is located between the application layer and the storage layer, and globally manages the memory usage of each sub-module of the storage layer, realizes discrete memory release at the system level, and solves the performance problem of independent release of each sub-module.

[0069] In this method, by monitoring the memory usage in each business submodule, the order in which each business submodule needs to clean up the memory is coordinated from the overall perspective, and the total memory usage of each business submodule is checked. Once it is greater than or equal to the preset threshold, the business module is immediately arranged to clean up according to its own existing rules according to the coordinated order. This method releases memory in an orderly manner according to the priority of the memory submodule, and on the basis of limiting the memory usage, the overall performance of the system is improved, and the memory management is triggered every time the memory changes, and the triggering timing is discretized, thereby avoiding the CPU impact caused by the timing and periodic elimination mechanisms in the data structure and memory database of the prior art, and finally overcomes the problems of hardware environment differences, inconsistent database versions, and inconsistent built-in elimination mechanisms.

[0070] In one implementation, the process of step S120 includes: step S121, step S122, and step S123.

[0071] Step S121, calculating the time interval of each submodule, wherein the time interval is the interval between the access time and the current time;

[0072] Step S122, sorting from large to small using time interval as the primary keyword, and when the time intervals are the same, sorting from small to large using memory usage as the secondary keyword to obtain a sorted list;

[0073] Step S123, generating an elimination table according to the sorted list.

[0074] As mentioned above, the algorithm principle for generating the elimination table is that "the older the time and the smaller the memory usage", the higher the sorting order. This implementation is a specific way to implement this principle.

[0075] Assume that there are n submodules in total, the most recent access time of the i-th submodule is last_ts[i], and the module memory size when accessed is mem[i].

[0076] The current system time that triggers the memory management is sys_ts, and the time interval from the time each submodule is accessed to the current latest time is period[i].

[0077] period[i]=sys_ts-last_ts[i]

[0078] The first time, period[i] is used as the keyword to sort the stability from large to small, and the second time, mem[i] is used as the keyword to sort the stability from small to large, and the sorted list is obtained.

[0079] The sorted list can be used directly as an elimination list, or appropriate modifications can be made on its basis to obtain the final elimination list.

[0080] In one implementation, the method further includes: step S160.

[0081] Step S160, if after the process of calling the API of the sub-module to be processed and allowing the sub-module to be processed to clear the corresponding memory content according to its own cleaning rules, the total memory usage is still greater than or equal to the total available memory preset threshold, continue to select the sub-module to be processed from the unselected sub-modules according to the elimination table, and call the API of the sub-module to be processed, so that the sub-module to be processed can clear the corresponding memory content according to its own cleaning rules, until the total memory usage is less than the total available memory preset threshold.

[0082] like Figure 3 As shown, Figure 3It is a schematic diagram of the judgment process of this embodiment. After cleaning the first submodule, it is still possible that the total memory usage is still greater than or equal to the total available memory preset threshold, that is, MemUsed>=MemThreshold. At this time, it is necessary to continue cleaning. Continuing cleaning means cleaning the second submodule in the elimination list. The cleaning method is the same as when cleaning the first submodule, that is, the same as the process of step S150. If MemUsed>=MemThreshold after cleaning the second submodule, then clean the third submodule in the elimination list, and so on, until the total memory usage is not greater than or equal to the total available memory preset threshold, that is, MemUsed<MemThreshold.

[0083] In one implementation, the method further includes: step S210, step S220, step S230 and step S240.

[0084] Step S210, after calling the API of the submodule to be processed and clearing the corresponding memory content of itself, update the memory size usage in the information table of the corresponding submodule;

[0085] Step S220, after all sub-modules have been selected as sub-modules to be processed and their corresponding memory contents have been emptied according to their respective cleaning rules, when the total memory usage is still greater than or equal to the total available memory preset threshold, a elimination table is regenerated according to the information table of each sub-module;

[0086] Step S230, selecting a submodule to be processed for a second time according to the regenerated elimination table;

[0087] Step S240, dumping the content in the submodule to be processed for the second time to a hard disk or other peripheral device, and clearing the content in the submodule to be processed for the second time.

[0088] In the previous implementation, the total memory usage is stopped when it is not greater than or equal to the total available memory preset threshold. However, in actual situations, it is possible that all submodules have been through and all submodules have cleaned up their own memory contents, but the total memory usage still cannot be less than the total available memory preset threshold. At this time, if the above method is repeated again to clean up, the effect is very small, because the submodules cannot clean up more memory under the same cleaning rules. Therefore, in order to achieve the goal of the total memory usage being less than the total available memory preset threshold, this implementation adopts another processing method.

[0089] First, the elimination table needs to be regenerated. The principle of generating the elimination table is still that "the longer the time, the smaller the memory size usage", the higher the order of sorting. The order of executing the clearing of each sub-module memory is still based on the access time and memory size usage of each sub-module. The process of generating the elimination table can also be generated using the aforementioned implementation method. It should be noted here that since the elimination table is sorted in the order of "the longer the time", the higher the order, if the access time and memory size usage in the information table are updated each time the sub-module clears its own memory content, since the time of the first clearing must be longer, then the result of the elimination table generated again must be the same as the previous one, and it is meaningless to do so. Therefore, step S210 in the present application only uses the memory size usage in the information table of the sub-module, so that a elimination table different from the previous elimination table can be regenerated. In fact, the approximate order of the regenerated elimination table is the same, except that a slight adjustment is made to the sub-modules with the same time. After the first clearing, the memory size usage of each sub-module has changed. For the sub-modules with the same time, they are re-sorted according to the memory size usage to obtain a new elimination table.

[0090] Step S230 selects the submodule to be processed for the second time according to the new elimination table, and step S240 processes the submodule to be processed for the second time. The cleaning method of step S240 is as follows: dump the content of the submodule to be processed for the second time to a hard disk or other peripheral device, and then clear the content of the submodule to be processed for the second time.

[0091] In this implementation, the content is dumped to a hard disk or other peripheral device, and another method is used to clean up the memory.

[0092] In one implementation, the method further includes: step S250.

[0093] Step S250, if after the process of dumping the content of the sub-module to be processed for the second time to the hard disk or other peripheral device and clearing the content of the sub-module to be processed for the second time, the total memory usage is still greater than or equal to the total available memory preset threshold, continue to select the sub-module to be processed for the second time from the unselected sub-modules according to the regenerated elimination table, and dump the content of the sub-module to be processed for the second time to the hard disk or other peripheral device, and clear the content of the sub-module to be processed for the second time, until the total memory usage is less than the total available memory preset threshold.

[0094] like Figure 4 As shown, Figure 4 This is a schematic diagram of the judgment process of this embodiment. Figure 3Similar to the implementation method, for the second processing, after processing the first submodule, it is still possible that the total memory usage is still greater than or equal to the total available memory preset threshold, MemUsed>=MemThreshold. At this time, it is necessary to continue cleaning, and continuing cleaning means cleaning the submodule ranked second in the regenerated elimination table. The cleaning method is the same as that of the first submodule, that is, the same as the process of step S240. If MemUsed>=MemThreshold after cleaning the second submodule, the submodule ranked third in the regenerated elimination table is cleaned, and so on, until the total memory usage is not greater than or equal to the total available memory preset threshold, that is, MemUsed<MemThreshold.

[0095] Embodiment 2

[0096] Corresponding to the method of embodiment 1, as Figure 5 As shown, the present invention further provides a memory management device 5, comprising: a management module 510, a generation module 520, an analysis module 530, and an execution module 540.

[0097] The management module 510 is used to generate and maintain an information table for each submodule, wherein each submodule is a service type, and the information table includes: the access time and memory size usage of each submodule, wherein each time a submodule is accessed, the access time needs to be updated to the system time when the submodule is accessed, and if there is an increase or decrease in the content involved, the memory size usage needs to be updated;

[0098] A generating module 520 is used to generate an elimination table according to the information table of each submodule, wherein the elimination table is a table of the order of clearing the memory of each submodule based on the access time and memory size usage of each submodule;

[0099] The analysis module 530 is used to determine whether the total memory usage used by all sub-modules is greater than or equal to a preset threshold of total available memory according to the information table of each sub-module;

[0100] Execution module 540 is used to select the sub-module to be processed according to the elimination table when the total memory usage is greater than or equal to the preset threshold of the total available memory, call the API of the sub-module to be processed, and let the sub-module to be processed clear the corresponding memory content according to its own cleaning rules.

[0101] In one embodiment, the generation module performs the process of generating the elimination table according to the information table of each submodule, including:

[0102] Calculate the time interval of each submodule, wherein the time interval is the interval between the access time and the current time;

[0103] Sort the lists from largest to smallest using time interval as the primary keyword. If the time intervals are the same, sort the lists from smallest to largest using memory usage as the secondary keyword to get the sorted list.

[0104] An elimination table is generated according to the sorted list.

[0105] In one embodiment, the execution module is also used to continue selecting the sub-module to be processed from the unselected sub-modules according to the elimination table, and calling the API of the sub-module to be processed, so that the sub-module to be processed can clear the corresponding memory content according to its own cleaning rules, if the total memory usage is still greater than or equal to the total available memory preset threshold after the process of calling the API of the sub-module to be processed and allowing the sub-module to be processed to clear the corresponding memory content according to its own cleaning rules, until the total memory usage is less than the total available memory preset threshold.

[0106] In one embodiment, the management module is further used to update the memory size usage in the information table of the corresponding submodule after calling the API of the submodule to be processed and clearing the corresponding memory content of itself;

[0107] The generation module is also used to regenerate the elimination table according to the information table of each submodule when the total memory usage is still greater than or equal to the total available memory preset threshold after all submodules have been selected as submodules to be processed and the corresponding memory contents in them have been emptied according to their respective cleaning rules;

[0108] The execution module is also used to select the submodule to be processed for the second time according to the regenerated elimination table, dump the content of the submodule to be processed for the second time to the hard disk or other peripherals, and clear the content of the submodule to be processed for the second time.

[0109] In one embodiment, the execution module is also used to continue selecting sub-modules to be processed for the second time from unselected sub-modules according to the regenerated elimination table, dumping the contents of the sub-modules to be processed for the second time to the hard disk or other peripheral device, and clearing the contents of the sub-modules to be processed for the second time, if the total memory usage is still greater than or equal to the total available memory preset threshold after the process of dumping the contents of the sub-modules to be processed for the second time to the hard disk or other peripheral device and clearing the contents of the sub-modules to be processed for the second time, until the total memory usage is less than the total available memory preset threshold.

[0110] In one implementation, the generation module executes the process of regenerating the elimination table according to the information table of each submodule, including:

[0111] Sort the lists from largest to smallest using time interval as the primary keyword. If the time intervals are the same, sort the lists from smallest to largest using memory usage as the secondary keyword to get the re-sorted list.

[0112] The elimination table is regenerated according to the reordered list.

[0113] In this device, by monitoring the memory usage in each business submodule, the order in which each business submodule needs to clean up the memory is coordinated from the overall perspective, and the total memory usage of each business submodule is checked. Once it is greater than or equal to the preset threshold, the business module is immediately arranged to clean up according to its own existing rules according to the coordinated order. This device releases memory in an orderly manner according to the priority of the memory submodule, and on the basis of limiting the memory usage, the overall performance of the system is improved, and the memory management is triggered every time the memory changes, and the triggering timing is discretized, thereby avoiding the CPU impact caused by the timing and periodic elimination mechanisms in the data structure and memory database of the prior art, and finally overcomes the problems of hardware environment differences, inconsistent database versions and inconsistent built-in elimination mechanisms.

[0114] Embodiment 3

[0115] An embodiment of the present invention further provides a storage medium on which computer instructions are stored. When the instructions are executed by a processor, the memory management method of any of the above embodiments is implemented.

[0116] Those skilled in the art can understand that: all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, random access memories (RAM), read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.

[0117] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to execute all or part of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, RAM, ROM, magnetic disks or optical disks.

[0118] Corresponding to the above-mentioned computer storage medium, in one embodiment, a computer device is also provided, which includes a memory, an encoder, and a computer program stored in the memory and executable on the encoder, wherein when the encoder executes the program, a memory management method as described in any one of the above-mentioned embodiments is implemented.

[0119] The above-mentioned computer equipment, by monitoring the memory usage in each business submodule, coordinates the order in which each business submodule needs to clean up the memory, checks the total memory usage of each business submodule, and once it is greater than or equal to the preset threshold, immediately arranges the business module to clean up according to its own existing rules according to the coordinated order. The above-mentioned computer equipment releases memory in an orderly manner according to the priority of the memory submodule, improves the overall performance of the system on the basis of limiting memory usage, and triggers memory management every time the memory changes, discretizing the triggering timing, thereby avoiding the CPU impact caused by the timing, periodic and other elimination mechanisms in the data structure and memory database of the prior art, and finally overcomes the problems of hardware environment differences, inconsistent database versions and inconsistent built-in elimination mechanisms.

[0120] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0121] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A memory management method, characterized in that: include: Generate and maintain an information table for each submodule, wherein each submodule is a business type, and the information table includes: the access time and memory size usage of each submodule, wherein each time a submodule is accessed, the access time needs to be updated to the system time when the submodule is accessed, and if there is an increase or decrease in the content involved, the memory size usage needs to be updated; Generate an elimination table according to the information table of each submodule, wherein the elimination table is a table of the order of clearing the memory of each submodule based on the access time and memory size usage of each submodule; According to the information table of each sub-module, determine whether the total memory usage used by all sub-modules is greater than or equal to the total available memory preset threshold; When the total memory usage is greater than or equal to a preset threshold of the total available memory, selecting a submodule to be processed according to the elimination table; Call the API of the submodule to be processed, so that the submodule to be processed clears the corresponding memory content according to its own cleaning rules.

2. The memory management method according to claim 1, characterized in that: The process of generating an elimination table according to the information table of each submodule includes: Calculate the time interval of each submodule, wherein the time interval is the interval between the access time and the current time; Sort the lists from largest to smallest using time interval as the primary keyword. If the time intervals are the same, sort the lists from smallest to largest using memory usage as the secondary keyword to get the sorted list. An elimination table is generated according to the sorted list.

3. The memory management method according to claim 1 or 2, characterized in that: Also includes: If after the process of calling the API of the sub-module to be processed and allowing the sub-module to be processed to clear the corresponding memory content according to its own cleaning rules, the total memory usage is still greater than or equal to the total available memory preset threshold, continue to select the sub-module to be processed from the unselected sub-modules according to the elimination table, and call the API of the sub-module to be processed, allowing the sub-module to be processed to clear the corresponding memory content according to its own cleaning rules, until the total memory usage is less than the total available memory preset threshold.

4. The memory management method according to claim 3, characterized in that: Also includes: After calling the API of the submodule to be processed and clearing its own corresponding memory content, update the memory size usage in the information table of the corresponding submodule; After all sub-modules have been selected as sub-modules to be processed and their corresponding memory contents have been emptied according to their respective cleaning rules, when the total memory usage is still greater than or equal to the total available memory preset threshold, the elimination table is regenerated according to the information table of each sub-module; Select the submodule to be processed for the second time according to the regenerated elimination table; Dump the content in the submodule to be processed for the second time to a hard disk or other peripheral device, and clear the content in the submodule to be processed for the second time.

5. The memory management method according to claim 4, characterized in that: Also includes: If after the process of dumping the content of the sub-module to be processed for the second time to the hard disk or other peripheral device and clearing the content of the sub-module to be processed for the second time, the total memory usage is still greater than or equal to the total available memory preset threshold, continue to select the sub-module to be processed for the second time from the sub-modules that have not been selected according to the regenerated elimination table, dump the content of the sub-module to be processed for the second time to the hard disk or other peripheral device, and clear the content of the sub-module to be processed for the second time, until the total memory usage is less than the total available memory preset threshold.

6. The memory management method according to claim 4, characterized in that: The process of regenerating the elimination table according to the information table of each submodule includes: Sort the lists from largest to smallest using time interval as the primary keyword. If the time intervals are the same, sort the lists from smallest to largest using memory usage as the secondary keyword to get the re-sorted list. The elimination table is regenerated according to the reordered list.

7. A memory management device, characterized in that: include: A management module is used to generate and maintain an information table for each submodule, wherein each submodule is a service type, and the information table includes: the access time and memory size usage of each submodule, wherein each time a submodule is accessed, the access time needs to be updated to the system time when the submodule is accessed, and if there is an increase or decrease in the content involved, the memory size usage needs to be updated; A generation module, used to generate an elimination table according to the information table of each sub-module, wherein the elimination table is a table of the order of clearing the memory of each sub-module based on the access time and memory size usage of each sub-module; The analysis module is used to determine whether the total memory usage used by all sub-modules is greater than or equal to a preset threshold of total available memory according to the information table of each sub-module; The execution module is used to select the sub-module to be processed according to the elimination table when the total memory usage is greater than or equal to the preset threshold of the total available memory, call the API of the sub-module to be processed, and let the sub-module to be processed clear the corresponding memory content according to its own cleaning rules.

8. The memory management device according to claim 7, characterized in that: include: The execution module is also used to continue selecting the sub-module to be processed from the unselected sub-modules according to the elimination table, and calling the API of the sub-module to be processed, so that the sub-module to be processed can clear the corresponding memory content according to its own cleaning rules, if the total memory usage is still greater than or equal to the total available memory preset threshold after the process of calling the API of the sub-module to be processed and allowing the sub-module to be processed to clear the corresponding memory content according to its own cleaning rules, until the total memory usage is less than the total available memory preset threshold.

9. A computer device 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 program, the method according to any one of claims 1 to 6 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.