Dynamic memory intelligent expansion method and device, equipment and storage medium

By identifying free capacity in the dynamic memory area and performing data compression, transmission, and fragmentation reclamation, the problem of tight dynamic memory resources is solved, memory utilization efficiency is improved, and the cost of electronic devices is reduced.

CN115328656BActive Publication Date: 2026-04-07SHENZHEN OURUIBO ELECTRONICS
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-16
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

With limited hardware resources, the scarcity and high cost of dynamic memory resources lead to low resource utilization efficiency in electronic devices.

Method used

By identifying the free capacity of the dynamic memory area, data is compressed into a preset compressed memory area in main memory, data is transferred to a preset swap memory area in flash memory, and memory fragments are periodically reclaimed to release target data and expand the usable capacity of the dynamic memory area.

Benefits of technology

It improves the efficiency of dynamic memory usage, reduces the cost of electronic devices, and enhances resource utilization and product competitiveness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115328656B_ABST
    Figure CN115328656B_ABST
Patent Text Reader

Abstract

The application relates to memory management and provides a dynamic memory intelligent expansion method, device, equipment and storage medium. The method identifies the main memory and the flash memory of an electronic device, the main memory comprising a dynamic memory area; when it is detected that the free capacity of the dynamic memory area is less than a preset threshold, first storage data in the dynamic memory area is compressed to a preset compression memory area in the main memory. The application can effectively solve the technical problems of dynamic memory resource shortage and insufficiency under limited hardware resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of memory management technology, and in particular to a method, apparatus, device, and storage medium for dynamic intelligent memory expansion. Background Technology

[0002] With the development of the internet, the number of services running on electronic devices to provide different business functions has increased, leading to a greater demand for dynamic memory. To meet these business functions at the lowest possible cost, effectively addressing the shortage of dynamic memory resources within limited hardware resources and reducing equipment costs have become urgent technical challenges. Summary of the Invention

[0003] In view of the above, it is necessary to provide a method, device, equipment and storage medium for intelligent expansion of dynamic memory, which can effectively solve the technical problem of the tension and insufficiency of dynamic memory resources under the premise of limited hardware resources.

[0004] On the one hand, this invention proposes a dynamic memory intelligent expansion method for application in electronic devices. The dynamic memory intelligent expansion method includes:

[0005] Identify the main memory and flash memory of electronic devices; the main memory includes a dynamic memory area.

[0006] When the free capacity of the dynamic memory area is detected to be less than a preset threshold, the first stored data in the dynamic memory area is compressed into the preset compressed memory area in the main memory.

[0007] According to a preferred embodiment of the present invention, the method further includes:

[0008] Periodically acquire free bytes from the dynamic memory area according to a preset time period;

[0009] Calculate the duration for which idle bytes remain idle;

[0010] Identify the minimum length of newly added cached data in the dynamic memory area;

[0011] If the duration exceeds the preset duration and the length of the free bytes is less than the minimum length, the free bytes will be identified as memory fragments.

[0012] Call the preset interface to perform memory fragmentation reclamation.

[0013] According to a preferred embodiment of the present invention, the method further includes:

[0014] Get the lower limit of the dynamic memory area's capacity;

[0015] The upper limit of capacity is obtained by multiplying the lower limit of capacity by the preset ratio.

[0016] Generate a preset range based on the lower and upper capacity limits;

[0017] The preset threshold is adjusted periodically based on the preset range.

[0018] According to a preferred embodiment of the present invention, compressing the first stored data in the dynamic memory area to a preset compressed memory area in the main memory specifically includes:

[0019] Based on the preset mapping table, determine the occupied capacity of the preset compressed memory area;

[0020] The first stored data is extracted from the dynamic memory area based on the occupied capacity;

[0021] The first stored data is compressed to obtain compressed data;

[0022] Transfer the compressed data to the preset compressed memory area.

[0023] According to a preferred embodiment of the present invention, the method further includes: transferring a second storage data in a dynamic memory region to a preset swap memory region in a flash memory, including:

[0024] Calculate the amount of data in the second storage area;

[0025] A transmission thread is obtained from a preset thread pool based on the amount of data.

[0026] The target byte is determined from the preset swap memory area, corresponding to the amount of data.

[0027] Invoke the transmission thread to transfer the second storage data to the target byte for storage.

[0028] According to a preferred embodiment of the present invention, the method further includes:

