Virtual memory adjustment method, electronic equipment and storage medium

By dynamically increasing the space of virtual memory, the resource waste and insufficient caused by fixed virtual memory size in the existing technology is solved, and more efficient virtual memory usage and system stability are achieved.

CN119847720APending Publication Date: 2025-04-18HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311353120.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-18
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the prior art, the size of virtual memory is usually pre-set. If the setting is too large, it will lead to waste of hard disk resources and memory resources. If the setting is too small, it will lead to insufficient memory resources, which may lead to system crash.

Method used

By dynamically increasing the space of virtual memory, in response to detecting that data in physical memory is migrated to virtual memory, if the virtual memory space is insufficient, the space of virtual memory is increased. The specific method includes increasing the virtual memory space based on the occupied information of the virtual memory and the applied virtual memory space size, and controlling the data transmitted each time through the file unit size.

Benefits of technology

It avoids the problem of insufficient virtual memory caused by fixed virtual memory size, avoids system crashes, improves the efficiency of virtual memory usage, and saves hard disk resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847720A_ABST
    Figure CN119847720A_ABST
Patent Text Reader

Abstract

The invention provides a virtual memory adjustment method, electronic equipment and a storage medium, and the method comprises the following steps: responding to detection that data in a physical memory is migrated to a virtual memory, and if the space of the virtual memory is insufficient, increasing the space of the virtual memory. According to the method provided by the invention, the use efficiency of the virtual memory is improved, and the situation that the virtual memory is insufficient is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a virtual memory adjustment method, an electronic device and a storage medium. Background Art

[0002] Virtual memory can also be called virtual storage. When a program is running, it needs to be executed through physical memory, that is, when a program is running, it needs to occupy a certain amount of physical memory space. If too many programs are executed, it will cause too much physical memory space to be occupied, which will cause the physical memory resources to be exhausted, resulting in system crashes. To solve this problem, a space can be opened up in the hard disk as an extension of the physical memory, so that when the physical memory resources are insufficient, the memory resources can be expanded by using the expanded space in the hard disk. This space expanded in the hard disk can be called virtual memory.

[0003] It is understandable that the size of the above virtual memory is usually pre-set. If the virtual memory is set too large, it will lead to a waste of hard disk resources and memory resources. If the virtual memory is set too small, it will lead to insufficient memory resources. Summary of the invention

[0004] The present application provides a virtual memory adjustment method, an electronic device and a storage medium, which are helpful to improve the use efficiency of virtual memory and avoid the situation of insufficient virtual memory.

[0005] In a first aspect, the present application provides a virtual memory adjustment method, comprising: in response to detecting that data in a physical memory is migrated to a virtual memory, if the space of the virtual memory is insufficient, increasing the space of the virtual memory.

[0006] The present application can avoid virtual memory shortage caused by fixed virtual memory size by dynamically increasing the space of virtual memory, thereby avoiding system crash caused by insufficient virtual memory.

[0007] In one possible implementation, increasing the space of the virtual memory includes: increasing the space of the virtual memory based on the occupancy information of the virtual memory and the size of the space of the applied virtual memory, wherein the size of the space of the applied virtual memory is determined by the migration data.

[0008] In one possible implementation manner, the method further includes: determining a file unit size of the migration data, where the file unit is used to represent data that can be transmitted each time for the migration data.

[0009] The present application can control the data transmitted each time through the file unit size, thereby being able to adjust according to the system resources to avoid increasing the consumption of system resources when the system resources are tight.

[0010] In one possible implementation, increasing the space of the virtual memory includes: increasing the space of the virtual memory based on a first adjustment ratio or a first adjustment value; wherein the first adjustment ratio is used to characterize the ratio of the increased virtual memory space to the original virtual memory space, and the first adjustment value is used to characterize the size of the increased virtual memory space.

[0011] In one possible implementation, after increasing the space of the virtual memory, the method further includes: monitoring the occupancy of the physical memory and / or the occupancy of the virtual memory; in response to monitoring that the physical memory reaches a first preset condition and / or the occupancy of the virtual memory reaches a second preset condition, reducing the space of the virtual memory.

[0012] The present application detects the occupancy of the physical memory and / or the occupancy of the virtual memory, and reduces the space of the virtual memory when preset conditions are met to save hard disk resources.

