Memory management method and device, electronic equipment, storage medium and product
Patent Information
- Application Number
- CN202210959503.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-10
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2042-08-10
AI Technical Summary
但是,上述相对固化的内存分配策略并不适配于应用程序的应用场景变化导致内存需求变化的场景,会使内存分配的性能降低,并影响应用程序的运行性能
[0018]This embodiment of the disclosure addresses the problem of a single memory allocation strategy affecting memory allocation performance and application performance during the execution of a preset application. It adjusts the current memory pre-allocation strategy at first preset time intervals, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application runs. Each time the memory pre-allocation strategy is adjusted, memory allocation management is performed according to the adjusted strategy during the execution of the preset application in the corresponding application scenario. The performance of the preset application over a runtime period is then monitored. Based on the performance score of the preset application under multiple adjusted memory pre-allocation strategies, a preferred memory pre-allocation strategy for the preset application in the corresponding application scenario is determined and set as the default memory pre-allocation strategy for the preset application in the corresponding application scenario. This embodiment of the disclosure solves the problem of a single application memory allocation strategy affecting memory allocation performance and application performance. It adaptively explores relatively better preferred memory pre-allocation strategies to meet the memory needs of applications in different scenarios, thereby improving the application's performance in the corresponding scenarios, making the memory allocation strategy more flexible, and improving the efficiency of memory allocation.
Smart Images