[0029] If the execution frequency and number of executions of data stored in the dynamic memory area are less than the preset frequency and number of executions, the data will be identified as the target data.

[0030] Clear the target data from the dynamic memory area.

[0031] According to a preferred embodiment of the present invention, clearing target data from the dynamic memory area specifically includes:

[0032] Call the preset deletion thread to clear the target data; or

[0033] The target data is transferred to the preset swap memory area.

[0034] On the other hand, the present invention also proposes a dynamic memory intelligent expansion device, which operates in electronic devices. The dynamic memory intelligent expansion device includes:

[0035] An identification unit is used to identify the main memory and flash memory of an electronic device, wherein the main memory includes a dynamic memory area;

[0036] The compression unit is used to compress the first stored data in the dynamic memory area to a preset compressed memory area in the main memory when the free capacity of the dynamic memory area is detected to be less than a preset threshold.

[0037] On the other hand, the present invention also proposes an electronic device, the electronic device comprising:

[0038] Memory, which stores computer-readable instructions; and

[0039] A processor executes computer-readable instructions stored in memory to enable a dynamic and intelligent method of memory expansion.

[0040] On the other hand, the present invention also proposes a computer-readable storage medium storing computer-readable instructions, which are executed by a processor in an electronic device to realize a dynamic memory intelligent expansion method.

[0041] As can be seen from the above technical solutions, when the free capacity is detected to be less than a preset threshold, this application can increase the total capacity of the dynamic memory area by compressing the first storage data and transmitting the second storage data to the preset swap memory area. By actively releasing the target occupied dynamic area, the utilization efficiency of the dynamic memory area can be improved, and memory fragments can be periodically recycled. Under the condition of limited hardware resources, this application can effectively solve the problems of resource shortage in the dynamic memory area and high cost of electronic devices due to the high cost of dynamic memory by combining multiple dimensions. Attached Figure Description

[0042] Figure 1 This is a flowchart of a preferred embodiment of the dynamic memory intelligent expansion method of the present invention.

[0043] Figure 2 This is a visual diagram of the preset compressed memory area in this invention.

[0044] Figure 3 This is a visual diagram of the preset swap memory area in this invention.

[0045] Figure 4 This is a functional block diagram of a preferred embodiment of the dynamic memory intelligent expansion device of the present invention.

[0046] Figure 5 This is a schematic diagram of the structure of an electronic device that implements a preferred embodiment of the intelligent dynamic memory expansion method of the present invention. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0048] like Figure 1 The diagram shown is a flowchart of a preferred embodiment of the dynamic memory intelligent expansion method of the present invention. The order of the steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements.

[0049] The dynamic memory intelligent expansion method is applied to one or more electronic devices. An electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored computer-readable instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0050] Electronic devices can be any electronic product that allows human-computer interaction, such as personal computers, tablets, smartphones, personal digital assistants (PDAs), game consoles, interactive network television (IPTV), smart wearable devices, etc.

[0051] Electronic devices may include network devices and / or user devices. Among them, network devices include, but are not limited to, single network electronic devices, groups of electronic devices consisting of multiple network electronic devices, or cloud computing-based clouds consisting of a large number of hosts or network electronic devices.

[0052] The networks in which electronic devices are located include, but are not limited to: the Internet, wide area networks (WANs), metropolitan area networks (MANs), local area networks (LANs), and virtual private networks (VPNs).

[0053] 101 identifies the main memory and flash memory of an electronic device, with the main memory including the dynamic memory area.

[0054] In at least one embodiment of the present invention, the electronic device may be a smart home product, such as home appliances, lighting systems, smart central control screen switches, etc.

[0055] Main memory is the internal memory that directly exchanges data with the CPU. Main memory is usually used as a temporary data storage medium for the operating system or other running programs of electronic devices.

[0056] Flash memory, also known as flash storage, is a type of storage chip that allows data to be modified through specific programs.

[0057] Dynamic memory refers to the RAM capacity in main memory that users can specify for the startup of a virtual operating system.

[0058] In at least one embodiment of the present invention, the electronic device identifies the main memory and flash memory of the electronic device, specifically including:

[0059] The memory of type 1 in the electronic device is designated as main memory, and the memory of type 2 is designated as flash memory.

[0060] The first type of memory can write or read information from any specified address at any time.

[0061] The second type of memory will not lose data due to power failure.

