Memory use control method and device, storage medium and program product

By monitoring and analyzing the memory request information and frequent access of anonymous pages, the anonymous page is compressed and the anonymous page recycling problem is solved and efficient optimization of physical memory is achieved.

CN119536971APending Publication Date: 2025-02-28DOUYIN VISION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311112061.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-30
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively recycle and manage anonymous pages, resulting in the problem of insufficient physical memory.

Method used

By monitoring the anonymous page request received by the monitoring system, memory request information is obtained. If the memory size of the anonymous page is greater than the preset value and the physical memory occupancy is greater than the preset value, the anonymous page is compressed according to the frequent access.

Benefits of technology

It realizes optimization of physical memory, accurately finds objects to be compressed with high optimization efficiency, effectively releases physical memory, and improves system stability and fluency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536971A_ABST
    Figure CN119536971A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a memory use control method and device, a storage medium and a program product, and the method comprises the steps that an anonymous page request received by a system is monitored, corresponding memory request information is obtained, and the memory request information comprises the memory size of a target anonymous page to be applied; and if the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value, performing compression processing on the target anonymous page according to the subsequent access condition of the target anonymous page. According to the method provided by the embodiment of the invention, the anonymous page with a relatively large memory and a relatively large allocated physical memory is locked based on the memory size and the allocated physical memory size by monitoring the anonymous page request, and then the anonymous page is compressed based on the subsequent access frequency, so that the to-be-compressed object with relatively high optimization efficiency can be accurately found out, and the optimization efficiency of the to-be-compressed object is improved. And physical memory use control is effectively realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a memory usage control method, device, storage medium, and program product. Background Art

[0002] With the development of central processing unit (CPU) hardware technology, the bit width of CPU has gradually increased, and the focus of memory management has shifted from virtual memory to physical memory.

[0003] When the physical memory in the system is insufficient, the kernel will trigger the recycling mechanism, the main method is anonymous page compression. However, anonymous pages are generally difficult to track and record, so there has been no effective solution for the recycling of anonymous pages. Summary of the invention

[0004] The embodiments of the present disclosure provide a memory usage control method, device, storage medium and program product to effectively optimize physical memory.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for controlling physical memory usage, including:

[0006] Monitor the anonymous page requests received by the system to obtain corresponding memory request information; the anonymous page is a memory page that is not associated with any file; the memory request information includes the memory size of the target anonymous page to be applied for;

[0007] If the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value, the target anonymous page is compressed according to the access frequency of the target anonymous page.

[0008] In a second aspect, an embodiment of the present disclosure provides a memory usage control device, including:

[0009] A monitoring module, used to monitor anonymous page requests received by the system and obtain corresponding memory request information; the anonymous page is a memory page that is not associated with any file; the memory request information includes the memory size of the target anonymous page to be applied for;

[0010] The compression module is used to compress the target anonymous page according to the access frequency of the target anonymous page if the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value.

[0011] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;

[0012] The memory stores computer-executable instructions;

[0013] The processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the memory usage control method as described in the first aspect and various possible designs of the first aspect.

[0014] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the memory usage control method described in the first aspect and various possible designs of the first aspect is implemented.

[0015] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the memory usage control method described in the first aspect and various possible designs of the first aspect.

[0016] The present embodiment provides a memory usage control method and device, the method includes monitoring anonymous page requests received by the system, obtaining corresponding memory request information, the memory request information including the memory size of the target anonymous page to be applied for, if the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value, then according to the subsequent access situation of the target anonymous page, the target anonymous page is compressed. The method provided by the disclosed embodiment monitors anonymous page requests, and locks anonymous pages with larger memory and larger allocated physical memory based on the memory size and the allocated physical memory size, and then compresses the anonymous pages based on the subsequent access frequency, so as to accurately find out the objects to be compressed with higher optimization efficiency and effectively realize physical memory usage control. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0018] Figure 1 A diagram showing the relationship between virtual memory and physical memory provided for related technologies;

[0019] Figure 2 Schematic diagram of the memory usage control method provided in the embodiment of the present disclosure Figure 1 ;

[0020] Figure 3 Schematic diagram of the memory usage control method provided in the embodiment of the present disclosure Figure 2 ;

[0021] Figure 4 A structural block diagram of a memory usage control device provided in an embodiment of the present disclosure;