[0013] In one possible implementation, the space of the virtual memory after reduction is greater than or equal to the space of the virtual memory before increase.

[0014] The present application helps to avoid a serious shortage of virtual memory due to a small virtual memory setting by setting the reduced virtual memory space to be not less than the initial value of the virtual memory.

[0015] In one possible implementation, the detecting that data in the physical memory is migrated to the virtual memory includes: in response to detecting that the physical memory is insufficient or detecting that one or more application programs will run in the background, migrating the data in the physical memory to the virtual memory.

[0016] In a second aspect, the present application provides a virtual memory adjustment device, comprising one or more functional modules, wherein the one or more functional modules are used to implement the virtual memory adjustment method as described in the first aspect.

[0017] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, wherein the memory is used to store a program; and the processor is used to run the program to implement the virtual memory adjustment method as described in the first aspect.

[0018] In a fourth aspect, the present application provides a readable storage medium, which stores a program. When the program is executed on an electronic device, the electronic device implements the virtual memory adjustment method as described in the first aspect.

[0019] In a fifth aspect, the present application provides a program, which, when executed on a processor of an electronic device, enables the electronic device to execute the virtual memory adjustment method as described in the first aspect.

[0020] In one possible design, the program in the fifth aspect may be stored in whole or in part on a storage medium packaged together with the processor, or may be stored in whole or in part on a memory not packaged together with the processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0022] Figure 2 A schematic diagram of the system architecture provided for an embodiment of the present application;

[0023] Figure 3 A flowchart of an embodiment of a virtual memory adjustment method provided by the present application;

[0024] Figure 4 A flowchart of another embodiment of the virtual memory adjustment method provided by the present application;

[0025] Figure 5 A flowchart of another embodiment of the virtual memory adjustment method provided by the present application;

[0026] Figure 6 A schematic diagram of the structure of a virtual memory adjustment device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] In the embodiments of the present application, unless otherwise specified, the character " / " indicates that the objects before and after the association are in an or relationship. For example, A / B can represent A or B. "And / or" describes the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone.

[0028] It should be pointed out that the words "first", "second", etc. involved in the embodiments of the present application are only used to distinguish the description purpose, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated, nor can they be understood as indicating or implying order.

[0029] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. In addition, "at least one of the following" or similar expressions refers to any combination of these items, which may include any combination of single items or plural items. For example, at least one of A, B, or C may represent: A, B, C, A and B, A and C, B and C, or A, B and C. Among them, each of A, B, and C may be an element itself, or a set containing one or more elements.

[0030] In the embodiments of the present application, "exemplary", "in some embodiments", "in another embodiment", etc. are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.

[0031] In the embodiments of the present application, "of", "corresponding", and "corresponding" can sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings to be expressed are consistent. In the embodiments of the present application, communication and transmission can sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings to be expressed are consistent. For example, transmission can include sending and / or receiving, which can be a noun or a verb.

[0032] The equal to involved in the embodiments of the present application can be used in conjunction with greater than, and is applicable to the technical solution adopted when greater than, and can also be used in conjunction with less than, and is applicable to the technical solution adopted when less than. It should be noted that when equal to is used in conjunction with greater than, it cannot be used in conjunction with less than; when equal to is used in conjunction with less than, it cannot be used in conjunction with greater than.

[0033] Virtual memory can also be called virtual storage. When a program is running, it needs to be executed through physical memory, that is, when a program is running, it needs to occupy a certain amount of physical memory space. If too many programs are executed, it will cause too much physical memory space to be occupied, which will cause the physical memory resources to be exhausted, resulting in system crashes. To solve this problem, a space can be opened up in the hard disk as an extension of the physical memory, so that when the physical memory resources are insufficient, the memory resources can be expanded by using the expanded space in the hard disk. This space expanded in the hard disk can be called virtual memory.

[0034] It is understandable that the size of the above virtual memory is usually pre-set. If the virtual memory is set too large, it will lead to a waste of hard disk resources and memory resources. If the virtual memory is set too small, it will lead to insufficient memory resources.