[0062] The memory type allows for accurate identification of main memory and flash memory.

[0063] 102. When the free capacity of the dynamic memory area is detected to be less than the preset threshold, the first stored data in the dynamic memory area is compressed into the preset compressed memory area in the main memory.

[0064] In at least one embodiment of the present invention, the preset threshold is a parameter value obtained by periodic adjustment.

[0065] The first stored data can be any data stored in the dynamic memory area. The preset compressed memory area refers to a memory region pre-defined in the main memory of an electronic device. Generally, the capacity of the preset compressed memory area does not exceed 10% of the main memory capacity. Data in the preset compressed memory area, because it has undergone compression processing, can be read at high speed. For example... Figure 2 As shown, Figure 2 The large square in the middle is the main storage. Figure 2 The small square in the image represents the preset compressed memory area.

[0066] In at least one embodiment of the present invention, the method further includes:

[0067] Get the lower limit of the dynamic memory area's capacity;

[0068] The upper limit of capacity is obtained by multiplying the lower limit of capacity by the preset ratio.

[0069] Generate a preset range based on the lower and upper capacity limits;

[0070] The preset threshold is adjusted periodically based on the preset range.

[0071] The lower limit of capacity can be set via the kernel option / proc / sys / vm / min_free_kbytes.

[0072] The preset ratio can be set according to actual needs; for example, the preset ratio can be 2.5.

[0073] By controlling the preset threshold within a preset range, it is possible to avoid frequent data compression and clearing due to setting the preset threshold too high, and also to avoid a small available dynamic memory area due to setting the preset threshold too low. This improves the rationality of the preset threshold setting. By periodically adjusting the preset threshold, resource balance of electronic devices can be achieved.

[0074] In at least one embodiment of the present invention, the electronic device compresses first stored data in a dynamic memory area to a preset compressed memory area in the main memory, specifically including:

[0075] Based on the preset mapping table, determine the occupied capacity of the preset compressed memory area;

[0076] The first stored data is extracted from the dynamic memory area based on the occupied capacity;

[0077] The first stored data is compressed to obtain compressed data;

[0078] Transfer the compressed data to the preset compressed memory area.

[0079] The preset mapping table stores the mapping relationship between multiple preset memory areas and their corresponding bytes.

[0080] By extracting the first storage data from the occupied capacity, a reasonable amount of storage data can be extracted, avoiding data loss due to the inability to store compressed data in the occupied bytes.

[0081] Specifically, the electronic device determines the occupied capacity of the preset compressed memory area based on a preset mapping table, including:

[0082] Retrieve the bytes occupied by the preset compressed memory area from the preset mapping table;

[0083] Calculate the occupied capacity based on the number of bytes occupied.

[0084] By using a pre-defined mapping table, the occupied bytes can be quickly obtained, improving the efficiency of determining the occupied capacity.

[0085] In other embodiments, the size of the occupied capacity can be set according to different business needs.

[0086] In other embodiments, the electronic device stores compressed data and first storage data in a preset swap memory area in flash memory.

[0087] In at least one embodiment of the present invention, the electronic device reclaims memory fragments in the dynamic memory area according to a preset time period.

[0088] The preset time can be set according to actual needs. Memory fragmentation refers to all unusable free memory in an electronic device.

[0089] In at least one embodiment of the present invention, the electronic device reclaims memory fragments in the dynamic memory area according to a preset time period, specifically including:

[0090] Periodically acquire free bytes from the dynamic memory area according to a preset time period;

[0091] Calculate the duration for which idle bytes remain idle;

[0092] Identify the minimum length of newly added cached data in the dynamic memory area;

[0093] If the duration exceeds the preset duration and the length of the free bytes is less than the minimum length, the free bytes will be identified as memory fragments.

[0094] Call the preset interface to perform memory fragmentation reclamation.

[0095] Among them, the duration refers to the difference between the acquisition time of the free byte and the release time of the free byte. The release time refers to the point in time when the data is cleared from the free byte, and the acquisition time refers to the point in time when the free byte is acquired from the dynamic memory area.

[0096] New cached data refers to the data information processed by the electronic device during the period from the time of release to the time of acquisition.

[0097] The preset duration can be set according to actual needs; for example, the preset duration can be 1 hour.

[0098] The default interface can be the kernel-mode shrinker interface.