[0022] Figure 5 A schematic diagram of the hardware structure of a memory usage control device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0024] With the development of CPU hardware technology, the bit width of CPU has gradually increased, for example, from 32 bits to 64 bits. Under 32 bits, the operation of applications is limited to 4GB of virtual memory addressing space, so the main topic of memory optimization is virtual memory. Under 64 bits, the addressing space is 256TB, which can be considered infinite for applications. Therefore, virtual memory is no longer a limitation for the stable operation of applications, and the limitation of physical memory follows.

[0025] Figure 1 A diagram showing the relationship between virtual memory and physical memory provided for related technologies. Figure 1 As shown in the figure, physical memory is the capacity of an actual physical device (such as the capacity of the memory stick actually installed in the computer), which provides the operating system with space for data storage and reading and writing. Its capacity, i.e., addressing space, can usually be configured, which is generally 1GB to 8GB. Virtual memory is the addressing space allocated by the operating system to each process, which is 256TB in 64-bit. When an application allocates memory, the operating system will allocate an area in the address space (such as 1, 2, 3, and 4 in the figure) for the application to use. When an application accesses the allocated virtual memory address, the operating system will allocate an equal amount of physical memory pages in the physical memory to store the application data. According to the needs of the application business, the same physical page can also be allocated to the virtual memory blocks of different applications to achieve memory sharing among multiple applications.

[0026] It can be seen that physical memory can be shared by multiple applications. Compared with virtual memory, physical memory resources are more precious. Physical memory is generally managed by the operating system, but with the popularity of 64-bit CPUs and the surge in virtual memory, physical memory consumption is increasing, and the memory management of the operating system is becoming increasingly stretched. In extreme cases, it seriously affects the stability and smoothness of the system and applications. Therefore, the monitoring and optimization needs of physical memory are gradually being paid attention to.

[0027] The kernel in Linux manages the allocation and recycling of physical memory. When the physical memory in the system is insufficient, the kernel will trigger the recycling mechanism, mainly in the form of anonymous page compression. However, anonymous pages are generally difficult to track and record, so there has been no effective solution for the recycling of anonymous pages.

[0028] In order to solve the above technical problems, the inventors of the present disclosure have found that anonymous page applications can be monitored, and anonymous pages with large virtual memory applications, large physical memory occupancy, and infrequent access can be found and compressed to release physical memory, thereby achieving the purpose of physical memory optimization. Based on this, the present disclosure provides a physical memory usage control method.

[0029] refer to Figure 2 , Figure 2 Schematic diagram of the memory usage control method provided in the embodiment of the present disclosure Figure 1 The method of this embodiment can be applied in a terminal device or a server. The memory usage control method includes:

[0030] 201. Monitor anonymous page requests received by the system to obtain corresponding memory request information; the anonymous page is a memory page that is not associated with any file; the memory request information includes the memory size of the target anonymous page to be requested.

[0031] Specifically, considering that the system needs to call specific functions (such as mmap(), mremap(), munmap(), etc.) when applying for an anonymous page, in order to monitor the memory request, the system call function for applying for the anonymous page can be hooked, that is, Hooked. In this way, once an anonymous page application occurs, a system notification will be received, that is, memory request information, and the information of the requested anonymous page will be obtained, such as creation time, virtual memory address, memory size, etc.

[0032] In one embodiment of the present disclosure, the monitoring of anonymous page requests received by the system to obtain corresponding memory request information may include: setting a hook function for a target function used to request anonymous pages, and monitoring the anonymous page requests received by the system according to the hook function to obtain corresponding memory request information.

[0033] 202. If the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value, compressing the target anonymous page according to the access frequency of the target anonymous page; the first preset value is greater than or equal to the second preset value.

[0034] Specifically, considering that the larger the physical memory of the anonymous page to be compressed is, the higher the efficiency of memory usage control will be, therefore, in order to improve the efficiency of optimization, a certain threshold can be set, for example, when the memory size is greater than a first preset value and the allocated physical memory is greater than a second preset value, the anonymous page is taken as the object to be compressed. Considering that if the anonymous page access rate is high, compression and decompression will need to be more frequent, which wastes resources and is still not conducive to the stable operation of the system and applications, in order to avoid resource waste and make the optimization more reasonable, the objects with low access rates can be further compressed.