[0035] Based on the above problems, an embodiment of the present application proposes a virtual memory adjustment method, which is applied to an electronic device. The electronic device can be a fixed device, for example, a fixed device can be a laptop computer, a desktop computer, a large screen, a smart screen and other devices. Alternatively, the electronic device can also be a mobile device. The mobile device can also be called user equipment (UE), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile terminal, user terminal, terminal, wireless communication device, user agent or user device. The mobile device may be a station (STAION, ST) in a WLAN, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a vehicle networking terminal, a computer, a laptop computer, a handheld communication device, a handheld computing device, a satellite wireless device, a wireless modem card, a TV set top box (STB), a customer premises equipment (CPE) and / or other devices for communicating on a wireless system and a next generation communication system, for example, a mobile terminal in a 5G network or a mobile device in a future evolved Public Land Mobile Network (PLMN) network, etc. The electronic device may also be a wearable device. Wearable devices can also be called wearable smart devices. They are a general term for the intelligent design and development of wearable devices for daily wear using wearable technology, such as glasses, gloves, watches, clothing and shoes.

[0036] The embodiments of the present application do not specifically limit the type of electronic device.

[0037] Figure 1 First, a schematic structural diagram of the electronic device 100 is shown as an example.

[0038] The electronic device 100 may include at least one processor and at least one memory connected to the processor, wherein the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method provided in the embodiment shown in this document.

[0039] Figure 1 A block diagram of an exemplary electronic device 100 suitable for implementing embodiments herein is shown. Figure 1The electronic device 100 shown is merely an example and should not limit the functionality and scope of use of the embodiments of this document.

[0040] like Figure 1 As shown, components of the electronic device 100 may include, but are not limited to: one or more processors 110 , a memory 120 , a communication bus 140 connecting different system components (including the memory 120 and the processor 110 ), and a communication interface 130 .

[0041] The communication bus 140 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnection (PCI) bus.

[0042] The electronic device 100 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the device, including volatile and non-volatile media, removable and non-removable media.

[0043] The memory 120 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The device may further include other removable / non-removable, volatile / non-volatile computer system storage media. Figure 1Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the communication bus 140 via one or more data medium interfaces. The memory 120 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments herein.

[0044] A program / utility having a set (at least one) of program modules may be stored in memory 120, such program modules including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules generally perform the functions and / or methods of the embodiments described herein.

[0045] The electronic device 100 may also communicate with one or more external devices (e.g., keyboard, pointing device, display, etc.), one or more devices that enable a user to interact with the device, and / or any device that enables the device to communicate with one or more other devices (e.g., network card, modem, etc.). Such communication may be performed via the communication interface 130. Furthermore, the electronic device 100 may also communicate with the network adapter ( Figure 1 The network adapter can communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the communication bus 140. It should be understood that although Figure 1 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 100, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Drives; hereinafter referred to as: RAID) systems, tape drives, and data backup storage systems.

[0046] The processor 110 executes various functional applications and data processing by running the programs stored in the memory 120, such as implementing the methods provided in the embodiments of this document.

[0047] It is understandable that the interface connection relationship between the modules illustrated in the embodiments of this document is only for illustrative purposes and does not constitute a structural limitation on the electronic device 100. In other embodiments of this document, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0048] Next, combine Figure 2-Figure 5 The virtual memory adjustment method provided in the embodiment of the present application is described.

[0049] Figure 2 This is a system architecture diagram provided by the embodiment of this application. Figure 2 The system architecture includes four protocol layers, for example, the four protocol layers may be an application layer, a service layer, a kernel layer and a driver layer.

[0050] The application layer can be used to provide various application services. For example, the application may include social software, photo taking software, shopping websites, game platforms, audio and video software, office software, etc. It is understandable that the above application is only an exemplary description, but does not constitute a limitation on the embodiments of the present application. In some embodiments, other types of application may also be included.

[0051] The service layer may include an information collection unit and a decision unit. The information collection unit may be used to collect information about the memory occupied by the application currently running in the electronic device, and the information about the memory occupied by the application currently running in the electronic device may include information about the physical memory and / or virtual memory occupied by the application currently running in the electronic device. The decision unit may be used to adjust the size of the current virtual memory according to the information collected by the information collection unit, and the adjustment may include increasing or decreasing it, which may help improve the efficiency of virtual memory usage and avoid insufficient or wasted virtual memory.

[0052] In some optional embodiments, the information collection unit may also be used to obtain information such as user usage habits and device hardware.