[0099] By combining the comparison between the duration and the preset duration, and the comparison between the length of the free byte and the minimum length, it is possible to avoid the free byte being mistakenly designated as memory fragment because it cannot be occupied in a short period of time, thereby improving the rationality of memory fragment identification and the rationality of periodic memory fragment reclamation.

[0100] In at least one embodiment of the present invention, a second storage data in a dynamic memory area is transferred to a preset swap memory area in a flash memory.

[0101] In at least one embodiment of the present invention, the second stored data is typically data that has not been used recently in the dynamic memory area. The second stored data can be determined by comparing the data read time corresponding to the stored data in the dynamic memory area with the configuration time period.

[0102] Pre-defined swap memory refers to a memory area that an electronic device pre-configures in its flash memory. For example... Figure 3 As shown, Figure 3 The large box in the image represents the flash memory. Figure 2 The small square in the image represents the default swap memory area.

[0103] In at least one embodiment of the present invention, transferring the second storage data in the dynamic memory area to a preset swap memory area in the flash memory specifically includes:

[0104] Calculate the amount of data in the second storage area;

[0105] A transmission thread is obtained from a preset thread pool based on the amount of data.

[0106] The target byte is determined from the preset swap memory area, corresponding to the amount of data.

[0107] Invoke the transmission thread to transfer the second storage data to the target byte for storage.

[0108] Among them, the transmission thread refers to the number of idle threads in the preset thread pool that is configured. The configured number is determined based on the amount of data and the data transmission efficiency of the idle threads.

[0109] The target byte refers to the byte region in the preset swap memory area that corresponds to the amount of data.

[0110] Identifying the target byte by the amount of data can prevent data loss during the transmission of the second storage data. Transmitting the second storage data through a transmission thread can achieve fast transmission of the second storage data without consuming the resources of the electronic device.

[0111] In at least one embodiment of the present invention, the method further includes:

[0112] If the execution frequency and number of executions of data stored in the dynamic memory area are less than the preset frequency and number of executions, the data will be identified as the target data.

[0113] Clear the target data from the dynamic memory area.

[0114] The target data refers to the stored data in the dynamic memory area whose execution frequency is less than the preset frequency and whose execution count is less than the preset count.

[0115] Execution frequency refers to the number of times an electronic device reads stored data per unit of time. Execution count refers to the total number of times stored data is read from the dynamic memory area.

[0116] The preset frequency and preset number of times can be set according to actual needs.

[0117] By combining the comparison between the execution frequency and the preset frequency, as well as the comparison between the number of executions and the preset number of executions, the target data can be accurately determined, thereby improving the rationality of the generation of the target occupying the dynamic area.

[0118] Specifically, the electronic device clears the target data from the dynamic memory area, including:

[0119] Call the preset deletion thread to clear the target data; or

[0120] The target data is transferred to the preset swap memory area.

[0121] The above implementation methods can achieve the removal of target data based on a variety of different removal methods.

[0122] The main memory in this invention includes, but is not limited to: a first dynamic area occupied by first stored data in a dynamic memory area, a second dynamic area occupied by second stored data in a dynamic memory area, and a target dynamic area occupied by target stored data in a dynamic memory area.

[0123] In at least one embodiment of the present invention, the electronic device completes the resource expansion of the dynamic memory area based on memory fragmentation and the release of storage space of the first occupied dynamic area, the second occupied dynamic area and the target occupied dynamic area.

[0124] In at least one embodiment of the present invention, memory fragments, a first occupied dynamic area, a second occupied dynamic area, a target occupied dynamic area, a preset compressed memory area, and a second occupied dynamic area can all be used as extended areas of the dynamic memory area.

[0125] As can be seen from the above technical solutions, when the free capacity is detected to be less than a preset threshold, this application can increase the total usable capacity of the dynamic memory area by compressing the first stored data and transferring the second stored data to a preset swap memory area. By actively releasing the target occupied dynamic area, the utilization efficiency of the dynamic memory area can be improved, and memory fragmentation can be periodically reclaimed. Under limited hardware resources, this approach effectively solves the resource shortage problem of the dynamic memory area by combining multiple dimensions. Furthermore, since dynamic memory is relatively expensive, solving the dynamic memory resource shortage problem can also reduce the cost of electronic devices, thereby enhancing the long-term competitiveness of electronic device products.