[0035] In one embodiment of the present disclosure, the allocation of physical memory can be detected within a preset time after the anonymous page request is detected. For example, the allocation of physical memory corresponding to the anonymous page can be obtained by reading the / proc / self / pagemap node 2 minutes after the anonymous page request is received.

[0036] From the above description, it can be seen that the memory usage control method provided by the embodiment of the present disclosure monitors anonymous page requests, and locks anonymous pages with larger memory and larger allocated physical memory based on the memory size and the allocated physical memory size, and then compresses the anonymous pages based on the subsequent frequency of access. It can accurately find the objects to be compressed with higher optimization efficiency and effectively realize physical memory usage control.

[0037] In one embodiment of the present disclosure, compressing the target anonymous page according to the frequency of access to the target anonymous page may include: canceling the access attribute of the target anonymous page to receive an access exception alarm when the target anonymous page is accessed; if no access exception alarm for the target anonymous page is received within a first preset time after canceling the access attribute, compressing the target anonymous page.

[0038] Specifically, after a period of time (such as 2 minutes) after the target anonymous page is applied, the allocation of physical memory corresponding to the target anonymous page is obtained by reading the / proc / self / pagemap node. If it is determined that a large number of physical pages have been allocated (for example, the physical memory is greater than 1M), the mprotect() function can be called to remove the access attributes (read, write, execute) of the target anonymous page. Removing the access attributes can detect access anomalies through a pre-registered signal processing function when the target anonymous page is accessed later, so as to know that the target anonymous page has been accessed. By monitoring whether the target anonymous page is accessed within a preset time, it is determined whether the target anonymous page can be compressed. For example, if the target anonymous page has no memory access within a period of time (such as 5 minutes), the target anonymous page can be compressed.

[0039] In one embodiment of the present disclosure, compressing the target anonymous page includes: compressing the data of the target anonymous page to obtain compressed data; and saving the compressed data to a storage space outside the target physical memory corresponding to the target anonymous page to release the target physical memory. Optionally, the storage space is a physical memory space or a disk space.

[0040] Specifically, after determining that the target anonymous page needs to be compressed, the data in the target physical memory corresponding to the target anonymous page can be compressed, and the obtained compressed data can be stored in a storage space other than the target physical memory, and the physical memory can be released to achieve the purpose of saving memory. Specifically, madvice() can be called with the MADV_DONTNEED parameter for the original memory segment to release the physical memory. Optionally, in order to facilitate reading, the storage space can use the space of the physical memory, and in order to fully save the space of the physical memory, the storage space can use the disk space. Among them, the virtual memory segment corresponding to the storage space is different from the memory segment corresponding to the target anonymous page. That is to say, in order to save physical memory, although the virtual memory is newly added, the space of the virtual memory is very abundant compared to the physical memory space. Therefore, overall, the loss of occupying virtual memory can be ignored.

[0041] In one embodiment of the present disclosure, after releasing the target physical memory, it may also include: if an abnormal access alarm to the target anonymous page is received, obtaining the compressed data from the storage space, decompressing the compressed data and writing it into the memory segment corresponding to the target anonymous page.

[0042] Specifically, after the target anonymous page is compressed, since the access attribute has been removed before, if the target anonymous page is accessed, an access exception alarm will be obtained through the signal processing function. Therefore, after receiving the access exception alarm, it indicates that the target anonymous page needs to be accessed, and then the compressed data stored in the storage space can be reversely decompressed and rewritten into the memory segment corresponding to the target anonymous page.

[0043] In one embodiment of the present disclosure, after the compressed data is decompressed and written into the memory segment corresponding to the target anonymous page, it may also include: if the physical memory allocated to the target anonymous page is greater than a third preset value after the compressed data of the target anonymous page is decompressed after a second preset time, compressing the target anonymous page according to the access frequency of the target anonymous page; the third preset value is less than or equal to the first preset value.

[0044] Specifically, after the compressed data is restored, after a second preset time period, the physical memory allocated to the target anonymous page continues to be monitored. When it is determined that the physical memory space allocated to the target anonymous page is greater than a third preset value, such as 1M, the target anonymous page continues to be compressed based on subsequent access conditions. For specific information on how to compress the target anonymous page based on subsequent access conditions, please refer to the above embodiment and will not be repeated here.