[0053] The kernel layer can adjust the virtual memory space according to the instructions of the decision unit in the service layer. For example, if the decision unit in the service layer instructs to increase the virtual memory, the kernel layer can forcibly reclaim part of the hard disk space to expand the size of the virtual memory. Alternatively, if the decision unit in the service layer instructs to reduce the virtual memory, the kernel layer can delete part or all of the current virtual memory to reduce the size of the virtual memory.

[0054] The driver layer can be used to migrate the running data of the application between the physical memory and the virtual memory. It is understandable that the efficiency of directly reading the data in the physical memory is higher than the efficiency of reading the data in the virtual memory. Therefore, when the physical memory resources are tight, some infrequently used data can be migrated to the virtual memory, and the frequently used data can be loaded into the physical memory, thereby improving the efficiency of reading the frequently used data.

[0055] For example, taking application A and application B as an example, after the user activates application A, the running data of application A can be loaded into the physical memory. Then, if the user does not use application A temporarily and wants to use application B, the electronic device can transfer application A to the background. At this time, the running data of application A can be migrated from physical memory to virtual memory, and the running data of application B can be loaded into physical memory, that is, the running data of application A occupies virtual memory, and the running data of application B occupies physical memory, thereby improving the reading efficiency of the running data of application B.

[0056] Before migrating the running data of application A from physical memory to virtual memory, the size of the file transferred each time can also be determined. It is understandable that in the process of migrating the running data of function A from physical memory to virtual memory, the data can be migrated in multiple times. In this way, excessive consumption of system resources due to excessive file transfer each time can be avoided. Exemplarily, when too many applications are executed or too many tasks (computing tasks or other types of tasks) are opened, excessive resource consumption may occur, and in severe cases, the electronic device may heat up or get hot. In this case, the consumption of system resources can be reduced. For example, the size of the transferred file can be set smaller, that is, a smaller file is transferred each time.

[0057] It is understandable that the above example only migrates operating data between applications, but does not constitute a limitation on the embodiments of the present application. In some embodiments, operating data corresponding to one or more functions within an application may also be migrated.

[0058] In some optional embodiments, if the system resources are sufficient, the size of the transmission file may be set larger, thereby improving the transmission efficiency.

[0059] like Figure 3 The figure is a flow chart of an embodiment of the virtual memory adjustment method provided by the present application. Figure 3In the scenario shown, when the application continues to occupy the physical memory, the running data in the physical memory will be migrated to the virtual memory, resulting in insufficient virtual memory resources. At this time, the virtual memory can be dynamically increased, thereby solving the problem of insufficient memory caused by fixed virtual memory size in the prior art, so as to improve the use efficiency of the virtual memory, which specifically includes the following steps:

[0060] Step 301, in response to detecting data to be executed, applying for physical memory.

[0061] Specifically, the data to be run may be data to be run when starting an application, or the data to be run may be data to be run when starting one or more functions in an application, or the data to be run may be data to be run in other scenarios, and this application does not make any special limitations on this.

[0062] In response to detecting the data to be run, a physical memory may be applied for so as to allocate the physical memory to the data to be run. The physical memory may be a double data rate (DDR) physical memory or other types of physical memory. The embodiment of the present application does not specifically limit the type of physical memory.

[0063] Step 302: In response to detecting that the physical memory is insufficient, applying for virtual memory.

[0064] Specifically, after receiving the application for physical memory, it can be detected whether the physical memory in the electronic device has enough free physical memory to be allocated to the data to be executed.

[0065] It is understandable that the upper limit of the physical memory space size depends on the hardware specifications. For example, a memory stick marked with 4G indicates that the maximum physical memory space size is 4G, or a memory stick marked with 8G indicates that the maximum physical memory space size is 8G. The above physical memory space size values ​​are only exemplary and do not constitute a limitation on the embodiments of the present application. In some embodiments, the physical memory space size values ​​may also be other values.

[0066] Therefore, as the physical memory is constantly occupied, the physical memory is likely to be exhausted or will be exhausted. When the physical memory is exhausted or will be exhausted, it will lead to insufficient physical memory. In this case, virtual memory can be applied.

[0067] It is understandable that the applied virtual memory can be used for data to be run, or part of the data already running in the physical memory can be migrated to the virtual memory, that is, the applied virtual memory is used for data already running, and the embodiments of the present application do not make special limitations on this.