[0126] like Figure 4 The diagram shown is a functional block diagram of a preferred embodiment of the dynamic memory intelligent expansion device of the present invention. The dynamic memory intelligent expansion device 11 includes an identification unit 110, a recycling unit 111, a compression unit 112, a transmission unit 113, a clearing unit 114, an execution unit 115, an acquisition unit 116, a calculation unit 117, and a generation unit 118. The module / unit referred to in this invention refers to a series of computer-readable instruction segments that can be acquired by the processor 13 and perform a fixed function, and which are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0127] The identification unit 110 identifies the main memory and flash memory of the electronic device, the main memory including a dynamic memory area.

[0128] In at least one embodiment of the present invention, the electronic device may be a smart home product, such as home appliances, lighting systems, smart central control screen switches, etc.

[0129] Main memory is the internal memory that directly exchanges data with the CPU. Main memory is usually used as a temporary data storage medium for the operating system or other running programs of electronic devices.

[0130] Flash memory, also known as flash storage, is a type of storage chip that allows data to be modified through specific programs.

[0131] Dynamic memory refers to the RAM capacity in main memory that users can specify for the startup of a virtual operating system.

[0132] In at least one embodiment of the present invention, the identification unit 110 identifies the main memory and flash memory of the electronic device, specifically including:

[0133] The memory of type 1 in the electronic device is designated as main memory, and the memory of type 2 is designated as flash memory.

[0134] The first type of memory can write or read information from any specified address at any time.

[0135] The second type of memory will not lose data due to power failure.

[0136] The memory type allows for accurate identification of main memory and flash memory.

[0137] When the free capacity of the dynamic memory area is detected to be less than a preset threshold, the compression unit 112 compresses the first stored data in the dynamic memory area to the preset compressed memory area in the main memory.

[0138] In at least one embodiment of the present invention, the preset threshold is a parameter value obtained by periodic adjustment.

[0139] The first stored data can be any data stored in the dynamic memory area. The preset compressed memory area refers to a memory region pre-defined in the main memory of an electronic device. Generally, the capacity of the preset compressed memory area does not exceed 10% of the main memory capacity. Data in the preset compressed memory area, because it has undergone compression processing, can be read at high speed. For example... Figure 2 As shown, Figure 2 The large square in the middle is the main storage. Figure 2 The small square in the image represents the preset compressed memory area.

[0140] In at least one embodiment of the present invention, the acquisition unit 116 acquires the lower limit value of the capacity of the dynamic memory area;

[0141] The calculation unit 117 calculates the product of the lower limit of capacity and the preset ratio to obtain the upper limit of capacity;

[0142] Generation unit 118 generates a preset range based on the lower capacity limit and the upper capacity limit;

[0143] The execution unit 115 periodically adjusts the preset threshold according to the preset range.

[0144] The lower limit of capacity can be set via the kernel option / proc / sys / vm / min_free_kbytes.

[0145] The preset ratio can be set according to actual needs; for example, the preset ratio can be 2.5.

[0146] By controlling the preset threshold within a preset range, it is possible to avoid frequent data compression and clearing due to setting the preset threshold too high, and also to avoid a small available dynamic memory area due to setting the preset threshold too low. This improves the rationality of the preset threshold setting. By periodically adjusting the preset threshold, resource balance of electronic devices can be achieved.

[0147] In at least one embodiment of the present invention, the compression unit 112 compresses the first stored data in the dynamic memory area to a preset compressed memory area in the main memory, specifically including:

[0148] Based on the preset mapping table, determine the occupied capacity of the preset compressed memory area;

[0149] The first stored data is extracted from the dynamic memory area based on the occupied capacity;

[0150] The first stored data is compressed to obtain compressed data;

[0151] Transfer the compressed data to the preset compressed memory area.

[0152] The preset mapping table stores the mapping relationship between multiple preset memory areas and their corresponding bytes.

[0153] By extracting the first storage data from the occupied capacity, a reasonable amount of storage data can be extracted, avoiding data loss due to the inability to store compressed data in the occupied bytes.

[0154] Specifically, the compression unit 112 determines the occupied capacity of the preset compressed memory area based on a preset mapping table, including:

[0155] Retrieve the bytes occupied by the preset compressed memory area from the preset mapping table;

[0156] Calculate the occupied capacity based on the number of bytes occupied.

[0157] By using a pre-defined mapping table, the occupied bytes can be quickly obtained, improving the efficiency of determining the occupied capacity.