[0045] In one embodiment of the present disclosure, the compression processing of the target anonymous page according to the access frequency of the target anonymous page may also include: if an access abnormality alarm of the target anonymous page is received within the first preset time after the access attribute is cancelled, the access attribute of the target anonymous page is restored.

[0046] Specifically, after a period of time (such as 2 minutes) after the target anonymous page is applied, the allocation of the physical memory corresponding to the target anonymous page is obtained by reading the / proc / self / pagemap node. If it is determined that a large number of physical pages have been allocated (for example, the physical memory is greater than 1M), the mprotect() function can be called to remove the access attributes (read, write, execute) of the target anonymous page. Removing the access attributes can detect access anomalies through a pre-registered signal processing function when the target anonymous page is accessed later, so as to know that the target anonymous page has been accessed. By monitoring whether the target anonymous page is accessed within a preset time, it is determined whether the target anonymous page can be compressed. For example, if the target anonymous page has memory access within a period of time (such as 5 minutes), it indicates that the access rate of the target anonymous page is relatively high, and there is no need to compress the target anonymous page. In order to achieve access, the previously cancelled access attributes can be restored, and then the access can be completed.

[0047] In one embodiment of the present disclosure, after restoring the access attributes of the target anonymous page, it may also include: if the physical memory allocated to the target anonymous page is greater than a fourth preset value after a third preset time after the access attributes are restored, compressing the target anonymous page according to the access frequency of the target anonymous page; the fourth preset value is less than or equal to the first preset value.

[0048] Specifically, after completing the access to the target anonymous page, the access to the target anonymous page can continue to be monitored. If it is monitored that no access abnormality alarm is received within the third preset time period, it indicates that the access frequency of the target anonymous page has decreased. At this time, when it is determined that the physical memory space allocated to the target anonymous page is greater than the fourth preset value, such as 1M, the target anonymous page can continue to be compressed based on the subsequent access situation. How to compress the target anonymous page based on the subsequent access situation can be referred to the introduction of the above embodiment, which will not be repeated here.

[0049] In this embodiment, the second preset time and the third preset time can be the same or different values. The third preset value and the fourth preset value can be the same or different values, which can be determined according to actual test conditions, and this embodiment does not limit this.

[0050] refer to Figure 3 , Figure 3 Schematic diagram of the memory usage control method provided in the embodiment of the present disclosure Figure 2 Based on the above embodiments, for example Figure 2 On the basis of the embodiment shown, in this embodiment, the target anonymous pages in different states are marked in state, so as to implement different monitoring strategies for anonymous pages with different marks. The memory usage control method includes:

[0051] 301. Monitor anonymous page requests received by the system to obtain corresponding memory request information; the anonymous page is a memory page that is not associated with any file; the memory request information includes the memory size of the target anonymous page to be requested.

[0052] 302. Determine whether the memory size is greater than a first preset value, if so, execute step 303, if not, execute step 310.

[0053] 303. Mark the target anonymous page as an observation page.

[0054] 304 . Determine whether the physical memory allocated to the observation page is greater than a second preset value. If not, continue to maintain it as the observation page. If so, execute step 305 .

[0055] 305. Cancel the access attribute of the observation page and mark the observation page as a protection page.

[0056] 306 . Determine whether an abnormal access alarm to the protected page is received within the first preset time. If not, execute step 307 . If yes, execute step 310 .

[0057] 307. Mark the protection page as a cold page, compress the data of the cold page to obtain compressed data; save the compressed data to a storage space outside the target physical memory corresponding to the cold page, and release the target physical memory.

[0058] 308. Determine whether an abnormal access alarm to a cold page is received. If yes, execute step 309.

[0059] 309. Obtain the compressed data from the storage space, decompress the compressed data and write it into the memory segment corresponding to the cold page, and mark the cold page as a hot page.

[0060] 310. Restore the access attribute of the protection page and mark the protection page as a hot page.

[0061] 311. After a preset period of time, mark the hot page as an observation page, and return to step 304.

[0062] For example, in order to find inactive anonymous pages, the system call functions for applying for anonymous pages, such as mmap(), mremap(), and munmap(), can be hooked, that is, hooked off, so that all anonymous pages used by the application can be managed and their creation time, address, size, etc. can be recorded. A signal processing function is registered, and memory access exceptions are monitored through the signal processing function.

[0063] The requested memory size is determined by the result of the hook. If the requested memory size is large (such as greater than 2M), the target anonymous page can be marked as an observation page (Watching).