[0068] In some optional embodiments, before applying for virtual memory, the space size of the applied virtual memory can also be determined. Among them, the space size of the applied virtual memory can be determined according to the occupation information of the collected physical memory. Exemplarily, the space size of the applied virtual memory can be determined according to the total space size of the physical memory, the size of the space of the occupied physical memory, and the size of the space of the physical memory that the data to be run will occupy. For example, assuming that the total space size of the physical memory is 2G, the size of the space of the occupied physical memory is 1.9G, and the size of the space of the physical memory that the data to be run will occupy is 200M. Since the remaining 0.1G of physical memory is not enough for the data to be run, therefore, 0.1G or more than 0.1G of virtual memory can be applied, and the data that has occupied 0.1G or more than 0.1G of physical memory is migrated to the applied virtual memory, so that 0.2G (i.e. 200M) or more than 0.2G of memory space is free in the physical memory, so that the freed physical memory space can load the data to be run.

[0069] It is understandable that the collection of physical memory occupancy information can be performed before step 301, or in step 301, or in any step after step 301, and the embodiment of the present application does not make any special limitation on this.

[0070] In some optional embodiments, when determining the size of the virtual memory to be applied for, the size of the virtual memory to be applied for may also be determined based on the user's usage habits. Exemplarily, the user's usage habits may include the applications that the user frequently uses, and / or some functions of the applications that the user frequently uses, and / or the time points at which the user frequently uses the applications.

[0071] Step 303: In response to detecting that the virtual memory is insufficient, increase the virtual memory space.

[0072] Specifically, as mentioned above, the virtual memory is a storage space opened up in the hard disk space, and the virtual memory may have an initial value in an initial state.

[0073] Exemplarily, if the initial value is 2G, it means that the maximum memory space of the virtual memory in the initial state is 2G, or, if the initial value is 4G, it means that the maximum memory space of the virtual memory in the initial state is 4G.

[0074] It can be understood that the above initial values ​​are merely exemplary and do not constitute a limitation on the embodiments of the present application. In some embodiments, the initial values ​​may also be other values.

[0075] After receiving the application for virtual memory, it can be detected whether the virtual memory in the electronic device has enough free virtual memory.

[0076] When it is detected that the size of the free virtual memory space does not match the size of the applied virtual memory space, the space of the virtual memory can be increased.

[0077] For example, taking the size of the applied virtual memory space as A and the size of the free virtual memory space as B, if A>B, it means that the size of the free virtual memory space does not match the size of the applied virtual memory space, and the virtual memory space can be increased; or, if A<=B, it means that the size of the free virtual memory space matches the size of the applied virtual memory space, and there is no need to increase the virtual memory space.

[0078] In some optional embodiments, after determining the space to increase the virtual memory, the size of the space of the increased virtual memory can also be determined. The size of the space of the increased virtual memory can be determined based on the collected virtual memory occupancy information and the size of the space of the applied virtual memory. Exemplarily, the size of the space of the increased virtual memory can be determined based on the total space size of the virtual memory, the size of the space of the occupied virtual memory, and the size of the space of the applied virtual memory.

[0079] It is understandable that the collection of virtual memory occupancy information may be performed before step 301, or in step 301, or in any step after step 301, and the embodiment of the present application does not impose any special limitation on this.

[0080] In some optional embodiments, the size of the increased virtual memory space may be determined in a proportional adjustment manner. For example, the virtual memory space may be increased according to a first adjustment ratio. For example, taking the initial value of the virtual memory as 2G and the first adjustment ratio as 50%, after the virtual memory space is increased, the virtual memory space increases from the initial value of 2G to 3G.

[0081] In some optional embodiments, the size of the increased virtual memory space may be determined in an absolute space manner. For example, the virtual memory space may be increased according to the first adjustment value. For example, if the initial value of the virtual memory is 2G and the first adjustment value is 1G, after the virtual memory space is increased, the virtual memory space increases from the initial value 2G to 3G.

[0082] It can be seen that the technical solution of the embodiment of the present application can dynamically increase the space of the virtual memory compared to the prior art, thereby avoiding the virtual memory shortage caused by the fixed virtual memory size, and thus avoiding the system crash caused by the virtual memory shortage. In addition, since the system needs to be restarted to take effect after the virtual memory space is reset in the prior art, the embodiment of the present application can take effect without restarting the system by dynamically increasing the space of the virtual memory, thereby improving the use efficiency and enhancing the user experience.