[0158] In other embodiments, the size of the occupied capacity can be set according to different business needs.

[0159] In other embodiments, the compression unit 112 stores the compressed data and the first storage data in a preset swap memory area in the flash memory.

[0160] In at least one embodiment of the present invention, the recycling unit 111 recycles memory fragments in the dynamic memory area according to a preset time period.

[0161] The preset time can be set according to actual needs. Memory fragmentation refers to all unusable free memory in an electronic device.

[0162] In at least one embodiment of the present invention, the recycling unit 111 recycles memory fragments in the dynamic memory area according to a preset time period, specifically including:

[0163] Periodically acquire free bytes from the dynamic memory area according to a preset time period;

[0164] Calculate the duration for which idle bytes remain idle;

[0165] Identify the minimum length of newly added cached data in the dynamic memory area;

[0166] If the duration exceeds the preset duration and the length of the free bytes is less than the minimum length, the free bytes will be identified as memory fragments.

[0167] Call the preset interface to perform memory fragmentation reclamation.

[0168] Among them, the duration refers to the difference between the acquisition time of the free byte and the release time of the free byte. The release time refers to the point in time when the data is cleared from the free byte, and the acquisition time refers to the point in time when the free byte is acquired from the dynamic memory area.

[0169] New cached data refers to the data information processed by the electronic device during the period from the time of release to the time of acquisition.

[0170] The preset duration can be set according to actual needs; for example, the preset duration can be 1 hour.

[0171] The default interface can be the kernel-mode shrinker interface.

[0172] By combining the comparison between the duration and the preset duration, and the comparison between the length of the free byte and the minimum length, it is possible to avoid the free byte being mistakenly designated as memory fragment because it cannot be occupied in a short period of time, thereby improving the rationality of memory fragment identification and the rationality of periodic memory fragment reclamation.

[0173] In at least one embodiment of the present invention, the transmission unit 113 transmits the second storage data in the dynamic memory area to the preset swap memory area in the flash memory.

[0174] In at least one embodiment of the present invention, the second stored data is typically data that has not been used recently in the dynamic memory area. The second stored data can be determined by comparing the data read time corresponding to the stored data in the dynamic memory area with the configuration time period.

[0175] Pre-defined swap memory refers to a memory area that an electronic device pre-configures in its flash memory. For example... Figure 3 As shown, Figure 3 The large box in the image represents the flash memory. Figure 2 The small square in the image represents the default swap memory area.

[0176] In at least one embodiment of the present invention, the transmission unit 113 transmits the second storage data in the dynamic memory area to a preset swap memory area in the flash memory, specifically including:

[0177] Calculate the amount of data in the second storage area;

[0178] A transmission thread is obtained from a preset thread pool based on the amount of data.

[0179] The target byte is determined from the preset swap memory area, corresponding to the amount of data.

[0180] Invoke the transmission thread to transfer the second storage data to the target byte for storage.

[0181] Among them, the transmission thread refers to the number of idle threads in the preset thread pool that is configured. The configured number is determined based on the amount of data and the data transmission efficiency of the idle threads.

[0182] The target byte refers to the byte region in the preset swap memory area that corresponds to the amount of data.

[0183] Identifying the target byte by the amount of data can prevent data loss during the transmission of the second storage data. Transmitting the second storage data through a transmission thread can achieve fast transmission of the second storage data without consuming the resources of the electronic device.

[0184] In at least one embodiment of the present invention, if the execution frequency of data stored in the dynamic memory area is less than a preset frequency and the number of executions is less than a preset number, the clearing unit 114 determines the data as target data.

[0185] The clearing unit 114 clears the target data from the dynamic memory area.

[0186] The target data refers to the stored data in the dynamic memory area whose execution frequency is less than the preset frequency and whose execution count is less than the preset count.

[0187] Execution frequency refers to the number of times an electronic device reads stored data per unit of time. Execution count refers to the total number of times stored data is read from the dynamic memory area.

[0188] The preset frequency and preset number of times can be set according to actual needs.

[0189] By combining the comparison between the execution frequency and the preset frequency, as well as the comparison between the number of executions and the preset number of executions, the target data can be accurately determined, thereby improving the rationality of the generation of the target occupying the dynamic area.

[0190] Specifically, the clearing unit 114 clears the target data from the dynamic memory area, including:

