Memory resource management and control method and system, vehicle-mounted terminal and storage medium
By obtaining memory resource configuration files and monitoring the memory consumption of application processes, the application process exceeding the standard is moved to a multi-level control list for management and control, solving the problem of excessive memory usage in the existing technology and improving the system operation performance.
Patent Information
- Application Number
- CN202411760341.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-11
AI Technical Summary
The existing technology lacks an effective memory resource management mechanism, which leads to the memory usage of various applications in the system exceeding the standard, affecting the system's operating performance.
By obtaining the memory resource configuration file and the memory consumption of each application process, monitor whether the application process exceeds the standard, and move the application process exceeding the standard into a multi-level control list for management and control. The multi-level control list is divided into multiple control sub-tables according to the degree of control and the number of consecutive times of memory exceeding the standard. If the application process exceeds the standard in the highest control sub-table, the process will be terminated. If the standard does not exceed the standard in the lowest control sub-table, the control list will be removed.
Through a multi-level control list, the control and fallback mechanism is carried out to ensure that the memory usage of each application process runs within a reasonable range, thereby improving the smoothness and performance of the system.
Smart Images

Figure CN119603305A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of memory resource management, and in particular to a memory resource management method, system, vehicle-mounted terminal and storage medium. Background Art
[0002] In modern smart devices, especially embedded systems that require high-performance computing and multi-tasking capabilities, memory resource management is one of the key factors to ensure smooth system operation. With the development of technology, these devices not only need to support more and more applications and services, but also face the pressure of providing a smoother user experience. Therefore, the effective management and optimization of memory resources has become an important research direction.
[0003] In a multitasking operating system environment, memory resources are usually shared by multiple applications and services. Each application consumes a certain amount of memory resources during operation. When the system carries a large number of applications and services, if there is no reasonable memory management mechanism, the increase in the number of applications and their demand for resources may lead to excessive memory usage. This situation not only affects the response speed of the application, but may also cause the system to become unstable, with abnormal phenomena such as system freezes, black screens, and even restarts. However, the industry currently lacks a control mechanism for the problem of excessive memory usage of various applications in the system, which seriously affects the system's operating performance. Summary of the invention
[0004] In view of the shortcomings of the prior art mentioned above, the present application discloses a memory resource management method, system, vehicle-mounted terminal and storage medium, which are used to solve the technical problem of poor control effect on the excessive memory usage of various applications in the system in the prior art.
[0005] In the first aspect, the present application provides a memory resource management method, the method comprising: obtaining a memory resource configuration file and the memory consumption of each application process, the resource configuration file including a memory target value for each application process; monitoring each application process, and if it is detected that the memory consumption of any of the application processes is greater than the memory target value, determining that the memory of any of the application processes exceeds the standard, and moving any of the application processes into a multi-level management list for management, the multi-level management list being divided into a plurality of management sub-tables from low to high according to the degree of management and the number of consecutive times of memory exceeding the standard; if it is detected that any of the application processes exceeds the standard in the highest-level management sub-table, terminating any of the application processes; if it is detected that any of the application processes does not exceed the standard in the lowest-level management sub-table, moving any of the application processes out of the multi-level management list.
[0006] In one embodiment of the present application, moving any of the application processes into the multi-level control list for control includes: querying whether any of the application processes is in the multi-level control list; if it is not in the multi-level control list, moving any of the application processes into the lowest-level control subtable for control; if it is in the multi-level control list and not in the highest-level control subtable, moving any of the application processes from the current control subtable to a higher-level control subtable for control.
[0007] In one embodiment of the present application, the method also includes: if it is monitored that any of the application processes has not exceeded the memory limit in the multi-level control column, and any of the application processes is not in the lowest level control subtable, then any of the application processes is moved from the current control subtable to a lower level control subtable.
[0008] In one embodiment of the present application, the memory target value includes a foreground process target value and a background process target value; the configuration method of the resource configuration file includes: obtaining the application package name of each application process, and setting the foreground process target value and the background process target value of each application process; according to a preset data structure, compile and package the application package name, the foreground process target value and the background process target value of each application process to obtain the resource configuration file.
[0009] In one embodiment of the present application, the monitoring of each application process includes: obtaining the running mode of any of the application processes, the running modes including the foreground running mode and the background running mode; if any of the application processes is in the foreground running mode, the memory consumption is compared with the foreground process target value to monitor whether any of the application processes exceeds the memory limit; if any of the application processes is in the background running mode, the memory consumption is compared with the background process target value to monitor whether any of the application processes exceeds the memory limit.
[0010] In one embodiment of the present application, before obtaining the memory resource configuration file and the memory consumption of each application process, it also includes: setting an application process whitelist, and the application processes in the application process whitelist are not subject to memory resource control; according to the application process whitelist, the whitelist identifier of the target application process is written into the resource configuration file.
[0011] In one embodiment of the present application, before monitoring each application process, it also includes: parsing the resource configuration file to obtain process information of each application process; if the process information of any of the application processes contains the whitelist identifier, then no monitoring of whether any of the application processes exceeds the memory limit; if the process information of any of the application processes does not contain the whitelist identifier, then entering the monitoring operation of any of the application processes.
[0012] In the second aspect, the present application provides a memory resource management and control system, the system comprising: an acquisition module, used to obtain a memory resource configuration file and the memory consumption of each application process, the resource configuration file comprising a memory target value for each application process; a management and control module, used to monitor each application process, if it is detected that the memory consumption of any of the application processes is greater than the memory target value, it is determined that the memory of any of the application processes exceeds the standard, and any of the application processes is moved into a multi-level management and control list for management and control, the multi-level management and control list is divided into multiple management and control sub-tables from low to high according to the degree of management and the number of consecutive times of memory exceeding the standard; the management and control module is also used to terminate any of the application processes if it is detected that any of the application processes exceeds the standard in the highest-level management and control sub-table; if it is detected that any of the application processes does not exceed the standard in the lowest-level management and control sub-table, any of the application processes is moved out of the multi-level management and control list.
[0013] In a third aspect, the present application provides a vehicle-mounted terminal, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the vehicle-mounted terminal implements the memory resource management method described in the first aspect.
[0014] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer, the computer executes the memory resource management method described in the first aspect.
[0015] As described above, the memory resource management method, system, vehicle terminal and storage medium provided by the embodiments of the present application have the following beneficial effects:
[0016] First, the resource configuration file of the system memory and the memory consumption of each application process are obtained. The resource configuration file includes the memory target value of each application process. Then, each application process is monitored. If the memory consumption of any application process is detected to be greater than the memory target value, it is determined that the memory of any application process exceeds the standard, and any application process is moved into the multi-level control list for control. The multi-level control list is divided into multiple control sub-tables from low to high according to the control degree and the number of consecutive memory exceeding standards. If any application process is detected to have memory exceeding the standard in the highest-level control sub-table, any application process is terminated. If any application process is detected to have no memory exceeding the standard in the lowest-level control sub-table, any application process is moved out of the multi-level control list. By setting the multi-level control list, multi-level control processing is performed on the application process with excessive memory consumption, including the multi-level control and fallback mechanism of the memory occupation of each application process, so that the memory occupation of each application process runs under this mechanism, thereby improving the smoothness of system operation and ensuring the system operation performance.
[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0019] Figure 1 is a schematic diagram of an implementation environment of a memory resource management and control system shown in an exemplary embodiment of the present application;
[0020] Figure 2 is a flowchart of a memory resource control method shown in an exemplary embodiment of the present application;
[0021] Figure 3 is a schematic diagram of a vehicle system shown in an exemplary embodiment of the present application;
[0022] Figure 4 It is a flow chart of a vehicle system presetting resource configuration file shown in an exemplary embodiment of the present application;
[0023] Figure 5 It is a flowchart of a three-level memory resource management method shown in an exemplary embodiment of the present application;
[0024] Figure 6 is a flowchart of a specific memory resource control method shown in an exemplary embodiment of the present application;
[0025] Figure 7 is a block diagram of a memory resource management and control system shown in an exemplary embodiment of the present application;
[0026] Figure 8 It is a structural schematic diagram of a vehicle-mounted terminal provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0027] The following will describe the implementation methods of the present application with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, not for limiting the scope of protection of the present application.
[0028] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present application in a schematic manner, and therefore the illustrations only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the form, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0029] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present application difficult to understand.
[0030] First of all, it should be noted that effective management and optimization of memory resources in the system can effectively ensure the response speed of the application and avoid abnormal phenomena such as freezing, black screen and even restart caused by system instability. However, the inventors of this application have found that there is currently a lack of control mechanism for the problem of excessive memory usage of various applications in the system, which seriously affects the operating performance of the system.
[0031] Therefore, see Figure 1 , Figure 1 FIG. 1 is a schematic diagram of an implementation environment of a memory resource management and control system shown in an exemplary embodiment of the present application. Figure 1 As shown, the implementation environment includes a vehicle 110 and a memory resource management and control system 120, wherein the memory resource management and control system 120 is embedded in the vehicle 110, and is used to implement memory resource management of the system in the vehicle 110. The memory resource management and control system 120 includes but is not limited to a vehicle system, an on-board computer, etc. By setting a multi-level management and control list, multi-level management and control are performed on application processes with excessive memory consumption, including a multi-level management and fallback mechanism for the memory usage of each application process, so that the memory usage of each application process can be operated under this mechanism, thereby improving the smoothness of system operation and ensuring the system operation performance.
[0032] See also Figure 2 , Figure 2 is a flowchart of a memory resource control method shown in an exemplary embodiment of the present application. The method can be applied to Figure 1 The implementation environment shown is a schematic diagram. It should be understood that the method may also be applicable to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable.
[0033] In addition, in an embodiment of the present application, the memory resource management method can be applied to the Android system, that is, it can be applied to mobile devices of the Android system, such as mobile phones, car computers, etc. For example, it is suitable for memory resource management in the car computer system, and performs multi-level management and processing on the memory consumption of each Android application.
[0034] See also Figure 3 , Figure 3 is a schematic diagram of a vehicle system shown in an exemplary embodiment of the present application. The vehicle system may be a Qualcomm 8155 vehicle system. It should be understood that in the embodiment of the present application, the memory resource management method may be applicable to various vehicle systems. Figure 3 As shown in the figure, the car system is a virtualized dual-system architecture, including the QNX operating system and the Android operating system. The processor virtualization and memory virtualization are realized through HyperVision (virtualization architecture), so as to share hardware resources (memory resources and processor resources, etc.). The memory resources of the car system are an important hardware resource. The memory resources often determine the smoothness of the car system. The memory of the car system is shared by the QNX operating system and the Android operating system. The QNX operating system is the main system and is mainly responsible for instrument applications. The Android operating system is the slave system and is mainly responsible for central control entertainment information applications. In the Android operating system, there are various in-vehicle applications, such as vehicle settings, Bluetooth phones, multimedia, driving recorders, 360-degree surround view, air conditioning settings, voice, virtual images, etc. Each application will occupy memory resources when running. If the system is in a low memory state, it will cause abnormal phenomena such as car system freezes, black screens, and even restarts. Through the memory resource management and control method provided in this application, a multi-level management and control list is set up to perform multi-level management and control on application processes with excessive memory consumption in the vehicle system, including a multi-level management and fallback mechanism for the memory usage of each application process. The memory usage of each application process is controlled under this mechanism to avoid abnormal phenomena such as freezing, black screen, and even restart of the vehicle system, thereby improving the smoothness of the vehicle system operation and ensuring the operation performance of the vehicle system.
[0035] like Figure 2 As shown, in an exemplary embodiment, the memory resource management method includes at least steps S210 to S230, which are described in detail as follows:
[0036] Step S210, obtaining a memory resource configuration file and memory consumption of each application process, wherein the resource configuration file includes a memory target value of each application process.
[0037] It should be noted that each application process in the system is set with a memory target value, which is used to determine whether the memory usage of the application process exceeds the standard. The memory target value of each application process can be set according to its own business logic, so that the application process can complete the business logic within a certain memory target value. The setting of the memory target value needs to consider factors such as its own business logic and the total system memory, and formulate a relatively accurate value within a certain range. In addition, the memory consumption of each application process is the real-time memory usage value of each application process.
[0038] In one embodiment, the memory target value includes a foreground process target value and a background process target value; the configuration method of the resource configuration file includes: obtaining the application package name of each application process, and setting the foreground process target value and the background process target value of each application process; according to a preset data structure, the application package name, the foreground process target value and the background process target value of each application process are compiled and packaged to obtain a resource configuration file.
[0039] It should be noted that the application process in the system may be in the foreground running state or in the background running state. Taking into account that the same application process consumes different memory resources in the foreground running state and the background running state, in this embodiment, the memory target value of each application process includes a foreground process target value and a background process target value, so that the foreground process target value or the background process target value is selected as the judgment standard whether the memory usage exceeds the standard according to the running state of each application process. In this way, different memory resources are allocated according to the actual running state of the application process, which can further ensure the management and control effect of the system memory resources.
[0040] Specifically, when an application process is in the foreground, it usually has a higher priority because the user is interacting with it, so a higher foreground process target value is set to ensure that the application has sufficient memory resources to maintain a good user experience. On the contrary, when the application process is in the background, since it is not the focus of the user's current attention, a lower background process target value can be set to limit the memory usage of these processes, thereby freeing up more memory for other more important tasks. In this way, it can ensure that the foreground application has sufficient resource support, and prevent the background application from excessively occupying memory resources, thereby avoiding the risk of overall system performance degradation.
[0041] For example, the memory target value of the navigation application is set to 500MB when it is in the foreground process, and the memory target value is set to 350MB when it is in the background process; the memory target value of the vehicle setting is set to 300MB when it is in the foreground process, and the memory target value is set to 200MB when it is in the background process; the memory target value of the driving recorder is set to 350MB when it is in the foreground process, and the memory target value is set to 250MB when it is in the background process.
[0042] In addition, in this embodiment, the preset data structure includes an application package name field, a foreground process target value field, and a background process target value field. According to the data structure, the application package name, foreground process target value, and background process target value of each application process are compiled and packaged to obtain a resource configuration file of the system memory.
[0043] For example, according to the data structure, the application package name, the foreground process target value, and the background process target value of the vehicle setting are compiled and packaged as follows:
[0044] <item>
[0045] <process_name>com.android.carsetting< / process_name>
[0046] <forground_value>300< / forground_value>
[0047] <background_value>200< / background_value>
[0048] < / item>
[0049] In one embodiment, before obtaining the memory resource configuration file and the memory consumption of each application process, it also includes: setting an application process whitelist, and the application processes in the application process whitelist are not subject to memory resource control; according to the application process whitelist, the whitelist identifier of the target application process is written into the resource configuration file.
[0050] In this embodiment, considering the life cycle of important application processes in the system, it is not appropriate to forcibly terminate them due to excessive memory consumption, so a whitelist of application processes is set. The application processes in the list are not subject to memory resource management and control, and the whitelist identifiers of these application processes are written into the resource configuration file. In this way, the life cycle of important application processes is protected through the memory whitelist mechanism, avoiding these important application processes from being forcibly terminated due to excessive memory consumption.
[0051] For example, if the vehicle setting is not a whitelist process, the fields in the vehicle setting section of the resource configuration file are as follows:
[0052] <item>
[0053] <process_name>com.android.carsetting< / process_name>
[0054] <forground_value>300< / forground_value>
[0055] <background_value>200< / background_value
[0056] <white_list>false< / white_list>
[0057] < / item>
[0058] If the vehicle is set as a whitelist process, the fields in the vehicle settings section of the resource configuration file are as follows:
[0059] <item>
[0060] <process_name>com.android.carsetting< / process_name>
[0061] <forground_value>300< / forground_value>
[0062] <background_value>200< / background_value
[0063] <white_list>true< / white_list>
[0064] < / item>
[0065] It should also be noted that whether each application process is a whitelist process can be set according to specific needs.
[0066] See also Figure 4 , Figure 4 FIG. 1 is a flow chart of a vehicle system presetting resource configuration file shown in an exemplary embodiment of the present application. Figure 4As shown in the figure, the steps of compiling and packaging the resource configuration file of the vehicle computer application memory based on the continuous integration tool (such as Jenkins) are detailed as follows: first, the compilation and packaging task is initiated through the continuous integration tool; then the system source code stage is entered, where the system source code is such as the source code of the memory resource configuration file and the source code of the product configuration file, etc. The memory resource configuration file is a configuration file used to define the target value of the vehicle computer application memory usage, and the product configuration file is used to customize the compilation options and build parameters; then the continuous integration tool executes the compilation task, and packages the system source code and its configuration file together into an installable system flashing package; finally, the generated system flashing package is written into the vehicle computer system. After the writing is successful, the vehicle computer system contains the memory resource configuration file. After the vehicle computer system is running, it will read this file and parse it into the corresponding data structure as the judgment condition whether the application memory consumption exceeds the standard.
[0067] Step S220, monitor each application process. If it is monitored that the memory consumption of any application process is greater than the memory target value, it is determined that the memory of any application process exceeds the standard, and any application process is moved into the multi-level control list for control. The multi-level control list is divided into multiple control sub-tables from low to high according to the control degree and the number of consecutive times of memory exceeding the standard.
[0068] In this embodiment, the more times the memory exceeds the limit continuously, the more the application process is in a state of continuous memory exceeding the limit, and the higher the control degree. In addition, the multi-level control list is used to control the application process with excessive memory. Therefore, the multi-level control list is divided into multiple control sub-tables from low to high according to the control degree and the number of consecutive times the memory exceeds the limit. If any application process exceeds the limit, the application process is controlled to different degrees according to the number of consecutive times the memory exceeds the limit.
[0069] In this embodiment, the multi-level control list is divided into multiple control sub-tables according to the control degree and the number of consecutive memory overruns from low to high, and each control sub-table implements multi-level control of memory resources. In addition, the number of control sub-tables divided according to the control degree and the number of consecutive memory overruns from low to high is not limited in this embodiment. For example, three control sub-tables can be divided to form a three-level control of memory resources, and four control sub-tables can be divided to form a four-level control of memory resources.
[0070] In one embodiment, each application process is monitored, including: obtaining the running mode of any application process, the running mode including the foreground running mode and the background running mode; if any application process is in the foreground running mode, the memory consumption is compared with the foreground process target value to monitor whether any application process exceeds the memory limit; if any application process is in the background running mode, the memory consumption is compared with the background process target value to monitor whether any application process exceeds the memory limit.
[0071] In this embodiment, the foreground process target value or the background process target value is selected as the judgment standard for whether the memory usage exceeds the standard according to the running status of each application process. In this way, different memory resources are allocated according to the actual running status of the application process, and the memory exceeding standard can be effectively adjusted dynamically according to the different running status of the application process, thereby ensuring the accuracy of the obtained memory exceeding standard result.
[0072] In one embodiment, any application process is moved into a multi-level control list for control, including: querying whether any application process is in the multi-level control list; if it is not in the multi-level control list, moving any application process into the lowest-level control subtable for control; if it is in the multi-level control list and not in the highest-level control subtable, moving any application process from the current control subtable to a higher-level control subtable for control.
[0073] In this embodiment, when it is determined that the memory of any application process exceeds the limit, it is first checked whether any application process is in the multi-level control list. If it is not in the multi-level control list, any application process is moved to the lowest-level control subtable for control. If it is in the multi-level control list and not in the highest-level control subtable, any application process is moved from the current control subtable to a higher-level control subtable for control. In this way, the application process is moved step by step into the highest-level control subtable according to the number of memory exceeding limits, thereby gradually improving the memory control degree of the application process and realizing multi-level control of memory resources.
[0074] In one embodiment, before monitoring each application process, it also includes: parsing the resource configuration file to obtain the process information of each application process; if the process information of any application process contains a whitelist identifier, then any application process is not monitored for memory excess; if the process information of any application process does not contain a whitelist identifier, then the monitoring operation of any application process is entered.
[0075] In this embodiment, memory resource control is not performed for whitelist processes, and the life cycle of important application processes is guaranteed by the whitelist mechanism. In this way, the problem of important application processes being forced to terminate due to excessive memory consumption is avoided, thereby ensuring customer experience.
[0076] Step S230, if it is monitored that any application process exceeds the memory limit in the highest-level control subtable, then terminate any application process; if it is monitored that any application process does not exceed the memory limit in the lowest-level control subtable, then remove any application process from the multi-level control list.
[0077] In this embodiment, if any application process is monitored to have memory overrun in the highest-level control subtable, it indicates that the application process has reached the preset threshold of consecutive overrun times, its control level is the highest level, and its memory overrun situation is serious, so the application process is terminated to ensure the smoothness of system operation; and if any application process is monitored to have no memory overrun in the lowest-level control subtable, the application process is removed from the multi-level control list, and the fallback mechanism is used to reduce the application memory consumption below the target value, thereby ensuring the life cycle of the application process under reasonable memory consumption. In this way, combined with the multi-level control and fallback mechanism of memory overrun, each application process runs within a certain memory range, ensuring the system's operating performance.
[0078] In one embodiment, if it is monitored that any application process does not exceed the memory limit in the multi-level control column, and any application process is not in the lowest level control subtable, then any application process is moved from the current control subtable to a lower level control subtable.
[0079] In this embodiment, for application processes that are in the multi-level control column but currently have not exceeded the memory limit, the multi-level control column is gradually removed according to the number of consecutive times that the memory limit has not exceeded the limit, so that the application processes that have not exceeded the memory limit are controlled. In this way, a step-by-step fallback mechanism is used when the application memory consumption drops below the target value, which further guarantees the life cycle of the application process under reasonable memory consumption.
[0080] In a possible embodiment, when terminating an application process from the highest-level control sub-table of the multi-level control list, all application processes in the highest-level control sub-table that still have excessive memory will be terminated, or, based on the system memory usage (such as the total memory consumption does not exceed a certain threshold), at least one of these application processes will be terminated according to a preset termination policy, wherein the termination policy is based on the importance level of the application process (application processes with higher levels are terminated later), the running status (background application processes are terminated first), or the size of the application process memory consumption (application processes with larger memory consumption are terminated first), etc.
[0081] In this way, the life cycle of each application process can be effectively protected while ensuring the system operation performance.
[0082] See also Figure 5 , Figure 5 FIG. 1 is a flowchart of a three-level memory resource management method shown in an exemplary embodiment of the present application. Figure 5 As shown, the multi-level control list includes three control sub-lists, which are the first-level control list, the second-level control list and the third-level control list according to the control degree and the number of consecutive times of memory exceeding the standard. This three-level control method of memory resources is suitable for vehicle-computer systems.
[0083] After the vehicle system is started, it starts to run. At this time, it starts to monitor the memory consumption of each application process, and monitors it every once in a while. Each monitoring enters the same process. First, filter the application processes in the memory whitelist, and then judge whether the memory usage exceeds the standard based on the memory consumption of each application process and the preset memory target value. The application processes with excessive memory usage enter the corresponding control list. The control list is divided into three levels. The processes entering the first-level control list are the least strict. If the memory is not exceeded in the next detection, they will be removed from the control. The second-level control list is more strict. The processes in the third-level control list are the most dangerous. The next time the memory is detected to be exceeded, they will be forcibly terminated by this mechanism. Among them, the three-level control of application memory usage exceeding the standard includes: when it is detected that the application process memory usage exceeds the standard, the application process will enter the first-level control list in turn. If the application process memory usage is still exceeded in the next monitoring, the application process will be moved to the second-level control list, and so on, it will be moved to the third-level control list until the next detection. If there is still an application process with excessive memory usage in the third-level control list, the application process will be terminated; the fallback mechanism when the memory consumption drops below the target value includes: when the memory consumption of the application process drops below the target value, the fallback mechanism will roll back the application process in the corresponding process list to the previous level, the application process in the third-level control list will be rolled back to the second-level control list, the application process in the second-level control list will be rolled back to the first-level control list, and the application process in the first-level control list will be removed from the monitoring, and the judgment of excessive memory usage will continue.
[0084] See also Figure 6 , Figure 6 FIG. 1 is a flowchart of a specific memory resource control method shown in an exemplary embodiment of the present application. Figure 6 As shown, this specific memory resource control method is applicable to the vehicle system, and the steps are detailed as follows:
[0085] 1. After the car system is started, start the ActivityManagerService service (that is, the system service responsible for system application life cycle management, process management and user interaction functions);
[0086] 2. Start MemoryTargetMonitor (i.e. memory monitor) to enable the memory consumption monitoring and processing function of the application process. MemoryTargetMonitor is a newly added core module for monitoring and processing abnormal memory consumption of vehicle-mounted applications;
[0087] 3. MemoryTargetMonitor reads the memory resource configuration file and parses it into a preset data structure style, namely the application package name, foreground process target value, background process target value and whitelist identifier;
[0088] 4. MemoryTargetMonitor obtains the memory consumption of each application process in the system every preset time period (such as 30 seconds);
[0089] 5. Find the memory target value of each application process in the parsing results and filter the whitelist processes;
[0090] 6. Compare memory consumption with memory target value;
[0091] 7. Determine whether the memory consumption of each application process exceeds the standard based on the comparison results;
[0092] 8. If the application process is determined to be a process with excessive memory usage in this memory detection, first check whether the third-level control list includes the application process. If it does, terminate the application process; if the third-level control list does not include the application process, continue to the second-level control list; if the second-level control list includes the application process, move the application process to the third-level control list; if the second-level control list does not include the application process, continue to search the first-level control list; if the first-level control list includes the application process, move the application process to the second-level control list; if the first-level control list does not include the application process, move the application process to the first-level control list;
[0093] 9. If the memory consumption of the application process does not exceed the standard in this memory detection, first check whether the third-level control list includes the application process. If it does, roll back the application process to the second-level control list; if the third-level control list does not include the application process, continue to query the second-level control list; if the second-level control list includes the application process, roll back the application process to the first-level control list; if the second-level control list does not include the application process, continue to search the first-level control list; if the first-level control list includes the application process, remove the application process from the first-level control list.
[0094] The above-mentioned memory resource control method first obtains the resource configuration file of the memory in the system and the memory consumption of each application process, and the resource configuration file includes the memory target value of each application process, and then monitors each application process. If it is monitored that the memory consumption of any application process is greater than the memory target value, it is determined that the memory of any application process exceeds the standard, and any application process is moved into a multi-level control list for control, wherein the multi-level control list is divided into multiple control sub-tables from low to high according to the control degree and the number of consecutive times of memory exceeding the standard. If it is monitored that any application process exceeds the standard in the highest-level control sub-table, any application process is terminated. If it is monitored that any application process does not exceed the standard in the lowest-level control sub-table, any application process is moved out of the multi-level control list. By setting the multi-level control list, multi-level control processing is performed on the application process with excessive memory consumption, including a multi-level control and fallback mechanism for the memory occupancy of each application process, so that the memory occupancy of each application process runs under this mechanism, thereby improving the smoothness of system operation and ensuring the system operation performance.
[0095] See also Figure 7 , Figure 7 is a block diagram of a memory resource management system shown in an exemplary embodiment of the present application. The system can be applied to Figure 1 The implementation environment shown is a schematic diagram. It should be understood that the system may also be applicable to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the system is applicable.
[0096] like Figure 7 As shown, in an exemplary embodiment, the memory resource management and control system 700 includes at least an acquisition module 710 and a management and control module 720, which are described in detail as follows:
[0097] An acquisition module 710 is used to acquire a memory resource configuration file and memory consumption of each application process, wherein the resource configuration file includes a memory target value of each application process;
[0098] The control module 720 is used to monitor each application process. If the memory consumption of any application process is detected to be greater than the memory target value, it is determined that the memory of any application process exceeds the target value, and any application process is moved into a multi-level control list for control. The multi-level control list is divided into multiple control sub-tables from low to high according to the control degree and the number of consecutive times of memory exceeding the target value;
[0099] The control module 720 is also used to terminate any application process if it is monitored that the memory of any application process exceeds the limit in the highest-level control subtable; if it is monitored that any application process does not exceed the memory in the lowest-level control subtable, then any application process is removed from the multi-level control list.
[0100] It should be noted that the memory resource management system provided in the above embodiment and the memory resource management method provided in the above embodiment belong to the same concept, wherein the contents of the operations performed by each module have been described in detail in the method embodiment and will not be repeated here.
[0101] See also Figure 8 , Figure 8 It is a structural schematic diagram of a vehicle-mounted terminal provided by an exemplary embodiment of the present application. Figure 8 The structure diagram of the computer system of the vehicle terminal suitable for implementing the embodiment of the present application is shown. It should be noted that: Figure 8 The computer system 800 of the vehicle-mounted terminal shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0102] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803, such as executing the method in the above embodiment. In RAM 803, various programs and data required for system operation are also stored. CPU 801, ROM 802 and RAM 803 are connected to each other through bus 804. Input / output (I / O) interface 805 is also connected to bus 804.
[0103] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0104] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 809, and / or installed from a removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, various functions defined in the system of the present application are executed.
[0105] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the memory resource management method as described above. The computer-readable storage medium may be included in the vehicle-mounted terminal described in the above embodiment, or may exist independently without being assembled into the vehicle-mounted terminal.
[0106] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0107] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0108] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not constitute limitations on the units themselves in some cases.
[0109] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A memory resource management method, characterized in that: The method comprises: Obtaining a memory resource configuration file and memory consumption of each application process, wherein the resource configuration file includes a memory target value of each application process; Monitor each application process. If it is detected that the memory consumption of any application process is greater than the memory target value, determine that the memory of any application process exceeds the target value, and move any application process into a multi-level control list for control. The multi-level control list is divided into multiple control sub-tables from low to high according to the control degree and the number of consecutive times of memory exceeding the target value; If it is monitored that any of the application processes exceeds the memory limit in the highest-level control subtable, any of the application processes will be terminated; if it is monitored that any of the application processes does not exceed the memory limit in the lowest-level control subtable, any of the application processes will be removed from the multi-level control list.
2. The memory resource management method according to claim 1, characterized in that: The step of moving any of the application processes into a multi-level control list for control includes: Query whether any of the application processes is in the multi-level control column; If it is not in the multi-level control list, any of the application processes is moved to the lowest level control sub-table for control; If it is in the multi-level control list and not in the highest-level control sub-list, any of the application processes will be moved from the current control sub-list to a higher-level control sub-list for control.
3. The memory resource management method according to claim 2, characterized in that: The method further comprises: If it is monitored that any of the application processes does not exceed the memory limit in the multi-level control column, and any of the application processes is not in the lowest level control subtable, then any of the application processes will be moved from the current control subtable to a lower level control subtable.
4. The memory resource management method according to claim 1, characterized in that: The memory target value includes a foreground process target value and a background process target value; The configuration method of the resource configuration file includes: Obtaining the application package name of each application process, and setting the foreground process target value and the background process target value of each application process; According to a preset data structure, the application package name, the foreground process target value and the background process target value of each application process are compiled and packaged to obtain the resource configuration file.
5. The memory resource management method according to claim 4, characterized in that: The monitoring of each application process includes: Obtaining the running mode of any of the application processes, wherein the running mode includes a foreground running mode and a background running mode; If any of the application processes is in the foreground running mode, the memory consumption is compared with the foreground process target value to monitor whether any of the application processes exceeds the memory limit; If any of the application processes is in the background running mode, the memory consumption is compared with the background process target value to monitor whether any of the application processes exceeds the memory limit.
6. The memory resource management method according to any one of claims 1 to 5, characterized in that: Before obtaining the memory resource configuration file and the memory consumption of each application process, the method further includes: Setting an application process whitelist, wherein the application processes in the application process whitelist are not subject to memory resource control; According to the application process whitelist, the whitelist identifier of the target application process is written into the resource configuration file.
7. The memory resource management method according to claim 6, characterized in that: Before monitoring each application process, the method further includes: Parsing the resource configuration file to obtain process information of each application process; If the process information of any of the application processes contains the whitelist identifier, then whether any of the application processes exceeds the memory limit is not monitored; If the process information of any of the application processes does not include the whitelist identifier, the monitoring operation of any of the application processes is entered.
8. A memory resource management and control system, characterized in that: The system comprises: An acquisition module, used to acquire a memory resource configuration file and memory consumption of each application process, wherein the resource configuration file includes a memory target value of each application process; A control module is used to monitor each application process. If it is monitored that the memory consumption of any application process is greater than the memory target value, it is determined that the memory of any application process exceeds the target value, and any application process is moved into a multi-level control list for control. The multi-level control list is divided into multiple control sub-tables from low to high according to the control degree and the number of consecutive times of memory exceeding the target value; The control module is also used to terminate any application process if it is monitored that the memory of any application process exceeds the limit in the highest-level control subtable; if it is monitored that the memory of any application process does not exceed the limit in the lowest-level control subtable, remove any application process from the multi-level control list.
9. A vehicle-mounted terminal, characterized in that: include: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the vehicle terminal to implement the memory resource management method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the memory resource management method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Memory optimization method and apparatus, and user equipment
CN106326137A
Dual system-based memory management method and apparatus
CN107766145A
Process management and control method based on Android system
CN108804207A
System resource utilization rate regulation and control method and device based on Agent process, equipment and medium
CN114968561A
Method and device for managing and controlling resources occupied by application program and medium
CN115794549A
Cited By
Watchdog circuit monitoring device and system
CN120179450A
Interface management method and device, new energy automobile and storage medium
CN120653352A