[0083] like Figure 4 FIG. 1 is a flow chart of another embodiment of the virtual memory adjustment method provided by the present application. Figure 4 In the embodiment shown, as the running state of the application program changes, the virtual memory can be dynamically increased to improve the system running efficiency, which specifically includes the following steps:

[0084] Step 401, monitor the running status of the application.

[0085] Specifically, the application can be run in the foreground, or the application can be run in the background, that is, the running state of the application can include running in the foreground or running in the background.

[0086] It is understandable that when an application is running in the background, the user may not operate it for a long time. In order to improve the operating efficiency of the system, the operating data of these applications running in the background can be migrated to the virtual memory to prevent the operating data of these applications running in the background from occupying the physical memory for a long time and causing the system efficiency to decrease. The freed physical memory can be used by the newly running applications.

[0087] Step 402 , in response to detecting that the running data occupying the physical memory needs to be migrated to the virtual memory, applying for the virtual memory.

[0088] Specifically, in response to detecting that the operating data that has occupied the physical memory is to be migrated to the virtual memory, the electronic device may apply for the virtual memory so as to allocate the applied virtual memory to the operating data that has occupied the physical memory.

[0089] It is understandable that before applying for virtual memory, the size of the space of the applied virtual memory may also be determined. The specific method for determining the size of the space of the applied virtual memory may refer to the relevant description in the above embodiment, which will not be repeated here.

[0090] Step 403: In response to detecting that the virtual memory is insufficient, increase the virtual memory space.

[0091] Specifically, after receiving the application for virtual memory, it can be detected whether the virtual memory in the electronic device has enough free virtual memory.

[0092] When it is detected that the size of the free virtual memory space does not match the size of the applied virtual memory space, the space of the virtual memory can be increased.

[0093] In some optional embodiments, after determining the space to increase the virtual memory, the size of the increased virtual memory space may also be determined. The specific method for determining the size of the increased virtual memory space may refer to the relevant description in the above embodiment, which will not be repeated here.

[0094] In some optional embodiments, after increasing the space of the virtual memory, since the data migration between the physical memory and the virtual memory is not necessarily completed in one migration, that is, it may be completed in multiple migrations, the file size of each migration can be determined.

[0095] The file size of each migration can be determined according to the current system resource consumption of the electronic device. For example, due to excessive system resource consumption in the electronic device, the computing speed and processing speed will be reduced, and in severe cases, the electronic device will heat up. Therefore, when the system resource consumption is too large, the file size of each migration can be set smaller, that is, each migration can occupy less system resources to avoid adding a greater burden to the electronic device; or, when the system resources are sufficient, the file size of each migration can be set larger, thereby improving the efficiency of data migration and thus improving the operation efficiency of the data.

[0096] The above Figure 3 and Figure 4 The scenario of dynamically increasing the space of virtual memory is illustrated. However, in some scenarios, as the application is closed, the space of virtual memory will be freed, which will cause waste of virtual memory. Therefore, part of the free virtual memory can be released, that is, the space of virtual memory can be reduced, thereby saving hard disk resources.

[0097] like Figure 5 FIG. 1 is a flow chart of another embodiment of the virtual memory adjustment method provided by the present application. Figure 5 In the scenario shown, when there is a lot of free virtual memory, the free virtual memory can be deleted to reduce the size of the virtual memory space and save hard disk resources. After step 303 or step 403, the following steps may also be included:

[0098] Step 501: monitor the occupancy of the physical memory and / or the occupancy of the virtual memory.

[0099] Specifically, as the applications are closed, these closed applications no longer occupy any physical memory and virtual memory.

[0100] Therefore, the occupancy of the virtual memory in the electronic device can be monitored in real time.

[0101] Among them, the occupancy of the virtual memory may include free space information of the virtual memory, and / or occupied space information of the virtual memory, etc., wherein the free space information of the virtual memory may be the size of the free virtual memory space, or the proportion of the free virtual memory to the entire virtual memory, and the occupied space information of the virtual memory may be the size of the occupied virtual memory space, or the proportion of the occupied virtual memory to the entire virtual memory, and the embodiments of the present application do not make any special limitations on this.

[0102] In some optional embodiments, the occupancy of the physical memory in the electronic device may also be monitored in real time.