[0064] After a period of time (such as 2 minutes) after the observation page (Watching) is applied, the allocation of physical memory corresponding to the observation page is obtained by reading the / proc / self / pagemap node. If it is determined that a large number of physical pages have been allocated (for example, greater than 1M), the mprotect() function can be called to remove the memory segment access attributes (read, write, execute) corresponding to the observation page and mark it as a protection page (Protecting). If the allocated physical pages do not reach the threshold, the observation page (Watchding) state is maintained.

[0065] After a period of time (such as 5 minutes), if there is any access to the protected page (Protecting) during this period, the kernel will trigger a memory access exception. In the signal processing function used to monitor memory access exceptions, the access attributes of the memory page are restored and the memory segment is marked as a hot page (Hot). If there is no memory access during this period, the memory segment is marked as a cold page (Cold).

[0066] Cold pages are compressed and saved in a cache other than the physical memory corresponding to the cold pages, or saved on disk. In order to save memory, madvice() is called with the MADV_DONTNEED parameter for the original memory segment to release physical memory and mark it as compressed page.

[0067] If the compressed memory segment is accessed later, a memory access exception will occur because there is still no access attribute at this time, which will trigger the signal processing function. The compressed memory segment can be found in the signal processing function, decompressed and written back to the compressed memory segment, and marked as a hot page.

[0068] After a period of time (such as 30 minutes), the hot page memory segment is marked as a watching page and returns to the processing step of the watching page.

[0069] From the above description, we can know that by removing the access attribute of the memory segment and monitoring with the signal processing function, we can determine whether the memory is accessed, thereby determining whether the memory page is cold or hot. By compressing anonymous pages, we can save memory. That is, by finding inactive anonymous pages and compressing and managing them at the user level, we can reduce the pressure on the system's physical memory, thereby reducing the pressure on the kernel's physical memory recovery and improving the fluency and stability of the application.

[0070] In one embodiment of the present disclosure, during actual application, the above logic can be installed in the application as an independent SDK, and as a memory management module, it monitors and manages the physical memory of the application in real time during the entire life cycle of the application. Specifically, the compression logic can be started when the application starts according to actual needs, or the compression logic can be triggered when the physical memory of the application reaches a certain threshold.

[0071] Corresponding to the memory usage control method of the above embodiment, Figure 4 This is a structural block diagram of a memory usage control device provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 4 , the device includes: a monitoring module 401 and a compression module 402.

[0072] The monitoring module 401 is used to monitor the anonymous page request received by the system and obtain the corresponding memory request information; the anonymous page is a memory page that is not associated with any file; the memory request information includes the memory size of the target anonymous page to be applied for;

[0073] The compression module 402 is configured to compress the target anonymous page according to the access frequency of the target anonymous page if the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value.

[0074] In one embodiment of the present disclosure, the compression module 402 is specifically used to: cancel the access attribute of the target anonymous page so as to receive an access exception alarm when the target anonymous page is accessed; if no access exception alarm for the target anonymous page is received within a first preset time after canceling the access attribute, the target anonymous page is compressed.

[0075] In one embodiment of the present disclosure, the compression module 402 is specifically used to: compress the data of the target anonymous page to obtain compressed data; save the compressed data to a storage space outside the target physical memory corresponding to the target anonymous page, and release the target physical memory.

[0076] In one embodiment of the present disclosure, the storage space is physical memory space or disk space.

[0077] In one embodiment of the present disclosure, the compression module 402 is further used to: if an abnormal access alarm to the target anonymous page is received, obtain the compressed data from the storage space, decompress the compressed data and write it into the memory segment corresponding to the target anonymous page.

[0078] In one embodiment of the present disclosure, the compression module 402 is also used to: if the physical memory allocated to the target anonymous page is greater than a third preset value after the compressed data of the target anonymous page is decompressed after a second preset time, compress the target anonymous page according to the access frequency of the target anonymous page; the third preset value is less than or equal to the first preset value.

[0079] In one embodiment of the present disclosure, the compression module 402 is further configured to restore the access attribute of the target anonymous page if an abnormal access alarm to the target anonymous page is received within a first preset time after the access attribute is cancelled.