Figure CN115328649B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to a memory management method, apparatus, electronic device, storage medium, and product. Background Technology
[0002] In memory management, the heap is used to represent the virtual address space for dynamically allocated memory. Heap memory allocators are commonly used to manage and schedule the available heap space. Typically, different memory allocators employ different allocation strategies, all aiming to improve the speed, efficiency, and adaptability of memory allocation. For universality and speed, memory allocators pre-plan the memory space based on the size of the allocated memory blocks, fixing the allocation range and corresponding allocation strategy. However, these relatively fixed memory allocation strategies are not suitable for scenarios where application needs change due to evolving application scenarios. This can degrade memory allocation performance and negatively impact application performance. Summary of the Invention
[0003] This disclosure provides a memory management method, apparatus, electronic device, storage medium, and product that can adaptively explore a memory pre-allocation strategy with better performance in any application scenario, improve memory allocation efficiency in various application scenarios, and optimize program performance.
[0004] In a first aspect, embodiments of this disclosure provide a memory management method, the method comprising:
[0005] During the operation of a preset application, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running.
[0006] Based on each adjusted memory pre-allocation strategy, memory space is pre-allocated for the preset application in the application scenario, and the running performance score of the preset application under each adjusted memory pre-allocation strategy is recorded.
[0007] Based on the performance scores, the preferred memory pre-allocation strategy of the preset application in the application scenario is determined, and the preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0008] Secondly, embodiments of this disclosure also provide a memory management device, the device comprising:
[0009] The pre-allocation strategy adjustment module is used to adjust the current memory pre-allocation strategy under the application scenario at a first preset time interval, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running.
[0010] The adjusted strategy testing module is used to pre-allocate memory space for the preset application in the application scenario based on each adjusted memory pre-allocation strategy, and record the running performance score of the preset application under each adjusted memory pre-allocation strategy.
[0011] The preferred pre-allocation strategy determination module is used to determine the preferred memory pre-allocation strategy of the preset application in the application scenario based on the performance scores of each application, and to use the preferred memory pre-allocation strategy as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0012] Thirdly, embodiments of this disclosure also provide an electronic device, the electronic device comprising:
[0013] One or more processors;
[0014] Storage device for storing one or more programs.
[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement the memory management method as described in any of the embodiments of this disclosure.
[0016] Fourthly, embodiments of this disclosure also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the memory management method as described in any of the embodiments of this disclosure.
[0017] Fifthly, embodiments of this disclosure also provide a computer program product, including a computer program that, when executed by a processor, implements the memory management method as described in any of the embodiments of this invention.
[0018] This embodiment of the disclosure addresses the problem of a single memory allocation strategy affecting memory allocation performance and application performance during the execution of a preset application. It adjusts the current memory pre-allocation strategy at first preset time intervals, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application runs. Each time the memory pre-allocation strategy is adjusted, memory allocation management is performed according to the adjusted strategy during the execution of the preset application in the corresponding application scenario. The performance of the preset application over a runtime period is then monitored. Based on the performance score of the preset application under multiple adjusted memory pre-allocation strategies, a preferred memory pre-allocation strategy for the preset application in the corresponding application scenario is determined and set as the default memory pre-allocation strategy for the preset application in the corresponding application scenario. This embodiment of the disclosure solves the problem of a single application memory allocation strategy affecting memory allocation performance and application performance. It adaptively explores relatively better preferred memory pre-allocation strategies to meet the memory needs of applications in different scenarios, thereby improving the application's performance in the corresponding scenarios, making the memory allocation strategy more flexible, and improving the efficiency of memory allocation. Attached Figure Description
[0019] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0020] Figure 1 This is a schematic flowchart of a memory management method provided in an embodiment of this disclosure;
[0021] Figure 2 This is a schematic flowchart of another memory management method provided in the embodiments of this disclosure;
[0022] Figure 3 This is a schematic flowchart of another memory management method provided in the embodiments of this disclosure;
[0023] Figure 4 This is a schematic flowchart of another memory management method provided in the embodiments of this disclosure;
[0024] Figure 5 This is a schematic diagram of the structure of a memory management device provided in an embodiment of this disclosure;
[0025] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0026] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0027] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0028] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0029] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0030] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0031] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0032] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0033] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0034] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0035] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0036] Figure 1 This is a flowchart illustrating a memory management method provided in an embodiment of the present disclosure. This embodiment is applicable to scenarios where memory management is performed during application execution, and memory is pre-allocated for applications in different application scenarios. The method can be executed by a memory management device, which can be implemented in software and / or hardware, or optionally by an electronic device, such as a mobile terminal, a PC, or a server.
[0037] like Figure 1 As shown, the memory management method includes:
[0038] S110. During the operation of the preset application, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval.
[0039] The preset application can be any application that uses the memory management method provided in this embodiment to manage memory during program execution. It can be different types of applications such as social media applications, e-commerce shopping applications, music applications, game applications, or video applications.
[0040] The target terminal for running the preset application can also be different types of terminal devices, and different types of terminal devices have different amounts of available memory space. Accordingly, different available memory space configurations, such as the number of CPU cores and the space size corresponding to each core, require different memory allocation strategies to adapt to the memory allocation limitations and needs of the terminal itself.
[0041] The usage and requirements of heap memory vary across different application scenarios. Applications can be categorized into multiple scenarios based on function or business logic. For example, mobile applications might include scenarios such as cold start, playing on-demand videos, entering a live stream, opening a search interface, recording and uploading videos. Server-side applications can be further divided into different scenarios based on service categories and API response processes; alternatively, they can be categorized by application load, such as light load, medium load, and heavy load scenarios.
[0042] Therefore, in this embodiment, the memory management strategy configuration for the preset application takes into account both the device performance of the target terminal running the preset application and the specific application scenario. Compared with the current memory management method where memory allocators perform memory pre-allocation according to a fixed pre-allocation strategy with fixed memory block size and quantity, the memory pre-allocation strategy configuration in this embodiment is more flexible and more adaptable to the operation of the application on the corresponding terminal device and in the corresponding scenario, reducing the number of repeated memory call requests by the application and ensuring the high-performance operation of the application.
[0043] Specifically, different initial memory pre-allocation strategies can be set for each terminal with different device performance, serving as a baseline for adjusting the memory pre-allocation strategy. Then, based on these initial memory pre-allocation strategies for terminals with varying device performance, further different memory allocation adjustment strategies can be set for different application scenarios, resulting in a set of memory allocation adjustment strategies. When determining the memory allocation adjustment strategy for a preset application, the target selection group for the preset application's memory allocation adjustment strategy can be determined based on the target terminal's device performance score. Then, based on the application scenario currently running the preset application, the target memory allocation adjustment strategy is determined within the target selection group. The principle for the target terminal's device performance score can be based on weighted scoring of hardware performance, with scores divided into multiple different levels, such as based on memory size or the number of CPU cores. Alternatively, the target terminal's device performance score can be determined by a preset device performance scoring program through comprehensive analysis.
[0044] After determining the target memory allocation adjustment strategy, the current memory pre-allocation strategy for the application scenario is adjusted at fixed intervals according to the target memory allocation adjustment strategy and a first preset time interval. Adjusting the memory pre-allocation strategy can involve modifying the values of configuration items such as memory block size and number of memory blocks within the memory pre-allocation strategy.
[0045] S120. Based on each adjusted memory pre-allocation strategy, pre-allocate memory space for the preset application in the application scenario, and record the running performance score of the preset application under each adjusted memory pre-allocation strategy.
[0046] Each time the memory pre-allocation strategy is adjusted, memory management is performed according to the adjusted strategy, pre-preparing memory blocks of appropriate size and quantity for the preset applications to respond to memory allocation requests (memory call requests) issued by the preset applications during runtime. At the same time, the running performance of the preset applications in the corresponding application scenarios under each adjusted memory pre-allocation strategy can be recorded as the test results of the adjusted memory pre-allocation strategy.
[0047] Since different memory configuration parameters can affect the running performance of an application, the degree to which a memory pre-allocation strategy is adapted to the application's running scenario can be determined by judging the running performance of the application.
[0048] The performance metrics for different application scenarios vary. For example, in video playback, metrics include video playback smoothness / stuttering rate, first frame loading time, and frame rate. In live streaming, the latency to enter the live stream can be a performance metric. Other application scenarios may include video recording smoothness, search latency, and application programming interface (API) response latency. Furthermore, each application scenario may have one or more performance metrics.
[0049] If there are multiple performance metrics, a weight parameter can be set for each performance metric. Then, the multiple performance metrics are combined according to their weights to obtain a runtime performance score. The process of adjusting the memory pre-allocation strategy is the process of exploring a better memory management scheme to improve the runtime performance score of the preset application.
[0050] S130. Based on the performance scores, determine the preferred memory pre-allocation strategy of the preset application in the application scenario, and set the preferred memory pre-allocation strategy as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0051] Based on the performance score corresponding to each adjusted memory pre-allocation strategy, the memory pre-allocation strategy with the highest performance score can be selected as the preferred memory pre-allocation strategy. Furthermore, based on this preferred memory pre-allocation strategy, further adjustments can be made to explore potentially even better preferred memory pre-allocation strategies.
[0052] Therefore, the preferred memory pre-allocation strategy can be set as the default memory pre-allocation strategy for the application in the corresponding application scenario to manage memory.
[0053] The technical solution of this disclosure, during the operation of a preset application, adjusts the current memory pre-allocation strategy in the application scenario at first preset time intervals based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application runs. Specifically, each time the memory pre-allocation strategy is adjusted, memory allocation management is performed according to the adjusted strategy when the preset application runs in the corresponding application scenario. Then, the running performance of the preset application is monitored within a running time cycle. Based on the running performance score of the preset application under multiple adjusted memory pre-allocation strategies, a preferred memory pre-allocation strategy for the preset application in the corresponding application scenario is determined, and this preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy for the preset application in the corresponding application scenario. The technical solution of this disclosure solves the problem of a single application memory allocation strategy affecting memory allocation performance and application running performance. It can adaptively explore relatively better preferred memory pre-allocation strategies to meet the memory needs of applications in different scenarios, thereby improving the running performance of applications in corresponding scenarios, making memory allocation strategies more flexible, and improving memory allocation efficiency.
[0054] Figure 2 This is a flowchart illustrating another memory management method provided in this disclosure. The flowchart further describes the specific process of adjusting the memory pre-allocation strategy and the process of determining the preferred distributed memory pre-allocation strategy. This method can be executed by a memory management device, which can be implemented in software and / or hardware, optionally through an electronic device such as a mobile terminal, PC, or server.
[0055] like Figure 2 As shown, the memory management method includes:
[0056] S210. During the operation of the preset application, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval.
[0057] Among them, the memory allocation adjustment strategy applies to strategies that change the memory pre-allocation strategy and can guide the process of exploring and optimizing the memory pre-allocation strategy. The current memory pre-allocation strategy is either the initial memory pre-allocation strategy of the application on its target terminal and corresponding application scenario, or the memory pre-allocation strategy after at least one strategy adjustment based on the target memory allocation adjustment strategy and the initial memory pre-allocation strategy.
[0058] The target memory allocation adjustment strategy and the initial memory pre-allocation strategy can be determined by looking up a table. For example, the target memory allocation adjustment strategy and the corresponding table for the device scenario are shown in Table 1 below:
[0059] Table 1
[0060]
[0061]
[0062] It should be noted that the table is divided into different levels based on the device performance score of the terminal device. When the terminal device in each score level runs the preset application, there are different baselines and strategies in different scenarios. The baseline refers to the initial memory pre-allocation strategy in the corresponding device and application scenario, and the strategy is the memory allocation adjustment strategy based on the initial memory pre-allocation strategy.
[0063] Furthermore, based on the determined memory allocation adjustment strategy, the memory pre-allocation strategy is adjusted at a customizable time interval, such as a first preset time interval. This adjustment can be performed by positively or negatively adjusting at least one preset memory pre-allocation strategy configuration item according to the preset adjustment step size corresponding to each configuration item in the current memory pre-allocation strategy. Positive adjustment refers to adding the value of a configuration item according to the corresponding adjustment step size; negative adjustment refers to subtracting the value of a configuration item according to the corresponding adjustment step size.
[0064] In a specific example, when an application first enters a certain application scenario, it first manages memory using the corresponding initial memory pre-allocation strategy (baseline) and runs one cycle, DeltaT, under this memory management method. Starting from the second cycle, DeltaT, based on the initial memory pre-allocation strategy (baseline), it combines the adjustment step size and adjustment direction of each configuration item to generate the path to be explored next. For example, if the configuration items in the initial memory pre-allocation strategy include (A, B, C), and the corresponding adjustment step size for each configuration item is (a, b, c), then the following exploration direction nodes can be generated: (A+a, B, C), (Aa, B, C), (A+a, B+b, C), (A+a, B+b, C), (A+a, B+b, C+c), (A+a, B+b, Cc), (A+a, Bb, C+c), (A+a, Bb, Cc). For step size parameters whose corresponding parameters are enumerated values, the enumerated values are directly used, such as the on or off state of a switch. Further exploration can be conducted at each directional node, using the step size of each configuration item, to extend to more nodes.
[0065] S220. Based on each adjusted memory pre-allocation strategy, pre-allocate memory space for the preset application in the application scenario, and record the running performance score of the preset application under each adjusted memory pre-allocation strategy.
[0066] During memory management using the initial memory pre-allocation strategy and each subsequent adjusted strategy, the performance scores of the preset application under each strategy are recorded. The performance score corresponding to the initial memory pre-allocation strategy is used as the initial score, denoted as ScoreInit. The number of performance scores obtained during the exploration of optimal memory pre-allocation strategies is the same as the number of memory pre-allocation strategies explored. During the exploration process, the highest score and its corresponding memory pre-allocation strategy can also be specifically recorded.
[0067] In one optional implementation, during the exploration of a preferred memory pre-allocation strategy, when a DeltaT cycle ends, the performance score for the corresponding application scenario in this cycle is calculated and recorded. If the score is greater than ScoreInit, the corresponding memory pre-allocation strategy is recorded as a baseline node for the next large cycle; if the score is less than ScoreInit, the current exploration direction node is discarded. The next large cycle refers to a new round of exploration after all exploration direction nodes in this round have been explored. The baseline refers to the initial memory pre-allocation strategy in a preferred memory pre-allocation strategy exploration process; the initial memory pre-allocation strategy and each adjusted memory pre-allocation strategy are recorded as an exploration node. Alternatively, when the performance score of a preset application under any adjusted memory pre-allocation strategy is less than the performance score under the original memory pre-allocation strategy, the direction of adjustment for the at least one preset memory pre-allocation strategy configuration item is changed during the next memory pre-allocation strategy adjustment, i.e., further exploration in the direction of the current exploration node is stopped.
[0068] S230. Based on the performance scores, determine the preferred memory pre-allocation strategy of the preset application in the application scenario, and set the preferred memory pre-allocation strategy as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0069] After exploring all explorable memory pre-allocation strategy nodes, a new exploration process can be initiated based on the exploration results. The exploration results can be memory pre-allocation strategies whose corresponding performance scores are greater than ScoreInit. Therefore, a new round of exploration can begin using the memory pre-allocation strategies from these exploration results as the new starting memory pre-allocation strategies.
[0070] Preferably, a new exploration process can be initiated according to the performance score in descending order from the exploration results. Alternatively, several memory pre-allocation strategies with higher performance scores can be selected as new initial memory pre-allocation strategies. Of course, strategy nodes that have already been explored will be recorded and will not be explored again.
[0071] After several rounds of exploration, the memory pre-allocation strategy with the highest corresponding performance score can be selected as the preferred memory pre-allocation strategy. This preferred memory pre-allocation strategy can then be used as the default memory pre-allocation strategy for the application in the corresponding application scenario for memory management.
[0072] S240. According to the second preset time interval, obtain the reference preferred memory pre-allocation strategy issued by the preset server, and use the reference preferred memory pre-allocation strategy as the new initial memory pre-allocation strategy of the preset application in the application scenario, and conduct a new round of preferred memory pre-allocation strategy exploration according to the memory allocation adjustment strategy.
[0073] The second preset time interval is a longer time period than the first preset time interval, denoted as DeltaD. The preset server can be a service cloud platform that comprehensively manages the operation of preset applications, coordinating the running data of preset applications on various terminals. The reference preferred memory pre-allocation strategy is determined by the preset server according to the preset reference strategy allocation strategy, allocating memory according to the preferred pre-allocation strategies for the preset application running on all terminal devices within the preset local area network where the target terminal is located, and during application scenario execution.
[0074] Specifically, when a pre-defined application runs on a target terminal, it can upload the discovered optimal memory pre-allocation strategy and its corresponding performance score to a pre-defined server. The pre-defined server can then obtain the data uploaded by the pre-defined application clients running on multiple terminals. Based on the performance scores of the pre-defined applications running on multiple terminals with the same device performance score level, it can select one or more reference optimal memory pre-allocation strategies according to the pre-defined reference strategy allocation strategy and distribute them to the pre-defined application clients running on the corresponding terminals.
[0075] For example, the pre-configured server can sort the obtained preferred memory pre-allocation strategies according to their corresponding performance scores, select the memory pre-allocation strategies corresponding to the highest and lowest scores, and then randomly select N (a natural number less than the total number of memory pre-allocation strategies) other memory pre-allocation strategies as reference preferred memory pre-allocation strategies, and then allocate these strategies. Specifically, when allocating strategies, the reference preferred memory pre-allocation strategy corresponding to the highest score can be distributed to the pre-configured applications of the majority of terminal devices, while the other reference preferred memory pre-allocation strategies can be randomly distributed proportionally to the pre-configured applications of a minority of terminal devices.
[0076] Accordingly, after receiving the reference preferred memory pre-allocation strategy, the preset application client of each terminal device updates the original baseline and explores a new round of preferred memory pre-allocation strategies.
[0077] Based on the above process, a distributed exploration approach was implemented to obtain the optimal memory pre-allocation strategy within a preset local area network area, and the memory pre-allocation strategy was continuously explored and optimized.
[0078] S250. Within a third preset time interval, obtain the random adjustment memory pre-allocation strategy issued by the preset server, and use the random adjustment memory pre-allocation strategy as the new initial memory pre-allocation strategy of the preset application in the application scenario, and conduct a new round of exploration of the preferred memory pre-allocation strategy according to the memory allocation adjustment strategy.
[0079] The third preset time interval has a longer time period than the second preset time interval, and can be denoted as DeltaM.
[0080] If, within a certain period of DeltaM, after exploration, the performance scores of preset applications on different terminal devices running in the same local area network range are similar and tend to be consistent, and the performance scores of each application are less than the preset difference threshold, the preset server will randomly adjust the explored memory pre-allocation strategy, generate a preset number of different randomly adjusted memory pre-allocation strategies, and allocate the new randomly adjusted memory pre-allocation strategies.
[0081] Accordingly, after receiving the randomly adjusted memory pre-allocation strategy, the default application client of each terminal device updates the original initial memory pre-allocation strategy and explores a new round of optimized memory pre-allocation strategies.
[0082] The technical solution of this disclosure involves adjusting the current memory pre-allocation strategy in the application scenario at first preset time intervals during the operation of a preset application. This adjustment is based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running. Each time the memory pre-allocation strategy is adjusted, memory allocation management is performed according to the adjusted memory pre-allocation strategy when the preset application is running in the corresponding application scenario. Then, the running performance of the preset application is monitored within a running time period. Based on the running performance score of the preset application under multiple adjusted memory pre-allocation strategies, the preferred memory pre-allocation strategy of the preset application in the corresponding application scenario is determined, and the preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy of the preset application in the corresponding application scenario. At different time stages during the exploration of the preferred memory pre-allocation strategy, the memory management optimization results of other memory allocators allocated by the preset server are synchronized. The received memory pre-allocation strategy is used as the starting point for exploring the preferred memory pre-allocation strategy, and the exploration continues. That is, on the basis of local incremental performance optimization exploration, memory management can also be continuously optimized and improved. The technical solution of this disclosure addresses the problem of a single memory allocation strategy for applications, which affects memory allocation performance and application running performance. It can adaptively explore a relatively better preferred memory pre-allocation strategy to meet the memory needs of applications in different scenarios, thereby improving the running performance of applications in corresponding scenarios, making the memory allocation strategy more flexible, and improving the efficiency of memory allocation.
[0083] Figure 3 This is a flowchart illustrating another memory management method provided in this disclosure. In implementing this method, the flowchart further describes memory management based on a preferred memory pre-allocation strategy to respond to memory requests from a preset application. This method can be executed by a memory management device, which can be implemented in software and / or hardware, optionally through an electronic device such as a mobile terminal, PC, or server.
[0084] like Figure 3 As shown, the memory management method includes:
[0085] S310. During the operation of a preset application, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval.
[0086] Specifically, in the memory pre-allocation strategy, configurable items may include at least one of the following: the number of sub-memory spaces of the central processing unit core, the size of memory blocks in each sub-memory space, the number of memory blocks of each size, the number of memory block reallocation additions, the memory fragmentation reclamation cycle, whether to temporarily suppress memory fragmentation reclamation, and the time interval for suppressing memory fragmentation reclamation.
[0087] It is understood that adjusting the memory pre-allocation strategy involves adjusting the value of at least one configuration item based on the initial memory pre-allocation strategy. The initial memory pre-allocation strategy is the baseline mentioned in this embodiment, and both the initial memory pre-allocation strategy and each adjusted memory pre-allocation strategy are recorded as an exploration node.
[0088] After matching the corresponding baseline and memory allocation adjustment strategy based on the device performance score of the terminal device running the preset application and the application scenario corresponding to the preset application, the exploration process of the optimal memory pre-allocation strategy can be started.
[0089] For example, an initial memory pre-allocation strategy includes an allocable memory subspace (area) for each CPU core (several CPU cores), the size of memory chunks within each arena, and the corresponding number of memory chunks. This is a discrete key-value mapping, such as an initial quantity of 1000 8-byte memory chunks, 1000 16-byte memory chunks, 1000 32-byte memory chunks, 1000 64-byte memory chunks, and 500 512-byte memory chunks. The memory fragmentation reclamation time is 100ms, and memory fragmentation suppression is not performed by default. Starting from this configuration baseline, the parameters of configurable items are fine-tuned according to the set step size. The step size for each parameter can be the same or different. The step size can be the magnitude of each adjustment, such as a 10ms step size for adjusting the fragmentation recycling cycle, a step size of 5 for changing the number of 16-byte memory blocks, a step size of 10 for changing the number of 32-byte memory blocks, and so on. The step size can also be an enumerated value, such as the step size being either on or off for some parameters that only have two options.
[0090] S320. Based on each adjusted memory pre-allocation strategy, pre-allocate memory space for the preset application in the application scenario, and record the running performance score of the preset application under each adjusted memory pre-allocation strategy.
[0091] S330. Based on the performance scores, determine the preferred memory pre-allocation strategy of the preset application in the application scenario, and set the preferred memory pre-allocation strategy as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0092] S340. During the operation of the preset application, under the application scenario, memory is pre-allocated for the preset application according to the default memory pre-allocation strategy.
[0093] In this step, memory management is carried out according to the preferred memory pre-allocation strategy determined after exploration, and memory blocks of a preset size and number are pre-allocated according to the values of each configuration parameter in the memory pre-allocation strategy.
[0094] S350. When a memory allocation request is obtained, the memory allocation path is determined according to the memory space size of the memory allocation request.
[0095] In this embodiment, the memory management request is obtained by intercepting the memory allocation request, so that the memory management device proposed in this embodiment can be used to allocate memory.
[0096] Specifically, memory allocation requests can be intercepted through hook functions, hooking the memory access interface. Alternatively, they can be customized based on the application programming interface provided by the memory management device itself, allowing it to handle all memory allocation (access) requests, meaning all memory access requests follow a customized allocation optimization scheme. Or, based on a configured scheme, only a portion of the memory space request size range can be customized for optimization. Specifically, the requested memory space size in the memory management request is compared with a preset memory range for the memory space requiring allocation optimization. This determines whether the requested memory space size falls within the preset memory range. If the memory space size is within the preset range, the memory management strategy path is determined to be the preset memory management optimization path, meaning the memory management device in this embodiment is used as the target memory manager to respond to the acquired memory management request. If the memory space size is not within the preset range, a conventional memory manager such as tcmalloc, jemalloc, or scudo is used to allocate memory using a conventional memory management strategy.
[0097] Furthermore, the preset memory range for which memory space allocation optimization is needed can be a pre-defined range of memory space sizes. This range could be a range of memory space sizes that the user is concerned about, or a range within which memory management operations are more frequent and require optimization. For example, memory management strategies are determined using a preset memory management optimization path for requests of 512MB or less.
[0098] S360. When the memory allocation path is a preset memory allocation optimization path, memory is allocated to the preset application in the memory space allocated according to the default memory pre-allocation strategy, according to the memory size requested in the memory allocation request.
[0099] The memory allocation path is determined to be a preset optimized memory allocation path. This means that the memory allocation request corresponding to the memory management method provided in this embodiment is selected, and memory is allocated to the preset application within the memory space allocated according to the default memory pre-allocation strategy, based on the memory size requested in the memory allocation request. The optimized memory pre-allocation strategy, after exploration, can maximize the satisfaction of the preset application's memory needs in the corresponding scenario, thereby reducing the number of memory requests and improving the running performance of the preset application.
[0100] The technical solution of this disclosure involves adjusting the current memory pre-allocation strategy in the application scenario at first preset time intervals during the operation of a preset application. This adjustment is based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running. Each time the memory pre-allocation strategy is adjusted, memory allocation management is performed according to the adjusted memory pre-allocation strategy when the preset application is running in the corresponding application scenario. Then, the running performance of the preset application is monitored within a running time period. Based on the running performance score of the preset application under the adjusted memory pre-allocation strategy, the preferred memory pre-allocation strategy of the preset application in the corresponding application scenario is determined, and the preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy of the preset application in the corresponding application scenario. When a memory allocation request is obtained, memory is allocated for the application that issued the memory request in the memory space managed based on the preferred memory pre-allocation strategy, thus responding to the memory allocation request quickly and efficiently. The technical solution of this disclosure addresses the problem of a single memory allocation strategy for applications, which affects memory allocation performance and application running performance. It can adaptively explore a relatively better preferred memory pre-allocation strategy to meet the memory needs of applications in different scenarios, thereby improving the running performance of applications in corresponding scenarios, making the memory allocation strategy more flexible, and improving the efficiency of memory allocation.
[0101] In one alternative implementation, the memory management process can be referred to Figure 4 The flowchart is shown below. Figure 4 As shown, the memory management process is as follows:
[0102] During application execution, a process of exploring optimal memory pre-allocation strategies also occurs. First, the memory management device manages the memory space according to the corresponding initial or adjusted memory pre-allocation strategy. When a memory access request is received, module 001 intercepts the application's memory access request, and module 002 makes a memory allocation decision: whether the memory access request should be handled by the regular heap memory allocator or by the private memory allocator in module 006. The decision-making process of module 002 is based on the default allocation tier strategy stored in module 004, runtime performance statistics from module 003, and the source-side allocation strategy synchronized from module 005.
[0103] Furthermore, module 001 can connect to the corresponding memory access interface via hook functions, and can also obtain memory access requests through the external callback interface provided by the private memory allocator. Specifically, memory requests and releases are consistent. When releasing memory space, it is determined whether it was allocated through module 006; if so, the memory space release is returned to module 006; otherwise, the memory space release is returned to the existing heap memory allocator. In addition, the memory access requests obtained by module 001 only affect the memory access of applications using this memory management device; they will not affect other applications in the system that do not use this memory management device, thus ensuring security.
[0104] The allocation decision module 002 comprises three sub-modules: bypass control sub-module 0021, decision sub-module 0022, and configuration sub-module 0023. 0021 receives configuration instructions from 0022, adjusts bypass settings, and bypasses memory request types requiring optimization, directing these memory call requests to module 006. 0022 receives input from 003, 004, and 005 and generates a decision result: adjusting the memory pre-allocation measure according to the memory allocation adjustment strategy. Then, based on the application's performance score under different memory pre-allocation strategies, it selects the preferred memory pre-allocation strategy and sends the updated preferred strategy to 0023 via configuration instructions, causing 0023 to adjust the configuration items of the specific memory pre-allocation strategy in 006.
[0105] Module 003 collects and analyzes runtime performance metrics. Different application scenarios require different performance metrics, and Module 003 collects the relevant metrics for each scenario and combines them to obtain a runtime performance score. Additionally, Module 003 can periodically adjust the memory pre-allocation strategy and pass it to Module 002. Module 005 receives the preferred memory pre-allocation strategy and randomly adjusts the strategy from the network application interface, updates the baseline configuration, and periodically synchronizes the preferred memory pre-allocation strategy and corresponding runtime performance scores for each local scenario.
[0106] The optimization allocation module 006 adjusts the corresponding parameter configurations according to the settings in 002. Internally, 006 allocates one or more blocks of dedicated memory space to each core, tailored to the characteristics of multi-core CPUs. Within this dedicated memory space, it generates a corresponding number of memory units based on the memory block size and quantity information in the memory pre-allocation strategy. These memory units can be organized as singly linked lists, doubly linked lists, or sets. Specifically, 002 can also specify fine-tuning for a particular thread, such as increasing or decreasing the number of memory units on the CPU core corresponding to that thread. Furthermore, 006's adjustment of memory units can occur during hook calls or at other times, and does not need to happen serially with the memory call interface.
[0107] Figure 5 This disclosure provides a memory allocation and management device suitable for memory management during application execution and for pre-allocating memory for applications in different application scenarios. The memory management device can be implemented in software and / or hardware and can be configured in an electronic device, such as a mobile terminal, a PC, or a server.
[0108] like Figure 5 As shown, the memory management device includes: a pre-allocation strategy adjustment module 410, an adjusted strategy testing module 420, and a preferred pre-allocation strategy determination module 430.
[0109] The pre-allocation strategy adjustment module 410 is used to adjust the current memory pre-allocation strategy in the application scenario at a first preset time interval, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application runs. The adjusted strategy testing module 420 is used to pre-allocate memory space for the preset application in the application scenario based on each adjusted memory pre-allocation strategy, and record the running performance score of the preset application under each adjusted memory pre-allocation strategy. The preferred pre-allocation strategy determination module 430 is used to determine the preferred memory pre-allocation strategy of the preset application in the application scenario based on each running performance score, and set the preferred memory pre-allocation strategy as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0110] The technical solution of this disclosure, during the operation of a preset application, adjusts the current memory pre-allocation strategy in the application scenario at first preset time intervals based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application runs. Specifically, each time the memory pre-allocation strategy is adjusted, memory allocation management is performed according to the adjusted strategy when the preset application runs in the corresponding application scenario. Then, the running performance of the preset application is monitored within a running time cycle. Based on the running performance score of the preset application under multiple adjusted memory pre-allocation strategies, a preferred memory pre-allocation strategy for the preset application in the corresponding application scenario is determined, and this preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy for the preset application in the corresponding application scenario. The technical solution of this disclosure solves the problem of a single application memory allocation strategy affecting memory allocation performance and application running performance. It can adaptively explore relatively better preferred memory pre-allocation strategies to meet the memory needs of applications in different scenarios, thereby improving the running performance of applications in corresponding scenarios, making memory allocation strategies more flexible, and improving memory allocation efficiency.
[0111] In an optional implementation, the pre-allocation strategy adjustment module 410 is specifically used for:
[0112] Based on the device performance score of the target terminal, determine the target selection group for the memory allocation adjustment strategy of the preset application;
[0113] Based on the application scenario, a target memory allocation adjustment strategy is determined within the target selection group;
[0114] According to the target memory allocation adjustment strategy, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval.
[0115] In an optional implementation, the pre-allocation strategy adjustment module 410 is further configured to:
[0116] According to the preset adjustment step size corresponding to each configuration item, at least one preset memory pre-allocation strategy configuration item in the current memory pre-allocation strategy is adjusted positively or negatively.
[0117] The current memory pre-allocation strategy is either the initial memory pre-allocation strategy of the preset application in the application scenario, or a memory pre-allocation strategy after at least one strategy adjustment based on the target memory allocation adjustment strategy and the initial memory pre-allocation strategy.
[0118] In an optional implementation, the pre-allocation strategy adjustment module 410 is further configured to:
[0119] When the performance score of the preset application under any adjusted memory pre-allocation strategy is lower than the performance score under the original memory pre-allocation strategy, the direction of adjustment of the at least one preset memory pre-allocation strategy configuration item shall be changed during the next memory pre-allocation strategy adjustment.
[0120] In an optional implementation, the preferred pre-allocation strategy determination module 430 is specifically used for:
[0121] Based on the scores of each of the aforementioned performance scores, the memory pre-allocation strategies corresponding to each of the aforementioned performance scores are filtered, and the filtered memory pre-allocation strategies are sorted.
[0122] Among the sorted memory pre-allocation strategies, the corresponding memory pre-allocation strategies are selected as the preferred memory pre-allocation strategies in descending order of their corresponding performance scores.
[0123] In an optional implementation, the memory management device further includes an initial memory pre-allocation policy update module, used for:
[0124] The preferred memory pre-allocation strategy is used as the new initial memory pre-allocation strategy for the preset application in the application scenario, so that the memory management device can conduct a new round of preferred memory pre-allocation strategy exploration based on the memory allocation adjustment strategy.
[0125] In an optional implementation, the initial memory pre-allocation policy update module device is further configured to:
[0126] According to the second preset time interval, a reference preferred memory pre-allocation strategy issued by the preset server is obtained, wherein the second preset time interval is greater than the first preset time interval;
[0127] So that the memory management device uses the reference preferred memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, and explores a new round of preferred memory pre-allocation strategies according to the memory allocation adjustment strategy;
[0128] The reference preferred memory pre-allocation strategy is determined by the preset server according to the preset reference strategy allocation strategy, which allocates and determines each preferred memory pre-allocation strategy for the preset application running on all terminal devices within the preset local area network where the target terminal is located and running in the application scenario.
[0129] In an optional implementation, the initial memory pre-allocation policy update module device is further configured to:
[0130] Within a third preset time interval, a random adjustment memory pre-allocation strategy issued by the preset server is obtained, wherein the third preset time interval is greater than the second preset time interval;
[0131] So that the memory management device can use the randomly adjusted memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, and explore a new round of optimal memory pre-allocation strategy based on the memory allocation adjustment strategy;
[0132] The random adjustment of memory pre-allocation strategy is a memory pre-allocation strategy generated by the preset server after randomly adjusting each explored memory pre-allocation strategy when the preset application is running on multiple terminal devices with the same device performance score and the difference in the running performance score under the application scenario is less than a preset difference threshold.
[0133] In one optional implementation, the preset memory pre-allocation strategy configuration item in the memory pre-allocation strategy includes:
[0134] The number of sub-memory spaces of the central processing unit core, the size of memory blocks in each sub-memory space, the number of memory blocks of each size, the number of memory block reallocations, the memory fragmentation reclamation cycle, whether memory fragmentation reclamation is temporarily suppressed, and the time interval for suppressing memory fragmentation reclamation.
[0135] In one optional implementation, the memory management device further includes:
[0136] The memory pre-allocation module is used to pre-allocate memory for the preset application according to the default memory pre-allocation strategy during the operation of the preset application and in the application scenario.
[0137] The memory allocation request response module is used to determine the memory allocation path based on the memory space size of the memory allocation request when a memory allocation request is received.
[0138] The memory allocation module is used to allocate memory to the preset application in the memory space allocated according to the default memory pre-allocation strategy, according to the memory size requested in the memory allocation request, when the memory allocation path is a preset memory allocation optimization path.
[0139] The memory management device provided in this disclosure can execute the memory management method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of executing the method.
[0140] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.
[0141] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Reference is made below. Figure 6 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 6 The diagram below shows the structure of the terminal device or server 500. The terminal device in this embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and vehicle terminals (e.g., vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0142] like Figure 6As shown, electronic device 500 may include a processing unit (e.g., central processing unit, graphics processor, etc.) 501, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 502 or a program loaded from storage device 508 into random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of electronic device 500. The processing unit 501, ROM 502, and RAM 503 are interconnected via bus 504. An edit / output (I / O) interface 505 is also connected to bus 504.
[0143] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, magnetic tapes, hard disks, etc.; and communication devices 509. Communication device 509 allows electronic device 500 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 500 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0144] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, it performs the functions defined in the methods of embodiments of this disclosure.
[0145] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0146] The electronic device provided in this embodiment and the memory management method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0147] This disclosure also provides a computer storage medium storing a computer program thereon, which, when executed by a processor, implements the memory management method provided in the above embodiments.
[0148] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0149] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0150] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0151] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to:
[0152] During the operation of a preset application, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running.
[0153] Based on each adjusted memory pre-allocation strategy, memory space is pre-allocated for the preset application in the application scenario, and the running performance score of the preset application under each adjusted memory pre-allocation strategy is recorded.
[0154] Based on the performance scores, the preferred memory pre-allocation strategy of the preset application in the application scenario is determined, and the preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0155] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0157] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0158] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0159] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0160] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the memory management method provided in any embodiment of this disclosure.
[0161] In implementing a computer program product, computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0162] According to one or more embodiments of this disclosure, [Example 1] provides a memory management method, the method comprising:
[0163] During the operation of a preset application, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running.
[0164] Based on each adjusted memory pre-allocation strategy, memory space is pre-allocated for the preset application in the application scenario, and the running performance score of the preset application under each adjusted memory pre-allocation strategy is recorded.
[0165] Based on the performance scores, the preferred memory pre-allocation strategy of the preset application in the application scenario is determined, and the preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0166] According to one or more embodiments of this disclosure, [Example 2] provides a memory management method, further comprising:
[0167] The memory allocation adjustment strategy, based on a device performance matching the target terminal running the preset application and the application scenario in which the preset application runs, adjusts the current memory pre-allocation strategy under the application scenario at a first preset time interval, including:
[0168] Based on the device performance score of the target terminal, determine the target selection group for the memory allocation adjustment strategy of the preset application;
[0169] Based on the application scenario, a target memory allocation adjustment strategy is determined within the target selection group;
[0170] According to the target memory allocation adjustment strategy, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval.
[0171] According to one or more embodiments of this disclosure, [Example 3] provides a memory management method, including:
[0172] In some optional implementations, adjusting the current memory pre-allocation strategy for the application scenario according to the target memory allocation adjustment strategy includes:
[0173] According to the preset adjustment step size corresponding to each configuration item, at least one preset memory pre-allocation strategy configuration item in the current memory pre-allocation strategy is adjusted positively or negatively.
[0174] The current memory pre-allocation strategy is either the initial memory pre-allocation strategy of the preset application in the application scenario, or a memory pre-allocation strategy after at least one strategy adjustment based on the target memory allocation adjustment strategy and the initial memory pre-allocation strategy.
[0175] According to one or more embodiments of this disclosure, [Example 4] provides a memory management method, further comprising:
[0176] In some alternative implementations, the method further includes:
[0177] When the performance score of the preset application under any adjusted memory pre-allocation strategy is lower than the performance score under the original memory pre-allocation strategy, the direction of adjustment of the at least one preset memory pre-allocation strategy configuration item shall be changed during the next memory pre-allocation strategy adjustment.
[0178] According to one or more embodiments of this disclosure, [Example 5] provides a memory management method, further comprising:
[0179] In some alternative implementations,
[0180] The step of determining the preferred memory pre-allocation strategy for the preset application in the application scenario based on each of the aforementioned performance scores includes:
[0181] Based on the scores of each of the aforementioned performance scores, the memory pre-allocation strategies corresponding to each of the aforementioned performance scores are filtered, and the filtered memory pre-allocation strategies are sorted.
[0182] Among the sorted memory pre-allocation strategies, the corresponding memory pre-allocation strategies are selected as the preferred memory pre-allocation strategies in descending order of their corresponding performance scores.
[0183] According to one or more embodiments of this disclosure, [Example Six] provides a memory management method, further comprising:
[0184] In some alternative implementations, the method further includes:
[0185] The preferred memory pre-allocation strategy is used as the new initial memory pre-allocation strategy for the preset application in the application scenario, and a new round of exploration of preferred memory pre-allocation strategies is carried out according to the memory allocation adjustment strategy.
[0186] According to one or more embodiments of this disclosure, [Example Seven] provides a memory management method, further comprising:
[0187] In some alternative implementations, the method further includes:
[0188] According to the second preset time interval, a reference preferred memory pre-allocation strategy issued by the preset server is obtained, wherein the second preset time interval is greater than the first preset time interval;
[0189] Using the reference preferred memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, a new round of preferred memory pre-allocation strategy exploration is carried out according to the memory allocation adjustment strategy;
[0190] The reference preferred memory pre-allocation strategy is determined by the preset server according to the preset reference strategy allocation strategy, which allocates and determines each preferred memory pre-allocation strategy for the preset application running on all terminal devices within the preset local area network where the target terminal is located and running in the application scenario.
[0191] According to one or more embodiments of this disclosure, [Example Eight] provides a memory management method, further comprising:
[0192] Within a third preset time interval, a random adjustment memory pre-allocation strategy issued by the preset server is obtained, wherein the third preset time interval is greater than the second preset time interval;
[0193] Using the random adjustment memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, a new round of exploration of the optimal memory pre-allocation strategy is carried out based on the memory allocation adjustment strategy.
[0194] The random adjustment of memory pre-allocation strategy is a memory pre-allocation strategy generated by the preset server after randomly adjusting each explored memory pre-allocation strategy when the preset application is running on multiple terminal devices with the same device performance score and the difference in the running performance score under the application scenario is less than a preset difference threshold.
[0195] According to one or more embodiments of this disclosure, [Example Nine] provides a memory management method, further comprising:
[0196] The preset memory pre-allocation strategy configuration items in the memory pre-allocation strategy include:
[0197] The number of sub-memory spaces of the central processing unit core, the size of memory blocks in each sub-memory space, the number of memory blocks of each size, the number of memory block reallocations, the memory fragmentation reclamation cycle, whether memory fragmentation reclamation is temporarily suppressed, and the time interval for suppressing memory fragmentation reclamation.
[0198] According to one or more embodiments of this disclosure, Example 10 provides a memory management method, further comprising:
[0199] During the operation of the preset application, in the application scenario, memory is pre-allocated for the preset application according to the default memory pre-allocation strategy.
[0200] When a memory allocation request is received, the memory allocation path is determined based on the memory space size of the memory allocation request;
[0201] When the memory allocation path is a preset memory allocation optimization path, memory is allocated to the preset application in the memory space allocated according to the default memory pre-allocation strategy, according to the memory size requested in the memory allocation request.
[0202] According to one or more embodiments of this disclosure, [Example 11] provides a memory management apparatus, including:
[0203] The pre-allocation strategy adjustment module is used to adjust the current memory pre-allocation strategy under the application scenario at a first preset time interval, based on a memory allocation adjustment strategy that matches the device performance of the target terminal running the preset application and the application scenario in which the preset application is running.
[0204] The adjusted strategy testing module is used to pre-allocate memory space for the preset application in the application scenario based on each adjusted memory pre-allocation strategy, and record the running performance score of the preset application under each adjusted memory pre-allocation strategy.
[0205] The preferred pre-allocation strategy determination module is used to determine the preferred memory pre-allocation strategy of the preset application in the application scenario based on the performance scores of each application, and to set the preferred memory pre-allocation strategy as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
[0206] According to one or more embodiments of this disclosure, [Example Twelve] provides a memory management apparatus, further comprising:
[0207] In one optional implementation, the pre-allocation strategy adjustment module is specifically used for:
[0208] Based on the device performance score of the target terminal, determine the target selection group for the memory allocation adjustment strategy of the preset application;
[0209] Based on the application scenario, a target memory allocation adjustment strategy is determined within the target selection group;
[0210] According to the target memory allocation adjustment strategy, the current memory pre-allocation strategy under the application scenario is adjusted at a first preset time interval.
[0211] According to one or more embodiments of this disclosure, [Example Thirteen] provides a memory management apparatus, further comprising:
[0212] In an optional implementation, the pre-allocation strategy adjustment module is further configured to:
[0213] According to the preset adjustment step size corresponding to each configuration item, at least one preset memory pre-allocation strategy configuration item in the current memory pre-allocation strategy is adjusted positively or negatively.
[0214] The current memory pre-allocation strategy is either the initial memory pre-allocation strategy of the preset application in the application scenario, or a memory pre-allocation strategy after at least one strategy adjustment based on the target memory allocation adjustment strategy and the initial memory pre-allocation strategy.
[0215] According to one or more embodiments of this disclosure, [Example Fourteen] provides a memory management apparatus, further comprising:
[0216] In an optional implementation, the pre-allocation strategy adjustment module is further configured to:
[0217] When the performance score of the preset application under any adjusted memory pre-allocation strategy is lower than the performance score under the original memory pre-allocation strategy, the direction of adjustment of the at least one preset memory pre-allocation strategy configuration item shall be changed during the next memory pre-allocation strategy adjustment.
[0218] According to one or more embodiments of this disclosure, [Example Fifteen] provides a memory management apparatus, further comprising:
[0219] In one optional implementation, the preferred pre-allocation strategy determination module is specifically used for:
[0220] Based on the scores of each of the aforementioned performance scores, the memory pre-allocation strategies corresponding to each of the aforementioned performance scores are filtered, and the filtered memory pre-allocation strategies are sorted.
[0221] Among the sorted memory pre-allocation strategies, the corresponding memory pre-allocation strategies are selected as the preferred memory pre-allocation strategies in descending order of their corresponding performance scores.
[0222] According to one or more embodiments of this disclosure, [Example Sixteen] provides a memory management apparatus, further comprising:
[0223] In one optional implementation, the memory management device further includes:
[0224] The initial memory pre-allocation policy update module is used for:
[0225] The preferred memory pre-allocation strategy is used as the new initial memory pre-allocation strategy for the preset application in the application scenario, so that the memory management device can conduct a new round of preferred memory pre-allocation strategy exploration based on the memory allocation adjustment strategy.
[0226] According to one or more embodiments of this disclosure, [Example Seventeen] provides a memory management apparatus, further comprising:
[0227] In an optional implementation, the initial memory pre-allocation policy update module device is further configured to:
[0228] According to the second preset time interval, a reference preferred memory pre-allocation strategy issued by the preset server is obtained, wherein the second preset time interval is greater than the first preset time interval;
[0229] So that the memory management device uses the reference preferred memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, and explores a new round of preferred memory pre-allocation strategies according to the memory allocation adjustment strategy;
[0230] The reference preferred memory pre-allocation strategy is determined by the preset server according to the preset reference strategy allocation strategy, which allocates and determines each preferred memory pre-allocation strategy for the preset application running on all terminal devices within the preset local area network where the target terminal is located and running in the application scenario.
[0231] According to one or more embodiments of this disclosure, [Example 18] provides a memory management apparatus, further comprising:
[0232] In an optional implementation, the initial memory pre-allocation policy update module device is further configured to:
[0233] Within a third preset time interval, a random adjustment memory pre-allocation strategy issued by the preset server is obtained, wherein the third preset time interval is greater than the second preset time interval;
[0234] So that the memory management device can use the randomly adjusted memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, and explore a new round of optimal memory pre-allocation strategy based on the memory allocation adjustment strategy;
[0235] The random adjustment of memory pre-allocation strategy is a memory pre-allocation strategy generated by the preset server after randomly adjusting each explored memory pre-allocation strategy when the preset application is running on multiple terminal devices with the same device performance score and the difference in the running performance score under the application scenario is less than a preset difference threshold.
[0236] According to one or more embodiments of this disclosure, [Example Nineteen] provides a memory management apparatus, further comprising:
[0237] In one optional implementation, the preset memory pre-allocation strategy configuration item in the memory pre-allocation strategy includes:
[0238] The number of sub-memory spaces of the central processing unit core, the size of memory blocks in each sub-memory space, the number of memory blocks of each size, the number of memory block reallocations, the memory fragmentation reclamation cycle, whether memory fragmentation reclamation is temporarily suppressed, and the time interval for suppressing memory fragmentation reclamation.
[0239] According to one or more embodiments of this disclosure, [Example 20] provides a memory management apparatus, further comprising:
[0240] In one optional implementation, the memory management device further includes:
[0241] The memory pre-allocation module is used to pre-allocate memory for the preset application according to the default memory pre-allocation strategy during the operation of the preset application and in the application scenario.
[0242] The memory allocation request response module is used to determine the memory allocation path based on the memory space size of the memory allocation request when a memory allocation request is received.
[0243] The memory allocation module is used to allocate memory to the preset application in the memory space allocated according to the default memory pre-allocation strategy, according to the memory size requested in the memory allocation request, when the memory allocation path is a preset memory allocation optimization path.
[0244] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0245] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0246] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A memory management method, characterized in that, include: During the operation of a preset application, based on the device performance score of the target terminal running the preset application, the target selection group for the memory allocation adjustment strategy of the preset application is determined, and the memory allocation adjustment strategy is determined in the target selection group according to the application scenario in which the preset application is running; as well as Based on the memory allocation adjustment strategy, the current memory pre-allocation strategy in the application scenario is adjusted at a first preset time interval, including: adjusting at least one preset memory pre-allocation strategy configuration item in the current memory pre-allocation strategy in a positive or negative manner according to the preset adjustment step size corresponding to each configuration item; wherein, the current memory pre-allocation strategy is the initial memory pre-allocation strategy of the preset application in the application scenario, or, based on the target memory allocation adjustment strategy, the memory pre-allocation strategy after at least one strategy adjustment based on the initial memory pre-allocation strategy; Based on each adjusted memory pre-allocation strategy, memory space is pre-allocated for the preset application in the application scenario, and the running performance score of the preset application under each adjusted memory pre-allocation strategy is recorded. The running performance score is determined according to a weighted combination of multiple performance indicators. Based on the performance scores, the preferred memory pre-allocation strategy of the preset application in the application scenario is determined, and the preferred memory pre-allocation strategy is set as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
2. The method according to claim 1, characterized in that, The method further includes: When the performance score of the preset application under any adjusted memory pre-allocation strategy is lower than the performance score under the original memory pre-allocation strategy, the direction of adjustment of the at least one preset memory pre-allocation strategy configuration item shall be changed during the next memory pre-allocation strategy adjustment.
3. The method according to claim 1, characterized in that, The step of determining the preferred memory pre-allocation strategy for the preset application in the application scenario based on each of the aforementioned performance scores includes: Based on the scores of each of the aforementioned performance scores, the memory pre-allocation strategies corresponding to each of the aforementioned performance scores are filtered, and the filtered memory pre-allocation strategies are sorted. Among the sorted memory pre-allocation strategies, the corresponding memory pre-allocation strategies are selected as the preferred memory pre-allocation strategies in descending order of their corresponding performance scores.
4. The method according to claim 3, characterized in that, The method further includes: The preferred memory pre-allocation strategy is used as the new initial memory pre-allocation strategy for the preset application in the application scenario, and a new round of exploration of preferred memory pre-allocation strategies is carried out according to the memory allocation adjustment strategy.
5. The method according to claim 1, characterized in that, The method further includes: According to the second preset time interval, a reference preferred memory pre-allocation strategy issued by the preset server is obtained, wherein the second preset time interval is greater than the first preset time interval; Using the reference preferred memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, a new round of preferred memory pre-allocation strategy exploration is carried out according to the memory allocation adjustment strategy; The reference preferred memory pre-allocation strategy is determined by the preset server according to the preset reference strategy allocation strategy, which allocates and determines each preferred memory pre-allocation strategy for the preset application running on all terminal devices within the preset local area network where the target terminal is located and running in the application scenario.
6. The method according to claim 5, characterized in that, The method further includes: Within a third preset time interval, a random adjustment memory pre-allocation strategy issued by the preset server is obtained, wherein the third preset time interval is greater than the second preset time interval; Using the random adjustment memory pre-allocation strategy as the new initial memory pre-allocation strategy for the preset application in the application scenario, a new round of exploration of the optimal memory pre-allocation strategy is carried out based on the memory allocation adjustment strategy. The random adjustment of memory pre-allocation strategy is a memory pre-allocation strategy generated by the preset server after randomly adjusting each explored memory pre-allocation strategy when the preset application is running on multiple terminal devices with the same device performance score and the difference in the running performance score under the application scenario is less than a preset difference threshold.
7. The method according to any one of claims 1-6, characterized in that, The preset memory pre-allocation strategy configuration items in the memory pre-allocation strategy include: The number of sub-memory spaces of the central processing unit core, the size of memory blocks in each sub-memory space, the number of memory blocks of each size, the number of memory block reallocations, the memory fragmentation reclamation cycle, whether memory fragmentation reclamation is temporarily suppressed, and the time interval for suppressing memory fragmentation reclamation.
8. The method according to claim 1, characterized in that, The method further includes: During the operation of the preset application, in the application scenario, memory is pre-allocated for the preset application according to the default memory pre-allocation strategy. When a memory allocation request is received, the memory allocation path is determined based on the memory space size of the memory allocation request; When the memory allocation path is a preset memory allocation optimization path, memory is allocated to the preset application in the memory space allocated according to the default memory pre-allocation strategy, according to the memory size requested in the memory allocation request.
9. A memory management device, characterized in that, include: The pre-allocation strategy adjustment module is used to determine the target selection group of the memory allocation adjustment strategy of the preset application based on the device performance score of the target terminal running the preset application during the operation of the preset application, and to determine the memory allocation adjustment strategy in the target selection group according to the application scenario of the preset application. And based on the memory allocation adjustment strategy, at a first preset time interval, adjust the current memory pre-allocation strategy in the application scenario, including: according to the preset adjustment step size corresponding to each configuration item, adjust at least one preset memory pre-allocation strategy configuration item in the current memory pre-allocation strategy in a positive or negative manner; wherein, the current memory pre-allocation strategy is the initial memory pre-allocation strategy of the preset application in the application scenario, or, based on the target memory allocation adjustment strategy, the memory pre-allocation strategy after at least one strategy adjustment based on the initial memory pre-allocation strategy; The adjusted strategy testing module is used to pre-allocate memory space for the preset application in the application scenario based on each adjusted memory pre-allocation strategy, and record the running performance score of the preset application under each adjusted memory pre-allocation strategy, wherein the running performance score is determined according to a weighted combination of multiple performance indicators. The preferred pre-allocation strategy determination module is used to determine the preferred memory pre-allocation strategy of the preset application in the application scenario based on the performance scores of each application, and to set the preferred memory pre-allocation strategy as the default memory pre-allocation strategy of the preset application in the corresponding application scenario.
10. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the memory management method as described in any one of claims 1-8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the memory management method as described in any one of claims 1-8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the memory management method as described in any one of claims 1-8.
Citation Information
Patent Citations
Memory allocation optimization method and device, electronic equipment, medium and program product
CN114237903A
Coroutine stack resource configuration method and device, equipment and storage medium
CN114721829A