[0103] Among them, the occupancy of the physical memory may include free space information of the physical memory, and / or occupied space information of the physical memory, etc., wherein the free space information of the physical memory may be the size of the free physical memory space, or the ratio of the free physical memory to the entire physical memory, and the occupied space information of the physical memory may be the size of the occupied physical memory space, or the ratio of the occupied physical memory to the entire physical memory, and the embodiments of the present application do not make any special limitations on this.

[0104] Step 502: In response to monitoring that the occupancy of the virtual memory reaches a first preset condition and / or the occupancy of the physical memory reaches a second preset condition, reduce the virtual memory space.

[0105] Specifically, when it is monitored that the occupancy of the virtual memory reaches a first preset condition, the space of the virtual memory may be reduced.

[0106] The first preset condition may be that the size of the free virtual memory reaches a first preset value, or the first preset condition may be that the proportion of the free virtual memory to the entire virtual memory reaches a second preset value.

[0107] In some optional embodiments, if the virtual memory is relatively free and the physical memory is tight, in the subsequent use of the electronic device, it is very likely that the virtual memory resources will soon be tight. At this time, it is inappropriate to reduce the size of the virtual memory. However, when both the virtual memory and the physical memory are relatively free, it is appropriate to reduce the size of the virtual memory. Therefore, when the occupancy of the virtual memory reaches the first preset condition and the occupancy of the physical memory reaches the second preset condition, the space of the virtual memory can be reduced.

[0108] The second preset condition may be that the size of the free physical memory reaches a third preset value; or the second preset condition may be that the ratio of the free physical memory to the entire physical memory reaches a fourth preset value. The first preset value and the third preset value may be the same, or the first preset value and the third preset value may be different; the second preset value and the fourth preset value may be the same, or the second preset value and the fourth preset value may be different, and the embodiment of the present application does not specifically limit this.

[0109] In some optional embodiments, when it is monitored that the occupancy of the physical memory reaches a second preset condition, the space of the virtual memory may be reduced.

[0110] In some optional embodiments, the preset conditions may also be set according to the user's usage habits. For example, the usage habits may be the user's usage time, frequently used applications, etc.

[0111] It is understandable that the above-mentioned preset conditions may also be set to other conditions, and the embodiments of the present application do not specifically limit this.

[0112] After it is determined to reduce the space of the virtual memory, the size of the reduced virtual memory space can be determined in a proportional adjustment manner. For example, the space of the virtual memory can be reduced according to the second adjustment ratio. Exemplarily, taking the virtual memory as 4G and the second adjustment ratio as 25%, after reducing the space of the virtual memory, the space of the virtual memory is reduced from 4G to 3G, and the saved virtual memory can be used by the hard disk, thereby saving hard disk space.

[0113] In some optional embodiments, the size of the reduced virtual memory space may be determined in an absolute space manner. For example, the virtual memory space may be reduced according to the second adjustment value. For example, if the virtual memory is 3G and the second adjustment value is 1G, after the virtual memory space is reduced, the virtual memory space is reduced from 3G to 2G.

[0114] In some optional embodiments, in order to avoid virtual memory shortage after reducing the virtual memory space, the reduced virtual memory space may be greater than or equal to the initial value of the virtual memory, that is, the initial value of the virtual memory may be the minimum virtual memory space.

[0115] Figure 6 This is a structural diagram of an embodiment of the virtual memory adjustment device of the present application, such as Figure 6 As shown, the virtual memory adjustment device 60 may include: an adjustment module 61; wherein:

[0116] The adjustment module 61 is configured to, in response to detecting that data in the physical memory is migrated to the virtual memory, increase the space of the virtual memory if the space of the virtual memory is insufficient.

[0117] In one possible implementation, the adjustment module 61 is further configured to increase the space of the virtual memory based on the occupancy information of the virtual memory and the size of the space of the applied virtual memory, where the size of the space of the applied virtual memory is determined by the migration data.

[0118] In one possible implementation, the virtual memory adjustment device 60 further includes:

[0119] The determination module is used to determine the file unit size of the migration data, and the file unit is used to represent the data that can be transferred each time of the migration data.

[0120] In one possible implementation, the adjustment module 61 is further configured to increase the space of the virtual memory based on a first adjustment ratio or a first adjustment value;

[0121] The first adjustment ratio is used to represent the ratio of the increased virtual memory space to the original virtual memory space, and the first adjustment value is used to represent the size of the increased virtual memory space.

