Memory control method and device and electronic equipment
By locking the physical memory area of the target application, preventing data from being displaced into virtual memory, the memory write amplification problem is solved, and the application's running speed and user experience is improved.
Patent Information
- Application Number
- CN202411218020.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-22
AI Technical Summary
In electronic devices, due to tight memory resources when the application is running, physical memory data is replaced with virtual memory, resulting in memory write amplification problems, which reduces the speed of the application and affects the user experience.
By determining the target application, controlling the physical memory area it applies to enter a locked state, preventing memory data from being displaced into virtual memory, thereby avoiding memory write amplification issues and ensuring fast response of the application.
It effectively avoids the problem of memory write amplification, improves the speed and user experience of the application, especially when there is insufficient memory resources.
Smart Images

Figure CN119003182A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a memory control method, device and electronic device. Background Art
[0002] As the functions of applications become increasingly powerful and complete, the memory space occupied by applications when running on electronic devices is getting larger and larger. When the memory resources of electronic devices are relatively tight, the operating system will replace the memory data in the physical memory of the currently running application with the virtual memory, causing the application process to use certain memory data and experience memory write amplification. This increases the application's response time for using the memory data replaced from the physical memory to the virtual memory, thereby reducing the application's running speed and affecting the user's experience of using the application. Summary of the invention
[0003] In view of the above problems, this application discloses the following technical solutions:
[0004] The first aspect of the present application provides a memory control method, comprising:
[0005] In response to a first application of the electronic device being started and running, obtaining application information of the first application;
[0006] In a case where it is determined based on the application information that the first application belongs to a target application, controlling the target memory area applied for by the first application to enter a locked state;
[0007] The target memory area belongs to the physical memory of the electronic device; in the locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device.
[0008] In a possible implementation, the method further includes:
[0009] In response to the first application being switched from a foreground running state to a target application state, controlling the target memory area to remain in the locked state or to switch from the locked state to a corresponding released state;
[0010] Among them, after the first application is switched from the foreground running state to a different application state, the release state of the memory resources corresponding to the target memory area is different.
[0011] In a possible implementation, in response to the first application being switched from the foreground running state to the target application state, controlling the target memory area to remain in the locked state or switching from the locked state to a corresponding released state includes at least one of the following:
[0012] In response to the first application being switched from a foreground running state to a background running state, controlling at least a portion of the target memory area to remain in the locked state;
[0013] In response to the first application being switched from a foreground running state to a suspended state, controlling the target memory area to be switched from the locked state to a first released state, in which memory data in the target memory area can be replaced to a virtual memory of the electronic device;
[0014] In response to the first application being switched from a running state to a closed state, the target memory area is controlled to be switched from the locked state to a second released state, and in the second released state, memory resources corresponding to the target memory area are released.
[0015] In a possible implementation, in response to a first application of the electronic device being started and running, obtaining application information of the first application includes at least one of the following:
[0016] In response to obtaining a control instruction for starting to run a first application, obtaining application information of the first application based on the control instruction;
[0017] In response to a triggering operation of obtaining an application icon acting on the first application, obtaining application information of the first application based on the application icon;
[0018] In response to obtaining a calling instruction from a second application, application information of the called first application is obtained based on interaction data or context data in the second application.
[0019] In a possible implementation, the method further includes:
[0020] Based on the type and / or source of the application information, the application category to which the first application belongs and / or the priority sequence to which the first application belongs are determined in different ways.
[0021] In a possible implementation, when it is determined that the first application belongs to a target application, the method further includes:
[0022] Using a memory processing function to monitor memory request information of a first application process, where the first application process is a core process of the first application program;
[0023] In the case of monitoring a memory application request from the first application process, controlling a target memory area requested by the memory application request to enter a locked state.
[0024] In a possible implementation, the method further includes:
[0025] Adding memory information corresponding to the memory application request to a memory management file, wherein the memory management file is used to record memory allocation information of a target application;
[0026] as well as,
[0027] When a memory destruction request from the first application process is monitored, the corresponding memory information in the memory management file is deleted or reconfigured to control the target memory area to switch from the locked state to the released state.
[0028] In a possible implementation, the method further includes:
[0029] In response to determining that the electronic device runs a third application belonging to the target application, obtaining memory resource status information of the electronic device;
[0030] When it is determined that the memory resources of the electronic device are insufficient based on the memory resource status information, based on the priority sequences of the first application and the third application, the target memory area applied for by the first application and / or the second application is controlled to switch from the locked state to the corresponding released state.
[0031] The second aspect of the present application also provides a memory control device, including:
[0032] an application information obtaining module, configured to obtain application information of a first application of the electronic device in response to the first application being started and run;
[0033] a memory control module, configured to control a target memory area applied for by the first application to enter a locked state when it is determined based on the application information that the first application belongs to a target application;
[0034] The target memory area belongs to the physical memory of the electronic device; in the locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device.
[0035] The third aspect of the present application further provides an electronic device, comprising: a memory chip and a memory controller, wherein:
[0036] The memory chip is configured with a physical memory including a plurality of memory areas, and is used to store memory data of application programs applied to corresponding memory areas;
[0037] The memory controller is used to execute multiple computer-readable instructions to implement the following steps:
[0038] In response to a first application of the electronic device being started and running, obtaining application information of the first application;
[0039] and, in a case where it is determined based on the application information that the first application belongs to a target application, controlling the target memory area applied for by the first application to enter a locked state;
[0040] The target memory area belongs to the physical memory; in the locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent 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.
[0042] Figure 1 A flowchart of a memory control method provided in Embodiment 15 of the present application;
[0043] Figure 2 A flowchart of a memory control method provided in Embodiment 2 of the present application;
[0044] Figure 3 A schematic diagram of a control flow of switching a lock state of a target memory area applied for by a first application program in a memory control method provided in an embodiment of the present application;
[0045] Figure 4 A flowchart of a memory control method provided in Embodiment 3 of the present application;
[0046] Figure 5 A flowchart of a memory control method provided in Embodiment 4 of the present application;
[0047] Figure 6 A flowchart of a memory control method provided in Embodiment 5 of the present application;
[0048] Figure 7 A schematic diagram of the structure of a memory control device provided in an embodiment of the present application;
[0049] Figure 8 A schematic diagram of an optional hardware structure of an electronic device applicable to the memory control method proposed in this application;
[0050] Fig. 9 The figure is another optional hardware structure diagram of an electronic device suitable for the memory control method proposed in the present application. DETAILED DESCRIPTION
[0051] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application and are not intended to limit the present application. The embodiments of the present application are described below in conjunction with the drawings. It is known to those of ordinary skill in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0052] The terms "first", "second" etc. in the above text of the application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable in appropriate circumstances, and this is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0053] In order to solve the above problems, the embodiment of the present application provides a memory control method. For each application configured in the electronic device, a target application that is prohibited from replacing the memory data stored in the physical memory with the virtual memory can be pre-selected. In this way, when any application in the electronic device is started to run, it is determined that the application belongs to the target application, and the target memory area belonging to the physical memory applied by the application is promptly controlled to enter a locked state, that is, the target memory area applied by the application is protected, and the memory data of the target memory area is prohibited from being replaced with the virtual memory, thereby avoiding the memory write amplification problem when the application uses the memory data, and ensuring the running speed of the application. The memory control method of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.
[0054] Reference Figure 1 , is a flowchart of a memory control method provided in the first embodiment of the present application. The memory control method can be applied to electronic devices, which may include but are not limited to terminals such as mobile phones, laptops, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, desktop computers or smart medical / transportation business devices. The present application does not limit the product form of electronic devices. Figure 1 As shown, the memory control method provided by the embodiment of the present application may include but is not limited to the following steps:
[0055] Step S101, in response to a first application of an electronic device being started and running, obtaining application information of the first application;
[0056] In combination with the above description of the technical solution of the present application, when any application supported by the electronic device (referred to as the first application) is started, in order to determine whether the first application needs to protect the target memory area applied for by the physical memory locking method, the application information of the first application can be obtained. The application information may include but is not limited to: one or more combinations of application type information, application identification information, application window information, and application display position information. In an embodiment of the present application, the application information can be configured based on the difference information between the target application (i.e., the application that needs to implement memory protection through physical memory locking) and the non-target application in the electronic device, so that it can distinguish whether the first application belongs to the target application or the non-target application. The present application does not limit the content of the application information and the method of obtaining it.
[0057] In some embodiments, one or more application startup methods can be determined based on factors such as the current operating status of the electronic device and the supported operating methods, so that when it is necessary to start the first application, any application startup method can be used to trigger the start of the first application. This application does not limit the various application startup methods and their implementation methods.
[0058] In one possible implementation, the first application can be started by triggering the first application through user operation, such as using an input device such as a finger, a joystick, a mouse key, a stylus / stylus pen, etc. to perform a trigger operation on or near an application icon of the first application displayed on a touch screen of the electronic device. The electronic device responds to the trigger operation on the application icon of the first application to control the start-up of the first application.
[0059] It should be understood that, in the case where the electronic device supports functions such as a voice assistant, the electronic device can also collect the startup voice signal output by the user for the first application, generate a startup instruction for the first application in response to the startup voice signal, execute the startup instruction, and control the startup of the first application. In addition, the user can perform corresponding input operations according to the pre-configured designated gestures, patterns, or function keys for starting the first application, such as inputting a designated finger, drawing the pattern, or touching the function key, and the electronic device responds to the input operation to control the startup of the first application. This application does not limit the implementation method of how to trigger the startup of the first application through user operations.
[0060] In another possible implementation of starting the first application, since in actual applications, the electronic device will not only run the first application, but may also run other applications, and during the operation of the other applications, there is a need to use the first application, and a start / call request for the first application can be generated. The electronic device responds to the request and starts the first application. It can be seen that in the start-up method of the first application, the electronic device can autonomously trigger the start-up of the first application, but is not limited to the trigger implementation method described in this embodiment. It can also be based on the electronic device pre-setting the self-start time for the first application, and the electronic device determines that the system time reaches the self-start time, triggering the start-up of the first application, etc.
[0061] In another possible implementation of starting the first application, when the electronic device is communicatively connected to other devices, such as any terminal, input device (such as one or more of a touch screen, a mouse, a joystick, a stylus / handwriting pen, etc.) or a server listed above that is interconnected with the electronic device, the other device can send a first application start instruction to the electronic device, and the electronic device responds to the instruction to control the start of the first application.
[0062] Of course, when the other device is interconnected with the electronic device, shares the input device of the other device, or the other device serves as an external expansion device of the electronic device, the user uses the other device to start the touch operation of the first application configured on the electronic device, and the other device sends the start touch operation or the start instruction converted from it to the electronic device. The electronic device responds to the start touch operation or the start instruction to control the start of the first application to start running, etc. This application does not limit the implementation method of how to start the first application of the electronic device by touching other devices, which can be determined according to the circumstances.
[0063] Step S102, when it is determined based on the application information that the first application belongs to the target application, the target memory area applied for by the first application is controlled to enter a locked state; the target memory area belongs to the physical memory of the electronic device; in this locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device.
[0064] Combined with the above description of application information, based on the application information of the current first application, it is possible to accurately and quickly determine whether the first application belongs to the target application. Combined with the above description of the target application, the target application can be a core application in the electronic device, which can be determined based on the operating environment of the electronic device, device type or user usage requirements. This application does not impose any restrictions on the application type / name of the target application.
[0065] For example, if the electronic device is an AIPC (Artificial Intelligence Personal Computer, also known as an AI computer) that supports the operation of artificial intelligence models, the AI assistants such as Lenovo's Xiaotian Intelligent Body or AI NOW, or large model applications such as generative AI software such as creator zone (AI creation) and learning zone (AI learning) that it supports can be determined as target applications. Optionally, the present application can also determine large-scale applications such as large-scale game applications or large-scale image processing applications (which use or generate a large amount of memory data during operation) as target applications. In addition, users can select core applications (here refers to the core applications for individual users, and the core applications selected by different users may be different, such as office software, instant messaging software, and video conferencing software that users are accustomed to / frequently use) from the applications supported by the electronic device as target applications, etc. according to their actual personal needs.
[0066] Therefore, the present application can be configured by the operating system (such as selecting a target application before the electronic device leaves the factory / before it is sold to the user, so that during or after the installation of the operating system, the target application is configured for the memory protection function of the memory control method proposed in the present application, etc.) or the user flexibly and independently configures the target application that needs memory protection in the electronic device. The present application does not elaborate on various configuration implementation methods. It should be understood that in the case that the user's use requirements for the electronic device change, the configured target application can be adjusted at any time, such as selecting a new core application and / or updating one or more configured target applications to non-target applications, etc., to ensure the running speed of the core application for the user and improve the flexibility of memory control.
[0067] Based on the above analysis, it can be known that when it is determined that the first application belongs to the target application according to the method described above, the electronic device needs to perform memory protection on the first application, that is, to protect the target memory area in the physical memory currently applied for by the first application to avoid memory write amplification problems and reduce the running speed of the first application. At this time, the target memory area applied for by the first application can be controlled to enter a locked state.
[0068] Among them, the memory write amplification problem is an undesirable phenomenon between physical memory and virtual memory, which causes the actual amount of physical data written to be multiple times the amount of data written. In the embodiment of the present application, when the memory resources of the electronic device are insufficient, the operating system swaps out the physical memory of the application process and puts it into the virtual memory, that is, the physical memory migrates the memory data of the application process to the virtual memory through paging (i.e., PageIO operation), resulting in a memory write amplification problem, causing the application to use the memory data placed in the virtual memory. The physical memory needs to obtain the corresponding memory data (the amount of data is often very large, such as the order of magnitude of gigabytes) through paging before the application process can use the memory data in the physical memory, increasing the response time of the application process using the memory data and reducing the speed of the application running.
[0069] In actual applications, the target memory area applied for by the first application belongs to the physical memory of the electronic device. The physical memory can be the storage space reported by the memory chip of the electronic device. This application does not limit the address and memory size of the physical memory, and can be flexibly configured according to actual conditions. The target memory area can be any or specified memory area in the physical memory allocated for the first application. This application does not limit the physical address and memory size of the target memory area of this application in the physical memory. In actual applications, after the first application needs to use the target memory area of this application, it can release the target memory area for other applications to apply for or the first application to apply for use again. Therefore, in the scenario where the first application needs to use the physical memory multiple times, the target memory area applied for each time can be the same or different memory area in the physical memory. This application does not limit this and can be determined according to the circumstances.
[0070] Combined with the above analysis, when the target memory area applied for by the first application is in a locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device. During this period, locking protection of the target memory area is realized. In this way, when the first application needs to use the memory data, it can directly perform read and write operations on the target memory area in the physical memory. The physical memory will no longer execute PageIO operations. During this period, the write amplification problem of the target memory area applied for by the first application is avoided, and the use of the memory data by the first application can be responded quickly. Even when the memory resources of the electronic device are insufficient, the running speed of the first application belonging to the target application can be guaranteed.
[0071] It can be seen that for the target memory area applied for by the first application mentioned above to enter a locked state, it can be achieved by configuring the access rights or protection state (such as entering a hidden state, etc.) of the target memory area applied for by the first application, so that the target memory area applied for by the first application is prohibited from being accessed by the virtual memory, or the access to the memory data of the target memory area associated with the virtual memory is prohibited, so as to avoid replacing the memory data of the target memory area with the virtual memory, resulting in a memory write amplification problem.
[0072] It should be noted that in the embodiment of the present application, the memory data of the target memory area may include but is not limited to: code data, processing functions, and various application data generated by the first application, etc., which may be determined during the installation, upgrade, and operation of the first application. The memory data may also change with the usage of the first application. The present application does not restrict the content and source of the memory data of the target memory area of the first application under different usage conditions of the electronic device. In addition, the virtual memory of the electronic device may be a space on the hard disk of the electronic device (such as a solid state disk (Solid State Disk or Solid State Drive, SSD), that is, the virtual memory set by the hard disk; it may also be the virtual memory provided by the cloud server to borrow the storage capacity of the cloud server and reduce the occupation of the local storage resources of the electronic device.
[0073] To summarize, in the scenario of starting the first application of an electronic device, if it is determined that the first application belongs to a target application based on the application information of the first application, the present application will promptly control the target memory area in the physical memory applied for by the first application to enter a locked state, so that the memory data in the target memory area (such as the data needed for the operation of the first application) will not be replaced into the virtual memory of the electronic device, thereby avoiding the write amplification problem in the target memory area. When the first application uses the memory data, it can quickly respond to the direct read and write operations on the memory data in the target memory area, thereby ensuring the running speed of the first application.
[0074] Reference Figure 2 , is a flow chart of a memory control method provided in the second embodiment of the present application, and the memory control method can still be applied to electronic devices, such as Figure 2 As shown, the memory control method proposed in this embodiment may include:
[0075] Step S201, in response to a first application of the electronic device being started and running, obtaining application information of the first application;
[0076] Step S202, when it is determined based on the application information that the first application belongs to the target application, controlling the target memory area applied for by the first application to enter a locked state;
[0077] Regarding the implementation process of step S201 and step S202, reference may be made to the description of the corresponding parts of the context implementation example, such as the description of the corresponding parts of step S101 and step S102, which will not be elaborated in this embodiment.
[0078] Step S203, in response to the first application program switching from the foreground running state to the target application state, controlling the target memory area to maintain in the locked state or switching from the locked state to the corresponding released state.
[0079] In actual applications, the application state of the first application can be determined according to the running status of the first application in the operating system of the electronic device, including but not limited to the foreground running state, the background running state, the suspended state and the exit state, etc. The management mechanisms corresponding to different application states may be different, and this application does not limit the control implementation method of these application states of the application. Based on this, the target application state of the embodiment of this application can be any state such as the background running state, the suspended state, the exit state, etc. that is different from the foreground running state.
[0080] Among them, the foreground running state of the first application may mean: the first application is being used directly by the user, can be displayed on the screen of the electronic device, and the user can interact with the first application. The background running state of the first application may mean: the first application is not displayed in the foreground, but at this time the first application is still running in the operating system of the electronic device, and it may be performing some background tasks, such as downloading files or synchronizing data. The suspended state of the first application may mean: when the system resources of the electronic device are tight or the first application needs to be switched to the background, the operating system may put the first application in a suspended state, at which time the operation of the first application is suspended, and its memory state is saved so that it can be quickly restored when used. The exit state of the first application may mean: the first application has completely stopped running and no longer occupies system resources. The first application can be closed by user operation or other device control or the system automatically ends the operation and enters the exit state. It should be understood that the closing method of the first application can correspond to its startup method, and the implementation process can refer to the corresponding startup method above, which is not described in detail in this embodiment.
[0081] Based on the above analysis, when the target memory area applied for by the first application enters a locked state, if the state of the first application is switched in the manner but not limited to the manner described above, so that it is switched from the current foreground running state to the background running state, suspended state, exited state or other target application states, the locking state of the target memory area applied for by the first application can be switched and controlled according to the requirements for the running speed of the first application in the target application state (or other usage requirements).
[0082] Therefore, if it is still necessary to protect the target memory area applied for by the first application in the target application state to avoid the write amplification problem, the target memory area can continue to be controlled to be maintained in a locked state; if it is no longer necessary to protect the target memory area applied for by the first application in the target application state, and its memory data is allowed to be replaced into the virtual memory or the applied target memory area is reclaimed, etc., the target memory area can be directly controlled to switch from the locked state to the corresponding released state, and after the first application switches from the foreground running state to a different application state (such as the background running state, the suspended state, or the exited state, etc.), the memory resources corresponding to the target memory area are released in different release states. For the implementation method of releasing the memory resources in different release states, please refer to the description of the corresponding part of the following embodiment.
[0083] In summary, in the embodiment of the present application, when any target application (i.e., the above-mentioned first application) of the electronic device is started and run, in order to ensure its running speed and avoid the situation where the memory resources of the electronic device are tight, the operating system replaces the memory data of the target memory area applied by the first application to the virtual memory of the electronic device, thereby reducing the running speed of the first application. Especially for large-scale applications, it is easy to cause obvious freezes, users waiting for responses for a long time, etc., which will greatly reduce the user experience. Therefore, the present application can timely control the target memory area to enter a locked state, prohibit / refuse the operating system to replace the memory data of the target memory area to the virtual memory of the electronic device, and ensure the high running speed of the first application.
[0084] Moreover, during the use of the electronic device, the first application is triggered to switch from the foreground running state to the target application state. In response to the state switch of the first application, the electronic device will flexibly control whether to enter a locked state or switch to a corresponding released state based on the actual processing requirements of the target memory area under the target application state, thereby meeting the actual memory control requirements of the first application under different running conditions.
[0085] In some embodiments, reference Figure 3 As shown in the flowchart, the implementation method of step S203 above may include but is not limited to the following implementation methods:
[0086] In a first possible implementation, when the target memory area applied for by the first application of the electronic device is in a locked state, in response to the first application switching from the foreground running state to the background running state, that is, when the target application state in step S203 is the background running state, the electronic device can control at least part of the target memory area to remain in a locked state. The present application does not limit the method for determining which part of the target memory area is maintained in a locked state. Combined with the above description of the background running state of the first application, since the first application may execute some background tasks in the background running state, the present application can maintain the part of the target memory area corresponding to the process executing this part of the background tasks in a locked state. The present application does not limit the content of the background task, which can be determined according to the circumstances.
[0087] Optionally, during the operation of the first application, multiple application processes are usually started / created to run to implement different tasks supported by the first application, and as the tasks executed by the first application change, the running application processes will also change accordingly. Based on this, the present application can determine whether the corresponding application process belongs to a pre-configured core application process based on task information such as the task type or task content or implementation method executed by each application process of the first application, so as to control the memory area required by each application process belonging to the core application process of the first application to remain in a locked state, continue to protect the memory area corresponding to the core application process, and ensure the running speed of the core application process running in the background.
[0088] Of course, the present application can also directly determine whether the application process belongs to the core application process based on the attribute information of each application process running by the first application in the background running state (such as startup frequency, startup duration, whether it contains a visible application window, etc.). If so, control the part of the target memory area required by it to remain in a locked state; if it is not a core application process, control the running non-core application processes and each application process that exits or suspends when the first application enters the background running state, and switch the part of the target memory area required by each to the corresponding released state, such as replacing the memory data of the part of the memory area belonging to the target memory area required by such application process into the virtual memory of the electronic device, which alleviates the memory resource tension of the electronic device to a certain extent, and can also ensure the running speed of the background task of the first application.
[0089] It should be noted that when the first application enters the background running state, the target memory area it applies for can still be controlled to remain in a locked state. This can be pre-configured based on the actual usage of the electronic device or the background running requirements of the first application, etc., to determine whether all the target memory areas applied for are in a locked state, or only part of the target memory area and which part of the memory area is in a locked state in the background running state, such as by entering or selecting the corresponding memory lock state control rule in the corresponding configuration interface. This application does not elaborate on the configuration implementation process.
[0090] Among them, when the first application is restored from the background running state to the foreground running state, in response to the first application being restored from the background running state to the foreground running state, the target memory area applied for by the first application can be controlled to switch from a locked state to a corresponding released state and then restored to a locked state. At this time, it is equivalent to the above-mentioned control of the target memory area to enter a locked state. The control implementation method can refer to the description of the corresponding part of the above embodiment, and this embodiment will not be described in detail here.
[0091] In the second possible implementation, the target application state in step S203 is in the suspended state. Combined with the above description of the suspended state of the first application, it is explained that the operation of the first application state is suspended at this time, and the first application is not needed temporarily. In order to alleviate the tight memory resource situation of the electronic device, in response to the first application switching from the foreground running state to the suspended state, the target memory area is controlled to switch from the locked state to the first released state. In the first released state, the memory data in the target memory area can be replaced to the virtual memory of the electronic device, so that when the memory resources of the electronic device are tight, the operating system can replace the memory data in the target memory area used by the first application to the virtual memory of the electronic device, so as to release / delete / reclaim / revoke the target memory area for other applications to apply for or the first application to apply for use again.
[0092] It should be understood that in the above-mentioned first release state, the memory data in the target memory area applied for by the first application program will not necessarily be replaced into the virtual memory, and the operating system of the electronic device can determine it according to the actual situation. In addition, when the target application state in step S203 is in the background running state, the above-mentioned second possible implementation method can also be adopted to switch the lock state of the target memory area applied for by the first application program, and the implementation process is similar to this application and will not be described in detail.
[0093] In a third possible implementation, if the target application state in the above step S203 is a closed state, such as the first application is closed or exited (its implementation method is similar to the startup method described above, such as user operation to close / exit, automatic triggering of the electronic device or other devices triggering the first application to close or exit, etc., the implementation process is not described in detail in this embodiment), it means that the first application no longer needs to use the applied target memory area and can directly release the memory resources. That is, in response to the first application switching from the running state to the closed state, the target memory area is controlled to switch from the locked state to the second released state. Combined with the relevant description of the release state in the above embodiment, the switching control of the second release state can be achieved by reconfiguring the access rights or protection state of the target memory area (such as switching from a hidden state to a visible state, etc.), and this application does not limit the switching control implementation method.
[0094] Among them, the second release state is different from the first release state. In the second release state, the memory resources corresponding to the target memory area applied for by the first application this time are released, allowing other applications to apply or the first application to apply again to use the target memory area. It should be noted that the method for determining that the first application does not need to lock the target memory area applied for includes but is not limited to the above-mentioned closed state, and may also be in a suspended state or a background running state, where the first application does not need to run quickly, and in response to a triggering operation (such as user operation or automatic triggering of an electronic device or other device triggering) to release the target memory area, it can also control it to switch from a locked state to a second release state.
[0095] Reference Figure 4 , is a flow diagram of a memory control method provided in the third embodiment of the present application. This embodiment can describe an optional detailed implementation of the above memory control method, such as a detailed description of a startup method of the first application, but is not limited to this startup method. Figure 4 As shown, the memory control method proposed in this embodiment may include:
[0096] Step S401, in response to obtaining a calling instruction from a second application, obtaining application information of a called first application based on interaction data or context data in the second application;
[0097] Among them, the second application can be any application in the electronic device that is distinguished from the first application and is allowed to access the first application, or it can be any application in other devices that is allowed to access the first application. This application does not limit the category of the second application.
[0098] During the operation of the second application, a call request to the first application can be automatically generated according to the call requirements of the second application for the first application by the second application running task. The electronic device obtains the call request from the second application and responds to the call request to implement the call to the first application of the electronic device, such as starting or waking up the first application to enter the foreground running state. This application does not limit the implementation method of how the first application is called by other applications (recorded as the second application).
[0099] In the embodiment of the present application, after the electronic device obtains the calling instruction from the second application, it can obtain the interaction data or context data of the second application, perform semantic analysis on it, and determine which application the second application needs to call, so as to accurately start the application that the second application needs to call. For example, based on the interaction data or context data of the second application, the application identification information or functional description information of the application requested to be called is obtained, so as to start the first application with the application identification information or conforming to the functional description information, and obtain the application information of the first application, or directly obtain the application information of the first application with the application identification information or conforming to the functional description information.
[0100] For the example of the calling instruction of the second application mentioned above, combined with the above description of the target application, if the second application is Lenovo Xiaotian (an AI software), if the first application (such as a target application) needs to be started, the interactive content can be entered in its interactive interface to express the calling demand for the first application. In this way, Lenovo Xiaotian analyzes the interactive content and determines that it is necessary to call any large model application such as Lenovo's image software Creator Zone or Lenovo's key application Smart Engine or Vantage or large-scale game applications. The second application can generate a calling instruction containing the application identifier of the corresponding application. In response to obtaining the calling instruction from the second application, the calling instruction is parsed, and the first application called by the second application can be determined based on the application identifier, and the application information of the first application can be obtained. Optionally, if the calling instruction does not indicate which application the second application calls, the electronic device can also obtain the interactive content or context content input in the interactive interface of Lenovo Xiaotian according to the method described above, analyze and determine the called first application, and obtain the application information of the first application.
[0101] Step S402, when it is determined based on the application information that the first application belongs to the target application, the target memory area applied for by the first application is controlled to enter a locked state; the target memory area belongs to the physical memory of the electronic device; in this locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device.
[0102] Regarding the implementation process of step S402, reference may be made to the description of the corresponding part of the above embodiment, such as the description of the corresponding part of step S102, and this embodiment will not be repeated here. It can be understood that in this embodiment, when the first application is switched from the foreground running state to any other application state listed above, the following steps may be followed but not limited to: Figure 3 The method shown realizes the lock state switching control of the target memory area, and the implementation process is not described in detail in this embodiment.
[0103] In actual application, in combination with the above description of the method for starting the first application, the method for obtaining the application information of the first application can be implemented according to at least one of the following methods in addition to the implementation method described in step S401:
[0104] In a possible implementation, in the scenario described above where the first application is triggered by a user operation, an electronic device automatically triggers, or another device triggers the start of the first application, the first application can be triggered to start running and its application information can be obtained by control methods such as voice, text, or patterns. Therefore, the control instructions for starting the first application can include but are not limited to voice instructions, string instructions, or gesture instructions, etc. The content of the control instructions can be pre-configured according to actual conditions, and this application does not limit the type of the control instructions and their configuration implementation methods.
[0105] Based on this, the electronic device can respond to obtaining a control instruction to start running the first application, and obtain application information of the first application based on the control instruction. Optionally, the application identification information or information describing the application function carried in the control instruction can be parsed, and the application information of the first application can be obtained based on the information. For example, when it is necessary to start running a raw image application (i.e., the first application) to perform a raw image task, the corresponding control instruction should be descriptive information that can point to the raw image application, such as the application name of the raw image application, or a functional description that can locate the raw image application, so that the electronic device can accurately locate the first application based on the control instruction and reliably obtain the required application information.
[0106] In another possible implementation, the start trigger of the first application can also be implemented by using an input device (such as one or more of a mouse key, a joystick, a stylus, a finger or a function key) to perform a trigger operation on its application icon, and the trigger operation may include but is not limited to a double-click operation on the application icon, dragging the application icon to a specific position, pressing or circling the application icon, etc. In this way, when any trigger operation is performed on the application icon of the first application presented on the display screen, the electronic device obtains the application information of the first application based on the application icon in response to obtaining the trigger operation acting on the application icon of the first application, that is, by identifying the triggered application icon, the application information such as the application identifier or application type of the first application is determined, and the implementation process is not described in detail in this application.
[0107] Reference Figure 5 , is a flow chart of a memory control method provided in Embodiment 4 of the present application, such as Figure 5 As shown, the memory control method may include:
[0108] Step S501, in response to a first application of the electronic device being started and running, obtaining application information of the first application;
[0109] Step S502, based on the type and / or source of the application information, determining the application category and / or priority sequence to which the first application belongs in different ways;
[0110] In combination with the method for obtaining application information of the first application described in each embodiment of the above text application, after obtaining the application information of the first application, the type of the application information can be determined, such as one or more of the application name, application type, application window position, and function description information of the first application; or the source of the application information can be determined, such as obtained through electronic device monitoring, user input, or analysis of interaction data or context data by the electronic device, and the corresponding source can be determined in combination with the various methods of obtaining application information described above; the type and source of the application can also be determined, and then, based on at least one of the type and source of the application information of the first application, at least one of the application type and priority sequence for identifying whether the first application belongs to the target application can be determined through one or more pre-configured methods.
[0111] Among them, the application type can indicate whether the first application is a core / critical application, and the priority sequence can indicate whether the first application is a high-priority application. The higher the priority of an application, the more it needs to include the target memory area it applies for. Core / critical applications and high-priority applications can be identified as target applications.
[0112] In an embodiment of the present application, the application category and priority sequence belonging to the target application can be recorded by means of a pre-configured whitelist or a preset application category list, a preset application priority sequence table, etc. Optionally, in combination with the above description of the content of the application information, the present application can also determine the application type and / or the priority sequence of the first application by identifying the display position, display duration, and foreground and background switching frequency of the application window of the current first application, thereby determining whether it belongs to the target application. In addition, the present application can also analyze the type and / or source of the application information through a large model, identify or calculate the application to which the first application belongs and / or the priority sequence, thereby determining whether it belongs to the target application, etc. The present application does not limit the implementation method of step S502.
[0113] In some embodiments, the present application may also determine the application category and / or priority sequence to which the first application belongs based on the application features and / or running status of the first application. The application features may refer to whether the running application window of the first application is a visible window, and the window size of the visible window, etc. The running status may refer to whether the first application is in the foreground running state or the background running state, etc. The first application in the foreground running state may be determined as the target application, or when the application process in the background running state contains a visible window or its size is greater than a threshold, the first application may be determined as the target application, etc., but it is not limited to the application category / priority sequence determination method described in the present application.
[0114] Step S503 : when it is determined that the first application belongs to the target application based on the application category and / or the priority sequence, controlling the target memory area applied for by the first application to enter a locked state.
[0115] It should be understood that determining whether the first application belongs to the target application based on the application category to which it belongs is consistent with the judgment result of determining whether the first application belongs to the target application based on the priority sequence in which the first application is located. In order to improve the accuracy of the judgment of whether the first application belongs to the target application, it can be determined based on the application category to which the first application belongs and the priority sequence in which it is located, but it is not limited to the judgment methods described in this embodiment. Regarding the lock state switching control process of the target memory area applied for by the first application, reference can be made to the description of the corresponding part of the above embodiment, and this embodiment will not be repeated here.
[0116] In summary, after the embodiment of the present application obtains the application information of the first application that is started and running, combined with the method of obtaining the application information, it can accurately determine the application type to which the first application belongs based on the type and / or source of the application information through one or more corresponding methods, and can also determine the priority sequence of the first application. It can also determine the application type and priority sequence to which the first application belongs, flexibly and reliably determine that the first application belongs to the target application, and promptly control the target memory area applied for by the first application to enter a locked state, avoid write amplification problems in the target memory area, and ensure the operating efficiency of the first application.
[0117] Reference Figure 6 , is a flowchart of a memory control method provided in Embodiment 5 of the present application, such as Figure 6 As shown, the memory control method may include:
[0118] Step S601, in response to a first application of the electronic device being started and running, obtaining application information of the first application;
[0119] Step S602, when it is determined based on the application information that the first application belongs to the target application, the memory request information of the first application process is monitored by using the memory processing function; the first application process is the core process of the first application;
[0120] Regarding how to obtain the application information of the first application and determine whether the first application belongs to the target application based on the implementation method, reference can be made to the description of the corresponding part of the above embodiment, and this embodiment will not be repeated here. Among them, in the actual application of this application, a driver that supports the implementation method can be configured / loaded on the operating system of the electronic device, so that after starting the driver, the startup message / instruction of the application can be monitored, so that after determining that the first application is started, it is determined whether it belongs to the target application according to the method described above.
[0121] In the embodiment of the present application, the memory processing function may include functions such as memory allocation, destruction, and re-application of the coverage system. For example, for the Windows operating system, the memory processing function includes a series of functions such as HeapAlloc, VirtualAlloc, HeapFree, and VirtualFree. The present application does not limit the corresponding functions required to implement tasks such as memory allocation, destruction, and re-application. In order to implement the memory control method of the present application, the memory processing function can be injected into the process of the target application in the form of DLL (Dynamic Link Library, dynamic link library file, also known as application extension), so that the driver monitors the task status of the process of the first application belonging to the target application by running the memory processing function. The implementation process is not described in detail in this application.
[0122] Based on this, the memory request information of the first application process monitored by the present application using one or more memory processing functions may include corresponding memory application requests, memory destruction requests, memory reapplication requests, memory deletion requests or memory release requests, etc. The configuration and identification method of the core process of the first application program may refer to the description of the corresponding part of the above embodiment.
[0123] Step S603: when a memory application request from the first application process is monitored, the target memory area requested by the memory application request is controlled to enter a locked state.
[0124] The memory application request may be a request for memory, which requires loading the corresponding application data into the applied target memory area to run the first application. For different application processes of the first application, the corresponding applied memory areas may be different. The memory application request of the first application process may be a request for memory application for the core process of the first application. The memory size and address and other memory information allocated to the core process may be determined based on the task information such as the type of task executed by the core process and the memory size it occupies. This application does not elaborate on the memory application implementation process.
[0125] It can be seen that when the first application belonging to the target application is run in the startup electronic device, the application monitors the memory interval in the physical memory applied by the core process of the first application, and can control the target memory area applied by the core process to enter the locked state, thereby realizing the protection of the target memory area allocated to the core process and ensuring the operation efficiency of the core process. For other processes of the first application, after they apply for the corresponding memory area, they can choose not to perform the locking protection process, or they can choose to enter the locked state according to actual needs. The application does not limit the memory control method of different application processes of the first application.
[0126] In some other embodiments proposed in the present application, memory information corresponding to the memory application request of the first application process of the first application, such as the applied memory address, memory length / size, and application identification information of the first application that makes the memory application request (used to identify the first application) or process identification information of its first application process (used to identify the first application process of the first application), etc., can be added to a memory management file storage. The memory management file can be used to record memory allocation information of the target application, such as an index table that records the memory allocation status of the target application. The present application does not impose any restrictions on the file type of the memory management file and the way of recording memory allocation information, which can be determined according to the circumstances.
[0127] Optionally, the present application may also configure an index table (i.e., memory management file) for each target application to record the memory information of the target memory area applied for by the target application or its first application process. In this case, there is no need to record the application identification information / process identification information.
[0128] It should be understood that, in the memory control method described in the above embodiments, after controlling the target memory area to enter a locked state, the status flag configured for the target memory area can be set to a target status value, and by reading whether the status value of the status flag is the target status value, it is determined whether the target memory area is currently in a locked state, but it is not limited to this recording method.
[0129] In some other embodiments proposed in the present application, combined with the above description of memory request information, when the first application process does not need to use the target memory area applied for, a corresponding memory destruction request (which can be called a memory deletion, release or recovery request) can be generated. When the corresponding memory processing function monitors the memory destruction request from the first application process, it can be deleted (in this case, by reading the content of the memory management file, the memory information corresponding to the first application process cannot be read, indicating that the first application process is no longer using the target memory area applied for this time, and no longer needs to be locked and protected because it is allocated to the first application process) or reconfigured (such as configuring the memory information of the target memory area applied for by the first application process to be empty, or by setting the state identifier to a non-target state value, to indicate that the target memory area is in a released state, etc.) The corresponding memory information in the memory management file is updated to update the memory allocation information recorded in the memory management file, so that the updated memory allocation information can indicate the destruction of the target memory area applied for by the first application process, that is, the current first application process does not need to use the target memory area and its use right is handed over to the operating system, thereby controlling the target memory area to switch from a locked state to a released state, and the control implementation process is not described in detail in this application.
[0130] In the memory control method described in any embodiment of the above application, after the first application belonging to the target application is started and the target memory area applied for by it is controlled to enter a locked state, if, according to the method described above, it is determined that a new application (recorded as a third application) of the electronic device that is started and run belongs to the target application, the priority sequences of the first application and the third application can be compared, and based on the result of the priority sequence comparison, the target memory area applied for by the third application can be controlled to enter a locked state, and / or the target memory area applied for by the first application can be controlled to switch from a locked state to a corresponding released state.
[0131] In a possible implementation, when the target memory areas applied for by the first application and the third application (i.e., two different target applications) started and run by the electronic device are both in a locked state, the lock state switching control of the respective target memory areas can also be implemented in combination with the memory resource situation of the electronic device. Therefore, in response to determining that the electronic device is running the third application belonging to the target application, the memory resource status information of the electronic device, such as the size and proportion of the current available storage space in the physical memory, etc., can be obtained. When it is determined based on the memory resource status information that the memory resources of the electronic device are insufficient (i.e., the memory resources of the electronic device are tight, which will affect the operation performance of the electronic device), the target memory areas applied for by the first application and / or the second application can be controlled to switch from the locked state to the corresponding released state based on the priority sequence of the first application and the third application. This can select at least one corresponding target memory area in the first application and the second application to be released according to the tightness of the memory resources, so as to replace the memory data in the target memory area switched to the released state with the virtual memory, so as to alleviate the tightness of the memory resources of the electronic device.
[0132] It should be understood that, in the case of tight memory resources, combined with the above description of the priority sequence, the target application with a lower priority sequence is preferentially selected to release the target memory area it has applied for. After that, the memory resource status information of the electronic device can be continuously obtained. If the memory resources are still determined to be tight based on the new memory resource status information, the target memory area applied for by the target application with a lower priority sequence can be continuously released to avoid the memory resources of the electronic device being too tight and affecting the operating performance of the electronic device.
[0133] A memory control method provided by an embodiment of the present application is introduced above, and a device for executing the above memory control method will be introduced below.
[0134] Reference Figure 7 , is a schematic diagram of the structure of a memory control device provided in an embodiment of the present application. Figure 7As shown, the memory control device may include:
[0135] An application information obtaining module 710 is configured to obtain application information of a first application of the electronic device in response to the first application being started and run;
[0136] A memory control module 720, configured to control a target memory area applied for by the first application to enter a locked state when it is determined based on the application information that the first application belongs to a target application;
[0137] The target memory area belongs to the physical memory of the electronic device; in the locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device.
[0138] In some embodiments, the memory control device may further include:
[0139] a first switching control module, configured to control the target memory area to remain in the locked state or switch from the locked state to a corresponding released state in response to the first application being switched from a foreground running state to a target application state;
[0140] Among them, after the first application is switched from the foreground running state to a different application state, the memory resources corresponding to the target memory area are released in different release states.
[0141] In a possible implementation, the switching control module may include but is not limited to at least one of the following control units:
[0142] a first control unit, configured to control at least a portion of the target memory area to remain in the locked state in response to the first application being switched from a foreground running state to a background running state;
[0143] a second control unit, configured to control the target memory area to switch from the locked state to a first released state in response to the first application being switched from a foreground running state to a suspended state, wherein the memory data in the target memory area can be replaced to a virtual memory of the electronic device in the first released state;
[0144] The third control unit is used to control the target memory area to switch from the locked state to a second released state in response to the first application being switched from a running state to a closed state. In the second released state, the memory resources corresponding to the target memory area are released.
[0145] In some embodiments, the application information obtaining module 710 may include at least one of the following obtaining units:
[0146] A first obtaining unit, configured to obtain application information of the first application based on the control instruction in response to obtaining a control instruction to start running the first application;
[0147] a second obtaining unit, configured to obtain application information of the first application based on the application icon in response to a triggering operation of obtaining an application icon acting on the first application;
[0148] The third obtaining unit is used to obtain application information of the called first application based on the interaction data or context data in the second application in response to obtaining the calling instruction from the second application.
[0149] Based on the above analysis, the memory control device proposed in the embodiment of the present application may further include:
[0150] The application category determination module is used to determine the application category to which the first application program belongs in different ways based on the type and / or source of the application information.
[0151] and / or,
[0152] The priority sequence determination module is used to determine the priority sequence of the first application program in different ways based on the type and / or source of the application information.
[0153] The memory control device described in the above embodiment may further include:
[0154] a memory request information monitoring module, configured to monitor memory request information of a first application process by using a memory processing function when it is determined that the first application belongs to a target application, the first application process being a core process of the first application;
[0155] The state control module is used to control the target memory area requested by the memory application request to enter a locked state when monitoring the memory application request from the first application process.
[0156] Based on this, the memory control device may further include:
[0157] A memory information adding module, used to add the memory information corresponding to the memory application request to a memory management file, wherein the memory management file is used to record the memory allocation information of the target application;
[0158] as well as,
[0159] A memory information processing module is used to delete or reconfigure the corresponding memory information in the memory management file when monitoring a memory destruction request from the first application process, so as to control the target memory area to switch from the locked state to the released state.
[0160] The memory control device described above may further include:
[0161] a memory resource status information obtaining module, configured to obtain the memory resource status information of the electronic device in response to determining that the electronic device is running a third application belonging to the target application;
[0162] A second switching control module is used to control the target memory area applied for by the first application and / or the second application to switch from the locked state to the corresponding released state based on the priority sequence of the first application and the third application when determining that the memory resources of the electronic device are insufficient based on the memory resource status information.
[0163] Reference Figure 8 , is a schematic diagram of an optional hardware structure of an electronic device applicable to the memory control method proposed in this application, the electronic device may include a memory chip 810 and a memory controller 820, wherein,
[0164] The memory chip 810 is configured with a physical memory including multiple memory areas for storing memory data of the application program applied to the corresponding memory area. It can be seen that the physical memory can be the storage space reported by the memory chip 810. The present application does not limit the type of the memory chip 810, such as a flash memory or a memory bar on a motherboard.
[0165] In some embodiments, the application on the electronic device may include an artificial intelligence application implemented based on an artificial intelligence model (such as the large model application mentioned above), that is, a target application, and the hardware on the electronic device includes dedicated hardware required by the artificial intelligence model to support the operation of the large model application.
[0166] The memory controller 820 can execute multiple computer-readable instructions to implement the memory control method proposed in each embodiment of the present application. The implementation process can refer to the description of the corresponding part of the above embodiment.
[0167] In the embodiment of the present application, the memory controller 820 can be one or more processors, such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), a digital signal processor (DSP), an application specific integrated circuit (ASIC) or a field-programmable gate array (FPGA).
[0168] Optional, such as Fig. 9 As shown, the memory controller 820 may also include at least one memory 821 and at least one processor 822. The memory 821 may be used to store multiple computer-readable instructions for implementing the memory control method proposed in the embodiment of the present application, so as to be loaded into the processor 822 and execute the corresponding memory control method. The memory may include but is not limited to storage media such as read-only memory (ROM) and random access memory (RAM).
[0169] In some embodiments, when the target memory area applied for by the target application is switched from a locked state to a released state, the virtual memory to which the memory data in the target memory area is replaced can be a storage space configured in the hard disk of the electronic device, or it can be a virtual memory of a cloud server. In the latter case, the electronic device can include a communication element for realizing communication between the electronic device and the cloud server, such as a communication element corresponding to wireless communication methods such as wifi, Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), email, and Short Messaging Service (SMS).
[0170] In order to realize the communication between the components of the electronic device, it can also include communication ports such as general-purpose input / output (GPIO) interface, USB interface, universal asynchronous receiver / transmitter (UART) interface, and buses such as peripheral component interconnect (PCI) bus or extended industry standard architecture (EISA) bus. Therefore, Figure 8 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiment of the present application. In practical applications, the electronic device may include Figure 8 This application does not provide detailed descriptions of more or fewer components shown, or combinations of certain components.
[0171] An embodiment of the present application also provides a computer program product, including computer program instructions. When the computer program instructions are executed on an electronic device, the electronic device implements any memory control method provided in the embodiment of the present application.
[0172] Wherein, when loading and executing computer program instructions on an electronic device, the process or function described in the embodiment of the present application is generated in whole or in part. The electronic device may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer program instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer program instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. Available media may be magnetic media, (e.g., floppy disk, hard disk, tape), optical media (e.g., DVD), or semiconductor media (e.g., solid-state drive (SSD)), etc.
[0173] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any memory control method provided in the embodiment of the present application.
[0174] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0175] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by dedicated hardware including dedicated integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. It can be seen that in the above embodiments, all or part of the implementation can be achieved by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product.
[0176] In addition, the various embodiments in this specification are described in a progressive or parallel manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the devices, systems, and electronic devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0177] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A memory control method, the method comprising: In response to a first application of the electronic device being started and running, obtaining application information of the first application; In a case where it is determined based on the application information that the first application belongs to a target application, controlling the target memory area applied for by the first application to enter a locked state; Wherein, the target memory area belongs to the physical memory of the electronic device; In the locked state, the memory data in the target memory area will not be replaced into the virtual memory of the electronic device.
2. The method according to claim 1, further comprising: In response to the first application being switched from a foreground running state to a target application state, controlling the target memory area to remain in the locked state or to switch from the locked state to a corresponding released state; Among them, after the first application is switched from the foreground running state to a different application state, the release state of the memory resources corresponding to the target memory area is different.
3. The method according to claim 2, wherein in response to the first application switching from the foreground running state to the target application state, controlling the target memory area to remain in the locked state or switching from the locked state to a corresponding released state comprises at least one of the following: In response to the first application being switched from a foreground running state to a background running state, controlling at least a portion of the target memory area to remain in the locked state; In response to the first application being switched from a foreground running state to a suspended state, controlling the target memory area to be switched from the locked state to a first released state, in which memory data in the target memory area can be replaced to a virtual memory of the electronic device; In response to the first application being switched from a running state to a closed state, the target memory area is controlled to be switched from the locked state to a second released state, and in the second released state, memory resources corresponding to the target memory area are released.
4. The method according to any one of claims 1 to 3, wherein: In response to a first application of the electronic device being started and running, obtaining application information of the first application includes at least one of the following: In response to obtaining a control instruction for starting to run a first application, obtaining application information of the first application based on the control instruction; In response to a triggering operation of obtaining an application icon acting on the first application, obtaining application information of the first application based on the application icon; In response to obtaining a calling instruction from a second application, application information of the called first application is obtained based on interaction data or context data in the second application.
5. The method according to any one of claims 1 to 3, further comprising: Based on the type and / or source of the application information, the application category to which the first application belongs and / or the priority sequence to which the first application belongs are determined in different ways.
6. The method according to claim 1, wherein: In the case where it is determined that the first application is a target application, the method further includes: Using a memory processing function to monitor memory request information of a first application process, where the first application process is a core process of the first application program; In the case of monitoring a memory application request from the first application process, controlling a target memory area requested by the memory application request to enter a locked state.
7. The method according to claim 6, further comprising: Adding memory information corresponding to the memory application request to a memory management file, wherein the memory management file is used to record memory allocation information of a target application; as well as, When a memory destruction request from the first application process is monitored, the corresponding memory information in the memory management file is deleted or reconfigured to control the target memory area to switch from the locked state to the released state.
8. The method according to any one of claims 1 to 3, further comprising: In response to determining that the electronic device runs a third application belonging to the target application, obtaining memory resource status information of the electronic device; When it is determined that the memory resources of the electronic device are insufficient based on the memory resource status information, based on the priority sequences of the first application and the third application, the target memory area applied for by the first application and / or the second application is controlled to switch from the locked state to the corresponding released state.
9. A memory control device, the device comprising: an application information obtaining module, configured to obtain application information of a first application of the electronic device in response to the first application being started and run; a memory control module, configured to control a target memory area applied for by the first application to enter a locked state when it is determined based on the application information that the first application belongs to a target application; Wherein, the target memory area belongs to the physical memory of the electronic device; In the locked state, the memory data in the target memory area will not be replaced into the virtual memory of the electronic device.
10. An electronic device, comprising: Memory chips and memory controllers, including: The memory chip is configured with a physical memory including a plurality of memory areas, and is used to store memory data of application programs applied to corresponding memory areas; The memory controller is used to execute multiple computer-readable instructions to implement the following steps: In response to a first application of the electronic device being started and running, obtaining application information of the first application; as well as, In a case where it is determined based on the application information that the first application belongs to a target application, controlling the target memory area applied for by the first application to enter a locked state; The target memory area belongs to the physical memory; in the locked state, the memory data of the target memory area will not be replaced into the virtual memory of the electronic device.
Citation Information
Cited By
Memory management method and memory management device of embedded system
CN119645641A