[0191] Call the preset deletion thread to clear the target data; or

[0192] The target data is transferred to the preset swap memory area.

[0193] The above implementation methods can achieve the removal of target data based on a variety of different removal methods.

[0194] The main memory in this invention includes, but is not limited to: a first dynamic area occupied by first stored data in a dynamic memory area, a second dynamic area occupied by second stored data in a dynamic memory area, and a target dynamic area occupied by target stored data in a dynamic memory area.

[0195] In at least one embodiment of the present invention, the execution unit 115 completes the resource expansion of the dynamic memory area based on memory fragmentation and the release of storage space of the first occupied dynamic area, the second occupied dynamic area and the target occupied dynamic area.

[0196] In at least one embodiment of the present invention, memory fragments, a first occupied dynamic area, a second occupied dynamic area, a target occupied dynamic area, a preset compressed memory area, and a second occupied dynamic area can all be used as extended areas of the dynamic memory area.

[0197] As can be seen from the above technical solutions, when the free capacity is detected to be less than a preset threshold, this application can increase the total capacity of the dynamic memory area by compressing the first storage data and transmitting the second storage data to the preset swap memory area. By actively releasing the target occupied dynamic area, the utilization efficiency of the dynamic memory area can be improved, and memory fragments can be periodically recycled. Under the condition of limited hardware resources, this application can effectively solve the problem of resource shortage in the dynamic memory area by combining multiple dimensions, reduce the cost of dynamic memory, reduce the cost of electronic products, and enhance the competitiveness of products.

[0198] like Figure 5 The diagram shown is a schematic representation of the structure of an electronic device that implements the intelligent dynamic memory expansion method of the present invention.

[0199] In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer-readable instructions stored in the memory 12 and executable on the processor 13, such as a dynamic memory intelligent extension program.

[0200] Those skilled in the art will understand that the schematic diagram is merely an example of electronic device 1 and does not constitute a limitation on electronic device 1. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device 1 may also include input / output devices, network access devices, buses, etc.

[0201] Processor 13 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. Processor 13 is the computational core and control center of electronic device 1, connecting various parts of electronic device 1 through various interfaces and lines, and executing the operating system of electronic device 1, as well as various installed application programs and program code.

[0202] For example, computer-readable instructions can be divided into one or more modules / units, one or more of which are stored in memory 12 and executed by processor 13 to complete the present invention. One or more modules / units can be a series of computer-readable instruction segments capable of performing a specific function, which describe the execution process of the computer-readable instructions in electronic device 1. For example, the computer-readable instructions can be divided into an identification unit 110, a recycling unit 111, a compression unit 112, a transmission unit 113, a clearing unit 114, an execution unit 115, an acquisition unit 116, a calculation unit 117, and a generation unit 118.

[0203] The memory 12 can be used to store computer-readable instructions and / or modules. The processor 13 implements various functions of the electronic device 1 by running or executing the computer-readable instructions and / or modules stored in the memory 12 and by calling the data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. The memory 12 may include non-volatile and volatile memory, such as: hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other storage devices.

[0204] The memory 12 can be the external memory and / or internal memory of the electronic device 1. Furthermore, the memory 12 can be a physical memory, such as a memory stick, a TF card (Trans-flash Card), etc.

[0205] If the modules / units integrated in electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by instructing related hardware through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium, and when executed by a processor, the computer-readable instructions can implement the steps of the various method embodiments described above.

[0206] Computer-readable instructions include computer-readable instruction code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media can include: any entity or device capable of carrying computer-readable instruction code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), and random access memory (RAM).

[0207] Combination Figure 1 The memory 12 in electronic device 1 stores computer-readable instructions to implement a dynamic intelligent memory expansion method, and the processor 13 can execute computer-readable instructions to achieve:

[0208] Identify the main memory and flash memory of electronic devices; the main memory includes a dynamic memory area.

[0209] When the free capacity of the dynamic memory area is detected to be less than a preset threshold, the first stored data in the dynamic memory area is compressed into the preset compressed memory area in the main memory.

[0210] Specifically, the specific implementation method of the processor 13 for the above-mentioned computer-readable instructions can be found in [reference]. Figure 1 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.

[0211] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.

[0212] A computer-readable storage medium stores computer-readable instructions, which, when executed by processor 13, are used to perform the following steps:

[0213] Identify the main memory and flash memory of electronic devices; the main memory includes a dynamic memory area.

[0214] When the free capacity of the dynamic memory area is detected to be less than a preset threshold, the first stored data in the dynamic memory area is compressed into the preset compressed memory area in the main memory.

[0215] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0216] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.

[0217] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.

[0218] Furthermore, it is clear that the word "including" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices can also be implemented by a single unit or device through software or hardware. Terms such as "first," "second," etc., are used to indicate names and do not indicate any specific order.

[0219] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A dynamic memory intelligent expansion method, applied to electronic devices, characterized in that, The method includes: Identify the main memory and flash memory of the electronic device, wherein the main memory includes a dynamic memory area; When the free capacity of the dynamic memory area is detected to be less than a preset threshold, the first stored data in the dynamic memory area is compressed into a preset compressed memory area in the main memory. Specifically, this includes: determining the occupied capacity of the preset compressed memory area based on a preset mapping table, wherein the preset mapping table stores a mapping relationship between multiple preset memory areas and corresponding bytes; extracting the first stored data from the dynamic memory area based on the occupied capacity; compressing the first stored data to obtain compressed data; and transferring the compressed data to the preset compressed memory area. The method further includes: Obtain the lower limit value of the capacity of the dynamic memory area; The upper capacity value is obtained by multiplying the lower capacity limit by a preset ratio. A preset range is generated based on the lower capacity limit and the upper capacity limit; The preset threshold is adjusted periodically according to the preset range.

2. The dynamic memory intelligent expansion method as described in claim 1, characterized in that, The method further includes: Periodically acquire free bytes from the dynamic memory area according to a preset time period; Calculate the duration for which the idle byte remains idle; Identify the minimum length of newly added cached data in the dynamic memory area; If the duration is greater than the preset duration and the length of the free byte is less than the minimum length, the free byte is identified as a memory fragment. The preset interface is invoked to perform the reclamation of the memory fragments.

3. The dynamic memory intelligent expansion method as described in claim 1, characterized in that, The method further includes: transferring the second storage data in the dynamic memory area to a preset swap memory area in the flash memory, including: Calculate the amount of data in the second storage area; A transmission thread is obtained from a preset thread pool based on the amount of data. The bytes corresponding to the data volume are determined from the preset swap memory area as the target bytes; The transmission thread is invoked to transmit the second storage data to the target byte for storage.

4. The dynamic memory intelligent expansion method as described in claim 3, characterized in that, The method further includes: If the execution frequency of data stored in the dynamic memory area is less than the preset frequency and the number of executions is less than the preset number of executions, the data will be identified as target data. Clear the target data from the dynamic memory area.

5. The dynamic memory intelligent expansion method as described in claim 4, characterized in that, The step of clearing the target data from the dynamic memory area specifically includes: Call the preset deletion thread to clear the target data; or The target data is transferred to the preset swap memory area.

6. A dynamic memory intelligent expansion device, applied to electronic devices, characterized in that, The dynamic memory intelligent expansion device includes: An identification unit is used to identify the main memory and flash memory of the electronic device, wherein the main memory includes a dynamic memory area; A compression unit is configured to compress first stored data in the dynamic memory area to a preset compressed memory area in the main memory when the free capacity of the dynamic memory area is detected to be less than a preset threshold. Specifically, this includes: determining the occupied capacity of the preset compressed memory area based on a preset mapping table, wherein the preset mapping table stores multiple preset memory areas and corresponding bytes; extracting the first stored data from the dynamic memory area based on the occupied capacity; compressing the first stored data to obtain compressed data; and transferring the compressed data to the preset compressed memory area. The device further includes: The acquisition unit is used to acquire the lower limit value of the capacity of the dynamic memory area; The calculation unit is used to calculate the product of the lower limit of capacity and the preset ratio to obtain the upper limit of capacity; A generation unit is used to generate a preset range based on the lower capacity limit and the upper capacity limit; An execution unit is used to periodically adjust the preset threshold according to the preset interval.

7. An electronic device, characterized in that, The electronic device includes: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the dynamic memory intelligent expansion method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which are executed by a processor in an electronic device to implement the dynamic memory intelligent expansion method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Memory application method and device and storage medium

    CN109614240A

  • Dynamic memory fusion and prefetch techniques

    CN114036076A

  • Memory dynamic management method and device, equipment and storage medium

    CN114706686A