[0122] In one possible implementation, the adjustment module 61 is further used to monitor the occupancy of the physical memory and / or the occupancy of the virtual memory;

[0123] In response to monitoring that the physical memory reaches a first preset condition, and / or the occupancy of the virtual memory reaches a second preset condition, reducing the space of the virtual memory.

[0124] In one possible implementation, the space of the virtual memory after reduction is greater than or equal to the space of the virtual memory before increase.

[0125] In one possible implementation, the virtual memory adjustment device 60 further includes:

[0126] The detection module is used to migrate data in the physical memory to the virtual memory in response to detecting that the physical memory is insufficient or detecting that one or more application programs will run in the background.

[0127] Figure 6 The virtual memory adjustment device 60 provided in the illustrated embodiment can be used to execute the technical solution of the method embodiment illustrated in the present application. Its implementation principle and technical effects can be further referred to the relevant description in the method embodiment.

[0128] It should be understood that the above Figure 6The division of the various modules of the virtual memory adjustment device 60 shown is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the detection module can be a separately established processing element, or it can be integrated in a chip of an electronic device. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. In the implementation process, each step of the above method or each of the above modules can be completed by an integrated logic circuit of hardware in a processor element or instructions in the form of software.

[0129] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (DSP), or one or more field programmable gate arrays (FPGA). For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0130] In the above embodiments, the processor involved may include, for example, a CPU, a DSP, a microcontroller or a digital signal processor, and may also include a GPU, an embedded neural network processor (Neural-network Process Units; hereinafter referred to as: NPU) and an image signal processor (Image Signal Processing; hereinafter referred to as: ISP). The processor may also include necessary hardware accelerators or logic processing hardware circuits, such as ASIC, or one or more integrated circuits for controlling the execution of the program of the technical solution of the present application. In addition, the processor may have the function of operating one or more software programs, and the software programs may be stored in a storage medium.

[0131] An embodiment of the present application also provides a readable storage medium, in which a program is stored. When the program is run on an electronic device, the electronic device executes the method provided by the embodiment shown in the present application.

[0132] An embodiment of the present application also provides a program product, which includes a program. When the program product is run on an electronic device, the electronic device executes the method provided by the embodiment shown in the present application.

[0133] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.

[0134] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0135] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0136] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk and other media that can store program codes.

[0137] The above is only a specific implementation of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A virtual memory adjustment method, characterized in that: The method comprises: In response to detecting that data in the physical memory is migrated to the virtual memory, if the space of the virtual memory is insufficient, the space of the virtual memory is increased.

2. The method according to claim 1, characterized in that The increasing the space of the virtual memory comprises: The space of the virtual memory is increased based on the occupancy information of the virtual memory and the space size of the applied virtual memory, wherein the space size of the applied virtual memory is determined by the migration data.

3. The method according to claim 2, characterized in that The method further comprises: The file unit size of the migration data is determined, where the file unit is used to represent the data that can be transferred each time for the migration data.

4. The method according to any one of claims 1 to 3, characterized in that: The increasing the space of the virtual memory comprises: Increasing the space of the virtual memory based on a first adjustment ratio or a first adjustment value; The first adjustment ratio is used to represent the ratio of the increased virtual memory space to the original virtual memory space, and the first adjustment value is used to represent the size of the increased virtual memory space.

5. The method according to any one of claims 1 to 4, characterized in that: After increasing the space of the virtual memory, the method further includes: Monitoring the occupancy of the physical memory and / or the occupancy of the virtual memory; In response to monitoring that the physical memory reaches a first preset condition, and / or the occupancy of the virtual memory reaches a second preset condition, reducing the space of the virtual memory.

6. The method according to claim 5, characterized in that The space of the virtual memory after the reduction is greater than or equal to the space of the virtual memory before the increase.

7. The method according to any one of claims 1 to 6, characterized in that: The detecting that data in the physical memory is migrated to the virtual memory comprises: In response to detecting that the physical memory is insufficient or detecting that one or more applications will run in the background, data in the physical memory is migrated to the virtual memory.

8. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store a program; and the processor is used to run the program to implement the virtual memory adjustment method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores a program, and when the program is run on an electronic device, the virtual memory adjustment method according to any one of claims 1 to 7 is implemented.