[0080] In one embodiment of the present disclosure, the compression module 402 is also used to: if the physical memory allocated to the target anonymous page is greater than a fourth preset value after the access attribute is restored after a third preset time, compress the target anonymous page according to the access frequency of the target anonymous page; the fourth preset value is less than or equal to the first preset value.

[0081] In one embodiment of the present disclosure, the monitoring module 401 is specifically used to: set a hook function for a target function for requesting an anonymous page, monitor the anonymous page request received by the system according to the hook function, and obtain corresponding memory request information.

[0082] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.

[0083] In order to implement the above embodiment, the embodiment of the present disclosure also provides an electronic device.

[0084] refer to Figure 5 , which shows a schematic diagram of the structure of an electronic device 900 suitable for implementing the embodiment of the present disclosure, and the electronic device 900 may be a terminal device or a server. The terminal device may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0085] like Figure 5 As shown, the electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 to a random access memory (RAM) 903. Various programs and data required for the operation of the electronic device 900 are also stored in the RAM 903. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0086] Typically, the following devices may be connected to the I / O interface 905: input devices 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 908 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 900 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0087] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0088] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0089] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0090] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0091] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0092] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0093] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".

[0094] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0095] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0096] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0097] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0098] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A memory usage control method, characterized in that: include: Monitor anonymous page requests received by the system and obtain corresponding memory request information; The anonymous page is a memory page that is not associated with any file; The memory request information includes the memory size of the target anonymous page to be applied for; If the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value, compressing the target anonymous page according to the access frequency of the target anonymous page; The first preset value is greater than or equal to the second preset value.

2. The method according to claim 1, characterized in that The compressing the target anonymous page according to the access frequency of the target anonymous page includes: canceling the access attribute of the target anonymous page, so as to receive an access abnormality alarm when the target anonymous page is accessed; If no access abnormality alarm for the target anonymous page is received within a first preset time after the access attribute is cancelled, the target anonymous page is compressed.

3. The method according to claim 2, characterized in that The compressing the target anonymous page includes: Compressing the data of the target anonymous page to obtain compressed data; The compressed data is saved in a storage space outside the target physical memory corresponding to the target anonymous page, and the target physical memory is released.

4. The method according to claim 3, characterized in that The storage space is physical memory space or disk space.

5. The method according to claim 3, characterized in that: After releasing the target physical memory, the method further includes: If an abnormal access alarm to the target anonymous page is received, the compressed data is obtained from the storage space, and the compressed data is decompressed and written into the memory segment corresponding to the target anonymous page.

6. The method according to claim 5, characterized in that After decompressing the compressed data and writing it into the memory segment corresponding to the target anonymous page, the method further includes: If the physical memory allocated to the target anonymous page is greater than a third preset value after the compressed data of the target anonymous page is decompressed after a second preset time, the target anonymous page is compressed according to the access frequency of the target anonymous page; the third preset value is less than or equal to the first preset value.

7. The method according to claim 2, characterized in that The compressing the target anonymous page according to the access frequency of the target anonymous page also includes: If an abnormal access alarm to the target anonymous page is received within a first preset time after the access attribute is cancelled, the access attribute of the target anonymous page is restored.

8. The method according to claim 7, characterized in that After restoring the access attribute of the target anonymous page, the method further includes: If the physical memory allocated to the target anonymous page is greater than a fourth preset value after the access attribute is restored for a third preset time, the target anonymous page is compressed according to the access frequency of the target anonymous page; the fourth preset value is less than or equal to the first preset value.

9. The method according to any one of claims 1 to 8, characterized in that: The step of monitoring the anonymous page request received by the system and obtaining the corresponding memory request information includes: A hook function is set for a target function for requesting an anonymous page, and the anonymous page request received by the system is monitored according to the hook function to obtain corresponding memory request information.

10. A memory usage control device, characterized in that: include: A monitoring module, used to monitor anonymous page requests received by the system and obtain corresponding memory request information; The anonymous page is a memory page that is not associated with any file; The memory request information includes the memory size of the target anonymous page to be applied for; The compression module is used to compress the target anonymous page according to the access frequency of the target anonymous page if the memory size is greater than a first preset value and the physical memory allocated to the target anonymous page is greater than a second preset value.

11. An electronic device, characterized in that: include: Processor and memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the memory usage control method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the memory usage control method according to any one of claims 1 to 9 is implemented.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the memory usage control method according to any one of claims 1 to 9 is implemented.