Memory allocation method, device, apparatus and storage medium

By identifying and adjusting the utilization rate of memory units and the image rate, reusable images of a set size are created, memory allocation is optimized, the problem of low memory utilization in terminal devices is solved, and more efficient memory management is achieved.

CN115061950BActive Publication Date: 2025-12-16CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210697095.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-20
Publication Date
2025-12-16
Estimated Expiration
2042-06-20

AI Technical Summary

Technical Problem

In existing technologies, the image caching strategy of terminal devices results in cached images in the primary memory not being reused, and a large number of mismatched image sizes appearing in the secondary memory, leading to low memory utilization.

Method used

By identifying primary and secondary memory units, the system calculates memory usage, image loading rate, and removal rate, adjusts capacity accordingly, creates reusable images of a set size, and partitions capacity based on reuse count and reuse rate to optimize memory allocation.

Benefits of technology

It improves memory utilization, avoids time consumption and memory fluctuations caused by image creation and memory allocation, and ensures the reasonable capacity and efficiency of memory units.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115061950B_ABST
    Figure CN115061950B_ABST
Patent Text Reader

Abstract

The application relates to data storage and provides a memory allocation method, device, equipment and storage medium. The method calculates a memory usage rate based on a first occupied capacity of a first-level memory unit, calculates a picture loading rate based on a loaded image of the first-level memory unit, calculates a picture removal rate based on a removed image of the first-level memory unit, performs capacity adjustment processing on the first-level memory unit according to the memory usage rate, the picture loading rate and the picture removal rate, obtains an adjusted first-level memory unit, identifies the picture size of a reused picture in a second-level memory unit, creates a set size according to the picture size, performs capacity division on the second-level memory unit based on the reuse frequency and reuse rate of each set size, and obtains a size memory unit of each set size, so that the memory utilization rate can be improved. In addition, the application also relates to a blockchain technology, and the reuse rate can be stored in the blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data storage, and in particular to a memory allocation method, device, equipment and storage medium. BACKGROUND

[0002] In order to improve the loading speed of pictures, some picture caching strategies are usually configured in terminal equipment, however, these picture caching strategies usually cause a large number of cached pictures in primary memory not to be reused, and a large number of unmatched picture sizes in secondary memory, resulting in low memory utilization. SUMMARY

[0003] In view of the above, it is necessary to provide a memory allocation method, device, equipment and storage medium, which can improve memory utilization.

[0004] In one aspect, the present application provides a memory allocation method, which comprises:

[0005] When a memory allocation request is received, a primary memory unit and a secondary memory unit are identified based on the memory allocation request;

[0006] The memory usage rate of the primary memory unit is calculated based on the first occupied capacity of the primary memory unit;

[0007] The picture loading rate of the primary memory unit is calculated based on the loaded image of the primary memory unit, and the picture removal rate of the primary memory unit is calculated based on the removed image of the primary memory unit;

[0008] The primary memory unit is subjected to capacity adjustment processing according to the memory usage rate, the picture loading rate and the picture removal rate, to obtain a primary adjusted memory unit;

[0009] The picture size of a reused picture in the secondary memory unit is identified, and a set size is created according to the picture size;

[0010] The secondary memory unit is subjected to capacity division based on the reuse frequency of each set size and the reuse rate of each set size, to obtain a size memory unit of each set size.

[0011] According to the preferred embodiment of the present application, the identification of the primary memory unit and the secondary memory unit based on the memory allocation request comprises:

[0012] The request message of the memory allocation request is parsed to obtain data information carried by the request message;

[0013] The memory name is extracted from the data information, and the space corresponding to the memory name is determined as a memory space;

[0014] obtaining a remaining space capacity of the memory space;

[0015] calculating a product of a first preset ratio and the remaining space capacity to obtain a first occupied capacity, and calculating a product of a second preset ratio and the remaining space capacity to obtain a second occupied capacity;

[0016] extracting a continuous address space from the memory space as the first-level memory unit based on the first occupied capacity, and extracting a continuous address space from the memory space as the second-level memory unit based on the second occupied capacity.

[0017] According to the preferred embodiment of the present application, the calculating the picture removal rate of the first-level memory unit based on the removed images of the first-level memory unit comprises:

[0018] obtaining images transferred from the first-level memory unit to the second-level memory unit as the removed images;

[0019] counting a total amount of images in the first-level memory unit;

[0020] calculating a ratio of the number of the removed images to the total amount of images to obtain the picture removal rate.

[0021] According to the preferred embodiment of the present application, the capacity adjustment processing of the first-level memory unit according to the memory usage rate, the picture loading rate and the picture removal rate to obtain a first adjusted memory unit comprises:

[0022] obtaining a first set weight value of the memory usage rate, a second set weight value of the picture loading rate and a third set weight value of the picture removal rate, wherein the first set weight value is greater than the second set weight value which is greater than the third set weight value;

[0023] performing weighted sum operation on the memory usage rate, the picture loading rate and the picture removal rate based on the first set weight value, the second set weight value and the third set weight value to obtain a memory utilization rate of the first-level memory unit;

[0024] performing capacity reduction processing on the first-level memory unit based on the memory utilization rate of the first-level memory unit and a preset adjustment range until the memory utilization rate of the first-level memory unit no longer increases to obtain the first adjusted memory unit.

[0025] According to the preferred embodiment of the present application, the identifying the picture size of the reused pictures in the second-level memory unit comprises:

[0026] acquire a read picture from a module log library of a preset module, and select a picture that does not correspond to all images in the primary memory unit as the multiplexed picture from the read picture;

[0027] acquire a first pixel point quantity of the multiplexed picture in a first preset dimension, and acquire a second pixel point quantity of the multiplexed picture in a second preset dimension;

[0028] generate the picture size according to the first pixel point quantity and the second pixel point quantity.

[0029] According to the preferred embodiment of the present application, the creating the set size according to the picture size comprises:

[0030] acquiring a maximum size and a minimum size in the picture size;

[0031] performing size limiting processing on the maximum size based on a preset interval, until a size obtained after the size limiting processing is less than or equal to the minimum size, to obtain the set size.

[0032] According to the preferred embodiment of the present application, the capacity division of the secondary memory unit based on the multiplexing quantity of each set size and the multiplexing rate of each set size to obtain the size memory unit of each set size comprises:

[0033] acquiring a multiplexing size of each multiplexed picture from the set size;

[0034] counting the multiplexing quantity of each set size based on the acquisition quantity of the multiplexing size;

[0035] performing capacity division of the secondary memory unit according to the multiplexing quantity of each set size to obtain an initial memory unit of each set size;

[0036] calculating a product of a set capacity occupied by each set size and the multiplexing quantity to obtain a multiplexing capacity, and calculating a ratio of each multiplexing capacity to a size occupied capacity of the initial memory unit to obtain a multiplexing rate of each set size;

[0037] performing capacity adjustment of a plurality of the initial memory units according to the multiplexing rate, until the multiplexing rate of each set size is in a preset interval threshold, to obtain the size memory unit of each set size.

[0038] On the other hand, the present application further provides a memory allocation device, which comprises:

[0039] an identification unit, configured to identify a primary memory unit and a secondary memory unit based on a memory allocation request when the memory allocation request is received;

[0040] a calculation unit configured to calculate a memory usage rate of the primary memory unit based on a first occupied capacity of the primary memory unit;

[0041] The calculation unit is further configured to calculate a picture loading rate of the primary memory unit based on loaded images of the primary memory unit and a picture removal rate of the primary memory unit based on removed images of the primary memory unit.

[0042] an adjustment unit configured to perform capacity adjustment processing on the primary memory unit according to the memory usage rate, the picture loading rate and the picture removal rate, to obtain a primary adjusted memory unit;

[0043] a creation unit configured to identify picture sizes of multiplexed pictures in the secondary memory unit and create set sizes according to the picture sizes;

[0044] a division unit configured to perform capacity division on the secondary memory unit based on a multiplexing number of each set size and a multiplexing rate of each set size, to obtain a size memory unit of each set size.

[0045] In another aspect, the present application further provides an electronic device, which comprises:

[0046] a memory configured to store computer readable instructions; and

[0047] a processor configured to execute the computer readable instructions stored in the memory to implement the memory allocation method.

[0048] In another aspect, the present application further provides a computer readable storage medium, which stores computer readable instructions, and the computer readable instructions are executed by a processor in an electronic device to implement the memory allocation method.

[0049] As can be seen from the above technical solutions, by performing capacity reduction processing on the primary memory unit according to the memory usage rate, the picture loading rate and the picture removal rate, the loading of cached pictures can be met under the premise that the occupied capacity of the primary adjusted memory unit is minimum, so as to improve the memory utilization rate. By creating each set size from multiplexed pictures in the secondary memory unit, not only the time consumption problem caused by creating pictures can be avoided, but also the memory fluctuation problem caused by memory opening can be avoided, and then by performing capacity division on the secondary memory unit based on the multiplexing number of each set size and the multiplexing rate of each set size, a large number of unmatched sizes in the secondary memory unit can be avoided, so as to improve the memory utilization rate. BRIEF DESCRIPTION OF DRAWINGS

[0050] Figure 1 is a flowchart of a preferred embodiment of the memory allocation method of the present application.

[0051] Figure 2 is a functional module diagram of a preferred embodiment of the memory allocation device of the present application.

[0052] Figure 3 is a structural schematic diagram of an electronic device for implementing a preferred embodiment of the memory allocation method of the present application. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be described in detail below in combination with the drawings and specific embodiments.

[0054] As shown in Figure 1 is a flowchart of a preferred embodiment of the memory allocation method of the present application. The order of steps in the flowchart can be changed according to different needs, and some steps can be omitted.

[0055] The memory allocation method can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) is the theory, method, technology and application system for simulating, extending and expanding human intelligence by using digital computers or machines controlled by digital computers, perceiving the environment, acquiring knowledge and using the knowledge to obtain the best results.

[0056] The basic technology of artificial intelligence generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. The software technology of artificial intelligence mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology and machine learning / deep learning, etc.

[0057] The memory allocation method is applied to one or more electronic devices, and the electronic device is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored computer readable instructions. The hardware thereof includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0058] The electronic device can be any electronic product that can interact with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive Internet Protocol Television (IPTV), a smart wearable device, and the like.

[0059] The electronic device can include a network device and / or a user device. The network device includes, but is not limited to, a single network electronic device, a group of electronic devices composed of multiple network electronic devices, or a cloud composed of a large number of hosts or network electronic devices based on cloud computing.

[0060] The network in which the electronic device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), and the like.

[0061] S10, when receiving a memory allocation request, identifying a first memory unit and a second memory unit based on the memory allocation request.

[0062] In at least one embodiment of the present application, the memory allocation request carries a name corresponding to a space requiring memory allocation.

[0063] The first memory unit is used to store a cache picture that is not temporarily displayed. By storing the cache picture in the first memory unit, the corresponding picture can be directly obtained from the first memory unit for subsequent caching, avoiding reloading and re-decoding the picture from the file, thereby accelerating the display speed.

[0064] The picture stored in the second memory unit is a picture removed from the first memory unit. That is, if the first memory unit is full, the least recently used picture will be removed to the second memory unit.

[0065] In at least one embodiment of the present application, the electronic device identifying the first memory unit and the second memory unit based on the memory allocation request includes:

[0066] Parsing a request message of the memory allocation request to obtain data information carried by the request message;

[0067] Extracting a memory name from the data information, and determining a space corresponding to the memory name as a memory space;

[0068] Obtaining a remaining space capacity of the memory space;

[0069] a first preset proportion and the remaining space capacity to obtain a first occupation capacity, and a second preset proportion and the remaining space capacity to obtain a second occupation capacity;

[0070] extract a continuous address space from the memory space as the first-level memory unit based on the first occupation capacity, and extract a continuous address space from the memory space as the second-level memory unit based on the second occupation capacity.

[0071] The remaining space capacity refers to the available capacity of the memory space.

[0072] The first preset proportion and the second preset proportion are proportions set according to actual needs, and the first preset proportion is greater than the second preset proportion.

[0073] The first preset proportion and the second preset proportion are proportions set according to actual needs, and the first preset proportion is greater than the second preset proportion.

[0074] S11, calculate a memory usage rate of the first-level memory unit based on a first occupation capacity of the first-level memory unit.

[0075] It should be emphasized that, in order to further ensure the privacy and security of the above-mentioned memory usage rate, the above-mentioned memory usage rate can also be stored in a node of a block chain.

[0076] In at least one embodiment of the present application, the first occupation capacity refers to the memory size of the first-level memory unit.

[0077] The memory usage rate refers to the ratio of the data occupation capacity of the first-level memory unit to the first occupation capacity. For example, the first-level memory unit stores an A database, the data occupation capacity of the A database is 3M, and the first occupation capacity is 10M. Therefore, the memory usage rate is 0.3.

[0078] S12, calculate a picture loading rate of the first-level memory unit based on a loaded image of the first-level memory unit, and calculate a picture removal rate of the first-level memory unit based on a removed image of the first-level memory unit.

[0079] It should be emphasized that, in order to further ensure the privacy and security of the above-mentioned picture loading rate and the above-mentioned picture removal rate, the above-mentioned picture loading rate and the above-mentioned picture removal rate can also be stored in a node of a block chain.

[0080] In at least one embodiment of the present application, the loading image refers to the cached picture displayed in the primary memory unit.

[0081] The picture loading rate refers to the ratio of the number of pictures displayed in the primary memory unit to the total number of images in the primary memory unit.

[0082] The removal image refers to the image transferred from the primary memory unit to the secondary memory unit.

[0083] The picture removal rate refers to the ratio of the number of removal images to the total number of images.

[0084] In at least one embodiment of the present application, the electronic device calculates the picture removal rate of the primary memory unit based on the removal image of the primary memory unit, comprising:

[0085] Obtaining the image transferred from the primary memory unit to the secondary memory unit as the removal image;

[0086] Counting the total number of images in the primary memory unit;

[0087] Calculating the ratio of the number of removal images to the total number of images to obtain the picture removal rate.

[0088] Through the above implementation, the picture removal rate can be accurately determined.

[0089] S13, according to the memory usage rate, the picture loading rate and the picture removal rate, the capacity of the primary memory unit is adjusted to obtain a primary adjusted memory unit.

[0090] In at least one embodiment of the present application, the primary adjusted memory unit is the primary memory unit whose capacity is adjusted to the primary memory unit whose memory utilization rate no longer increases.

[0091] In at least one embodiment of the present application, the electronic device adjusts the capacity of the primary memory unit according to the memory usage rate, the picture loading rate and the picture removal rate to obtain a primary adjusted memory unit, comprising:

[0092] Obtaining the first set weight value of the memory usage rate, the second set weight value of the picture loading rate and the third set weight value of the picture removal rate, the first set weight value is greater than the second set weight value which is greater than the third set weight value;

[0093] weighting and calculating the memory usage rate, the picture loading rate and the picture removing rate based on the first setting weight value, the second setting weight value and the third setting weight value, to obtain a memory utilization rate of the first memory unit;

[0094] performing capacity reduction processing on the first memory unit based on the memory utilization rate of the first memory unit and a preset adjustment range, until the memory utilization rate of the first memory unit no longer increases, to obtain a first adjusted memory unit.

[0095] The preset adjustment range is determined according to the capacity adjustment accuracy of the first memory unit, for example, the preset adjustment range can be 500 kb.

[0096] By setting the first setting weight value greater than the second setting weight value and the third setting weight value, the calculation accuracy of the memory utilization rate of the first memory unit can be improved. By performing capacity reduction processing on the first memory unit based on the preset adjustment range, since the preset adjustment range is set within a reasonable range, the capacity adjustment accuracy of the first memory unit can be improved while ensuring the capacity adjustment efficiency of the first memory unit, so that the memory utilization rate of the first memory unit can be ensured.

[0097] S14, identifying the picture size of the multiplexed picture in the second memory unit, and creating a setting size according to the picture size.

[0098] In at least one embodiment of the present application, the multiplexed picture refers to a read picture of a preset module, and a picture that does not correspond to all images in the first memory unit. The preset module can be an application program of a terminal device corresponding to the memory space.

[0099] The setting size refers to a size that can load the multiplexed picture, and the setting size is greater than or equal to the picture size of the multiplexed picture. For example, if the picture size of the multiplexed picture is 4*4, the corresponding setting size can be 4*4 or 5*5, etc.

[0100] In at least one embodiment of the present application, the electronic device identifying the picture size of the multiplexed picture in the second memory unit comprises:

[0101] obtaining a read picture from a module log library of a preset module, and selecting a picture that does not correspond to all images in the first memory unit from the read picture as the multiplexed picture;

[0102] obtaining a first pixel point number of the multiplexed picture in a first preset dimension, and obtaining a second pixel point number of the multiplexed picture in a second preset dimension;

[0103] generate the picture size according to the first pixel point quantity and the second pixel point quantity.

[0104] The module log library stores all module operations of the preset module.

[0105] The first pixel point quantity in the first preset dimension and the second pixel point quantity in the second preset dimension of the multiplexed picture can accurately quantify the picture size.

[0106] In at least one embodiment of the present application, the electronic device creates a set size according to the picture size, including:

[0107] Obtain the maximum size and the minimum size in the picture size;

[0108] The maximum size is size-limited based on a preset interval until the size obtained after the size-limiting processing is less than or equal to the minimum size, and the set size is obtained.

[0109] The preset interval can be set according to actual needs.

[0110] The size-limiting processing of the maximum size based on the preset interval can avoid the memory occupation being too large due to storing a large number of pictures corresponding to the maximum size in the secondary memory unit. The size-limiting processing of the maximum size based on the minimum size can avoid the waste of memory caused by the set size being unable to be multiplexed.

[0111] S15, based on the multiplexing times of each set size and the multiplexing rate of each set size, the capacity of the secondary memory unit is divided to obtain the size memory unit of each set size.

[0112] It should be emphasized that, in order to further ensure the privacy and security of the above-mentioned multiplexing times and the above-mentioned multiplexing rate, the above-mentioned multiplexing times and the above-mentioned multiplexing rate can also be stored in a node of a block chain.

[0113] In at least one embodiment of the present application, the multiplexing times refer to the number of times the picture corresponding to the multiplexing size is obtained by the preset module.

[0114] The multiplexing rate refers to the ratio of the product of the set capacity occupied by the set size and the multiplexing times to the size occupation capacity of the initial memory unit obtained by dividing the capacity of the secondary memory unit based on the multiplexing times.

[0115] The size memory unit of each set size refers to the initial memory unit corresponding to the multiplexing rate of each set size after capacity adjustment of a plurality of initial memory units to a preset interval threshold.

[0116] In at least one embodiment of the present application, the electronic device divides the capacity of the secondary memory unit according to the multiplexing number of each set size and the multiplexing rate of each set size, to obtain a size memory unit of each set size, including:

[0117] Obtaining the multiplexing size of each multiplexing picture from the set size;

[0118] Counting the multiplexing number of each set size based on the number of times of obtaining the multiplexing size;

[0119] Dividing the capacity of the secondary memory unit according to the multiplexing number of each set size, to obtain an initial memory unit of each set size;

[0120] Calculating the product of the set capacity occupied by each set size and the multiplexing number, to obtain a multiplexing capacity, and calculating the ratio of each multiplexing capacity to the size-occupied capacity of the initial memory unit, to obtain the multiplexing rate of each set size;

[0121] Adjusting the capacity of a plurality of initial memory units according to the multiplexing rate, until the multiplexing rate of each set size is within a preset interval threshold, to obtain a size memory unit of each set size.

[0122] Wherein, the greater the multiplexing number, the greater the size-occupied capacity of the initial memory unit of the corresponding set size, and vice versa.

[0123] The set capacity occupied by each set size refers to the memory-occupied capacity of the image corresponding to the set size.

[0124] The preset interval threshold is set according to actual needs.

[0125] By dividing the capacity of the secondary memory unit according to the multiplexing number of each set size, the initial memory unit of each set size can be quickly obtained, and then adjusting the capacity of a plurality of initial memory units in combination with the multiplexing rate and the preset interval threshold, not only can avoid the case that the secondary memory unit has no spare pictures matching the read pictures due to the excessively high multiplexing rate, but also can avoid the case that the memory utilization rate of the secondary memory unit is too low due to the excessively low multiplexing rate.

[0126] It can be seen from the above technical solutions that the application can meet the loading of cache pictures under the premise that the occupied capacity of the first adjusted memory unit is minimum by combining the memory usage, the picture loading rate and the picture removal rate to perform capacity reduction processing on the first memory unit, thereby improving the memory utilization. By creating each set size in the second memory unit, not only can the time consumption problem caused by creating pictures be avoided, but also the memory fluctuation problem caused by memory opening can be avoided, and then the capacity of the second memory unit is divided by combining the reuse times of each set size and the reuse rate of each set size, so that a large number of unmatched sizes in the second memory unit can be avoided, thereby improving the memory utilization.

[0127] As Figure 2 shown is a functional module diagram of a preferred embodiment of the memory allocation device. The memory allocation device 11 includes an identification unit 110, a calculation unit 111, an adjustment unit 112, a creation unit 113 and a division unit 114. The module / unit referred to by the application refers to a series of computer readable instruction segments that can be acquired by the processor 13 and can complete a fixed function, which is stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0128] When receiving a memory allocation request, the identification unit 110 identifies the first memory unit and the second memory unit based on the memory allocation request.

[0129] In at least one embodiment of the application, the memory allocation request carries the name corresponding to the space that needs to be allocated.

[0130] The first memory unit is used to store cache pictures that are not displayed temporarily. By storing cache pictures in the first memory unit, the corresponding pictures can be directly obtained from the first memory unit for subsequent caching, avoiding reloading and redecoding pictures from files, thereby speeding up the display.

[0131] The pictures stored in the second memory unit are pictures removed from the first memory unit. That is, if the first memory unit is full, the least recently used pictures will be removed to the second memory unit.

[0132] In at least one embodiment of the application, the identification unit 110 identifies the first memory unit and the second memory unit based on the memory allocation request, which includes:

[0133] Parsing the request message of the memory allocation request to obtain the data information carried by the request message;

[0134] extract a memory name from the data information, and determine a space corresponding to the memory name as a memory space;

[0135] acquire a remaining space capacity of the memory space;

[0136] calculate a product of a first preset ratio and the remaining space capacity to obtain a first occupied capacity, and calculate a product of a second preset ratio and the remaining space capacity to obtain a second occupied capacity;

[0137] extract a continuous address space from the memory space as the first-level memory unit based on the first occupied capacity, and extract a continuous address space from the memory space as the second-level memory unit based on the second occupied capacity.

[0138] The remaining space capacity refers to a usable capacity of the memory space.

[0139] The first preset ratio and the second preset ratio are ratios set according to actual needs, and the first preset ratio is greater than the second preset ratio.

[0140] The first preset ratio and the second preset ratio are used to select the first-level memory unit and the second-level memory unit from the memory space, which can improve the capacity rationality of the first-level memory unit and the second-level memory unit, and then extract a continuous address space as the first-level memory unit and the second-level memory unit, which can avoid the first-level memory unit and the second-level memory unit from being discontinuous and causing the first-level memory unit and the second-level memory unit to be unable to continuously store data.

[0141] The calculation unit 111 calculates a memory usage rate of the first-level memory unit based on the first occupied capacity of the first-level memory unit.

[0142] It should be emphasized that, in order to further ensure the privacy and security of the memory usage rate, the memory usage rate can also be stored in a node of a block chain.

[0143] In at least one embodiment of the present application, the first occupied capacity refers to a memory size of the first-level memory unit.

[0144] The memory usage rate refers to a ratio of a data occupied capacity of the first-level memory unit to the first occupied capacity. For example, the first-level memory unit stores an A database, the data occupied capacity of the A database is 3M, and the first occupied capacity is 10M, so the memory usage rate is 0.3.

[0145] The computing unit 111 calculates a picture loading rate of the primary memory unit based on the loaded images of the primary memory unit, and calculates a picture removal rate of the primary memory unit based on the removed images of the primary memory unit.

[0146] It is emphasized that, in order to further ensure the privacy and security of the picture loading rate and the picture removal rate, the picture loading rate and the picture removal rate can also be stored in a node of a block chain.

[0147] In at least one embodiment of the present application, the loaded images refer to cached pictures that are re-displayed in the primary memory unit.

[0148] The picture loading rate refers to a ratio of the number of pictures of the cached pictures that are re-displayed in the primary memory unit to the total number of images of all images in the primary memory unit.

[0149] The removed images refer to images transferred from the primary memory unit to the secondary memory unit.

[0150] The picture removal rate refers to a ratio of the number of the removed images to the total number of images.

[0151] In at least one embodiment of the present application, the computing unit 111 calculates the picture removal rate of the primary memory unit based on the removed images of the primary memory unit, comprising:

[0152] Obtaining images transferred from the primary memory unit to the secondary memory unit as the removed images;

[0153] Counting the total number of images of all images in the primary memory unit;

[0154] Calculating a ratio of the number of the removed images to the total number of images to obtain the picture removal rate.

[0155] Through the above embodiment, the picture removal rate can be accurately determined.

[0156] The adjusting unit 112 performs capacity adjustment processing on the primary memory unit according to the memory usage rate, the picture loading rate and the picture removal rate to obtain a primary adjusted memory unit.

[0157] In at least one embodiment of the present application, the primary adjusted memory unit is a primary memory unit after capacity adjustment of the primary memory unit to a primary memory unit corresponding to a situation in which the memory utilization rate of the primary memory unit no longer increases.

[0158] In at least one embodiment of the present application, the adjusting unit 112 performs capacity adjustment processing on the primary memory unit according to the memory usage rate, the picture loading rate and the picture removal rate, to obtain a primary adjusted memory unit including:

[0159] A first set weight value of the memory usage rate, a second set weight value of the picture loading rate and a third set weight value of the picture removal rate are obtained, and the first set weight value is greater than the second set weight value, which is greater than the third set weight value;

[0160] The memory usage rate, the picture loading rate and the picture removal rate are weighted and calculated based on the first set weight value, the second set weight value and the third set weight value, to obtain a memory utilization rate of the primary memory unit;

[0161] The capacity of the primary memory unit is reduced based on the memory utilization rate of the primary memory unit and a preset adjustment range, until the memory utilization rate of the primary memory unit no longer increases, to obtain the primary adjusted memory unit.

[0162] The preset adjustment range is determined according to the capacity adjustment accuracy of the primary memory unit, for example, the preset adjustment range can be 500kb.

[0163] By setting the first set weight value greater than the second set weight value, which is greater than the third set weight value, the calculation accuracy of the memory utilization rate of the primary memory unit can be improved. By reducing the capacity of the primary memory unit based on the preset adjustment range, since the preset adjustment range is set within a reasonable range, the capacity adjustment accuracy of the primary memory unit can be improved under the premise of ensuring the capacity adjustment efficiency of the primary memory unit, so as to ensure the memory utilization rate of the primary memory unit.

[0164] The creating unit 113 identifies the picture size of the multiplexed picture in the secondary memory unit, and creates a set size according to the picture size.

[0165] In at least one embodiment of the present application, the multiplexed picture refers to a read picture of a preset module, and does not correspond to all images in the primary memory unit. The preset module can be an application program of a terminal device corresponding to the memory space.

[0166] The set size refers to a size that can load the multiplexed picture, and the set size is greater than or equal to the picture size of the multiplexed picture. For example, if the picture size of the multiplexed picture is 4*4, the corresponding set size can be 4*4 or 5*5, etc.

[0167] In at least one embodiment of the present application, the creating unit 113 identifies the picture size of the multiplexed picture in the secondary memory unit comprises:

[0168] The reading picture is obtained from the module log library of the preset module, and the picture not corresponding to all images in the primary memory unit is selected from the reading picture as the multiplexed picture;

[0169] The first pixel point number of the multiplexed picture in the first preset dimension is obtained, and the second pixel point number of the multiplexed picture in the second preset dimension is obtained;

[0170] The picture size is generated according to the first pixel point number and the second pixel point number.

[0171] The module log library stores all module operations of the preset module.

[0172] The first pixel point number of the multiplexed picture in the first preset dimension and the second pixel point number in the second preset dimension can accurately quantify the picture size.

[0173] In at least one embodiment of the present application, the creating unit 113 creates a set size according to the picture size comprises:

[0174] The maximum size and the minimum size in the picture size are obtained;

[0175] The maximum size is size-limited based on a preset interval until the size obtained after the size-limiting processing is less than or equal to the minimum size, and the set size is obtained.

[0176] The preset interval can be set according to actual needs.

[0177] The size-limiting processing of the maximum size based on the preset interval can avoid the secondary memory unit from occupying too much memory due to storing a large number of pictures corresponding to the maximum size. The size-limiting processing of the maximum size based on the minimum size can avoid the waste of memory caused by the set size being unable to be multiplexed.

[0178] The partition unit 114 divides the capacity of the secondary memory unit based on the multiplexing number of each set size and the multiplexing rate of each set size, and obtains the size memory unit of each set size.

[0179] It should be emphasized that, in order to further ensure the privacy and security of the above multiplexing number and the above multiplexing rate, the above multiplexing number and the above multiplexing rate can also be stored in a node of a block chain.

[0180] In at least one embodiment of the present application, the multiplexing times refer to the number of times that the multiplexing size corresponding to the picture is acquired by the preset module.

[0181] The multiplexing rate refers to the ratio of the product of the set size and the multiplexing times to the size occupied capacity of the initial memory unit obtained by capacity division of the secondary memory unit based on the multiplexing times.

[0182] The size memory unit of each set size refers to the initial memory unit corresponding to the capacity adjustment of the plurality of initial memory units to the multiplexing rate of each set size being in the preset interval threshold.

[0183] In at least one embodiment of the present application, the division unit 114 performs capacity division on the secondary memory unit based on the multiplexing times of each set size and the multiplexing rate of each set size to obtain the size memory unit of each set size, including:

[0184] Obtaining the multiplexing size of each multiplexing picture from the set size;

[0185] Counting the multiplexing times of each set size based on the number of times of obtaining the multiplexing size;

[0186] Capacity division of the secondary memory unit according to the multiplexing times of each set size to obtain the initial memory unit of each set size;

[0187] Calculating the product of the set capacity occupied by each set size and the multiplexing times to obtain the multiplexing capacity, and calculating the ratio of each multiplexing capacity to the size occupied capacity of the initial memory unit to obtain the multiplexing rate of each set size;

[0188] Capacity adjustment of the plurality of initial memory units according to the multiplexing rate until the multiplexing rate of each set size is in the preset interval threshold to obtain the size memory unit of each set size.

[0189] Wherein, the greater the multiplexing times, the greater the size occupied capacity of the initial memory unit of the corresponding set size, and vice versa.

[0190] The set capacity occupied by each set size refers to the memory occupied capacity of the image corresponding to the set size.

[0191] The preset interval threshold is set according to actual needs.

[0192] By capacity division of the secondary memory unit according to the multiplexing times of each set size, the initial memory unit of each set size can be quickly obtained, and then capacity adjustment is performed on the initial memory units in combination with the multiplexing rate and the preset interval threshold, which can not only avoid the case that there is no redundant picture matching the read picture in the secondary memory unit due to the excessively high multiplexing rate, but also avoid the case that the memory utilization rate of the secondary memory unit is excessively low due to the excessively low multiplexing rate.

[0193] As can be seen from the above technical solutions, by capacity reduction processing of the primary memory unit in combination with the memory usage rate, the picture loading rate and the picture removal rate, the loading of the cached pictures can be met on the premise that the occupied capacity of the primary adjusted memory unit is minimum, so as to improve the memory utilization rate. By creating each set size in the secondary memory unit, not only the time consumption problem caused by the creation of pictures can be avoided, but also the memory fluctuation problem caused by the memory opening can be avoided, and then capacity division of the secondary memory unit is performed in combination with the multiplexing times of each set size and the multiplexing rate of each set size, which can avoid a large number of unmatched sizes in the secondary memory unit, so as to improve the memory utilization rate.

[0194] As Figure 3 shown is a structure schematic diagram of an electronic device of a preferred embodiment of the memory allocation method of the present application.

[0195] In an embodiment of the present application, 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 memory allocation program.

[0196] Those skilled in the art can understand that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation on the electronic device 1, and can include more or fewer components than the diagram, or combine certain components, or different components, for example, the electronic device 1 can also include an input / output device, a network access device, a bus, etc.

[0197] The processor 13 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, or the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The processor 13 is the operation core and control center of the electronic device 1, and connects various parts of the electronic device 1 through various interfaces and lines, and executes the operating system and installed various application programs, program codes, and the like of the electronic device 1.

[0198] For example, the computer readable instructions can be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units can be a series of computer readable instruction segments capable of completing a specific function, which are used to describe the execution process of the computer readable instructions in the electronic device 1. For example, the computer readable instructions can be divided into an identifying unit 110, a calculating unit 111, an adjusting unit 112, a creating unit 113, and a dividing unit 114.

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

[0200] The memory 12 can be an external memory and / or an internal memory of the electronic device 1. Further, the memory 12 can be a memory having a physical form, such as a memory stick, a TF card (Trans-flash Card), and the like.

[0201] The modules / units integrated in the electronic device 1, if implemented in the form of software functional units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be implemented by computer readable instructions instructing related hardware to complete, and the computer readable instructions can be stored in a computer readable storage medium. When the computer readable instructions are executed by a processor, the steps of the above-mentioned various method embodiments can be implemented.

[0202] The computer readable instructions include computer readable instruction codes, which can be in the form of source code, object code, executable files, or some intermediate forms, etc. The computer readable medium can include any entity or device capable of carrying the computer readable instruction codes, recording media, U disks, mobile hard disks, magnetic disks, optical disks, computer memories, read-only memories (ROMs), random access memories (RAMs).

[0203] The blockchain referred to in the present application is a new application mode of distributed memory allocation, peer-to-peer transmission, consensus mechanism, encryption algorithm, and other computer technologies. Blockchain, in essence, is a decentralized database, which is a series of data blocks associated using cryptographic methods, each data block containing information of a batch of network transactions, for verifying the validity (anti-fake) of the information and generating the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer, etc.

[0204] In combination with Figure 1 The memory 12 in the electronic device 1 stores computer readable instructions to implement a memory allocation method, and the processor 13 can execute the computer readable instructions to implement:

[0205] When receiving a memory allocation request, identifying a first memory unit and a second memory unit based on the memory allocation request;

[0206] Calculating a memory usage rate of the first memory unit based on a first occupied capacity of the first memory unit;

[0207] calculate a picture loading rate of the primary memory unit based on the loaded images of the primary memory unit, and calculate a picture removing rate of the primary memory unit based on the removed images of the primary memory unit;

[0208] perform capacity adjustment processing on the primary memory unit according to the memory usage rate, the picture loading rate, and the picture removing rate, to obtain a primary adjusted memory unit;

[0209] identify picture sizes of the multiplexed pictures in the secondary memory unit, and create set sizes according to the picture sizes;

[0210] perform capacity division on the secondary memory unit based on the multiplexing times of each set size and the multiplexing rate of each set size, to obtain a size memory unit of each set size.

[0211] Specifically, the specific implementation method of the processor 13 to the above computer readable instructions can refer to Figure 1 The description of related steps in the corresponding embodiments will not be repeated here.

[0212] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the above-described device embodiments are only schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner.

[0213] The computer readable storage medium stores computer readable instructions, wherein the computer readable instructions are executed by the processor 13 to implement the following steps:

[0214] When receiving a memory allocation request, identify a primary memory unit and a secondary memory unit based on the memory allocation request;

[0215] calculate a memory usage rate of the primary memory unit based on the first occupied capacity of the primary memory unit;

[0216] calculate a picture loading rate of the primary memory unit based on the loaded images of the primary memory unit, and calculate a picture removing rate of the primary memory unit based on the removed images of the primary memory unit;

[0217] perform capacity adjustment processing on the primary memory unit according to the memory usage rate, the picture loading rate, and the picture removing rate, to obtain a primary adjusted memory unit;

[0218] identify picture sizes of the multiplexed pictures in the secondary memory unit, and create set sizes according to the picture sizes;

[0219] Based on the multiplexing number of each set size and the multiplexing rate of each set size, the secondary memory unit is capacity divided to obtain a size memory unit of each set size.

[0220] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, i.e., they may be located in one place or distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0221] In addition, each functional module in various embodiments of the application can be integrated in one processing unit, or each unit can exist physically independently, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware, or in the form of hardware plus software functional module.

[0222] Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting, and the scope of the application is defined by the appended claims rather than the above description, and therefore all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the application. Any additional reference signs in the claims should not be considered as limiting the claims involved.

[0223] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices described can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and not any particular order.

[0224] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the application and not to limit it, and although the application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the application can be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the application.

Claims

1. A memory allocation method, characterized in that, The memory allocation method includes: When a memory allocation request is received, the primary memory unit and the secondary memory unit are identified based on the memory allocation request; The memory utilization rate of the first-level memory unit is calculated based on the first occupied capacity of the first-level memory unit, where the first occupied capacity refers to the memory size of the first-level memory unit; The image loading rate of the first-level memory unit is calculated based on the loaded image of the first-level memory unit, and the image removal rate of the first-level memory unit is calculated based on the removed image of the first-level memory unit. The loaded image refers to the cached image that is re-displayed in the first-level memory unit, and the removed image refers to the image that is transferred from the first-level memory unit to the second-level memory unit. The capacity of the first-level memory unit is adjusted based on the memory usage rate, the image loading rate, and the image removal rate to obtain an adjusted first-level memory unit. This includes: obtaining a first set weight for the memory usage rate, a second set weight for the image loading rate, and a third set weight for the image removal rate, wherein the first set weight is greater than the second set weight, and the second set weight is greater than the third set weight; performing a weighted sum operation on the memory usage rate, the image loading rate, and the image removal rate based on the first set weight, the second set weight, and the third set weight to obtain the memory utilization rate of the first-level memory unit; and performing capacity reduction processing on the first-level memory unit based on the memory utilization rate and a preset adjustment range until the memory utilization rate of the first-level memory unit no longer increases, thus obtaining the adjusted first-level memory unit. Identifying the image size of the reused image in the secondary memory unit and creating a set size based on the image size includes: obtaining the maximum and minimum size among the image sizes; performing size reduction processing on the maximum size based on a preset interval until the size obtained after size reduction processing is less than or equal to the minimum size, thereby obtaining the set size. The reused image refers to the image read by the preset module and is not corresponding to any image in the primary memory unit. The secondary memory units are divided into capacity based on the reuse count and reuse rate of each set size to obtain a size memory unit for each set size. This includes: obtaining the reuse size of each reused image from the set size; counting the reuse count of each set size based on the number of times the reuse size is obtained; dividing the capacity of the secondary memory units according to the reuse count of each set size to obtain an initial memory unit for each set size; calculating the product of the set capacity occupied by each set size and the reuse count to obtain the reuse capacity, and calculating the ratio of each reuse capacity to the size-occupied capacity of the initial memory unit to obtain the reuse rate of each set size; adjusting the capacity of multiple initial memory units according to the reuse rate until the reuse rate of each set size is within a preset threshold range to obtain a size memory unit for each set size.

2. The memory allocation method as described in claim 1, characterized in that, The step of identifying primary and secondary memory units based on the memory allocation request includes: Parse the memory allocation request message to obtain the data information carried by the request message; Extract the memory name from the data information, and determine the space corresponding to the memory name as the memory space; Obtain the remaining space capacity of the memory space; Calculate the product of the first preset ratio and the remaining space capacity to obtain the first occupied capacity, and calculate the product of the second preset ratio and the remaining space capacity to obtain the second occupied capacity; Based on the first occupied capacity, a contiguous address space is extracted from the memory space as the first-level memory unit, and based on the second occupied capacity, a contiguous address space is extracted from the memory space as the second-level memory unit.

3. The memory allocation method as described in claim 1, characterized in that, The calculation of the image removal rate of the first-level memory unit based on the removed images of the first-level memory unit includes: The image transferred from the first-level memory unit to the second-level memory unit is used as the removed image; Calculate the total number of images in the first-level memory unit; The image removal rate is obtained by calculating the ratio of the number of removed images to the total number of images.

4. The memory allocation method as described in claim 1, characterized in that, The image size for identifying the reused image in the secondary memory unit includes: The image is retrieved from the module log library of the preset module, and the image that does not correspond to any of the images in the first-level memory unit is selected from the retrieved images as the reused image; Obtain the number of first pixels in the reused image in a first preset dimension, and obtain the number of second pixels in the reused image in a second preset dimension; The image size is generated based on the number of the first pixel and the number of the second pixel.

5. A memory allocation device, characterized in that, The memory allocation device includes: The identification unit is used to identify primary memory units and secondary memory units based on the memory allocation request when a memory allocation request is received. A computing unit is used to calculate the memory utilization rate of the first-level memory unit based on the first occupied capacity of the first-level memory unit, wherein the first occupied capacity refers to the memory size of the first-level memory unit; The computing unit is also used to calculate the image loading rate of the first-level memory unit based on the loaded image of the first-level memory unit, and to calculate the image removal rate of the first-level memory unit based on the removed image of the first-level memory unit. The loaded image refers to the cached image that is re-displayed in the first-level memory unit, and the removed image refers to the image that is transferred from the first-level memory unit to the second-level memory unit. An adjustment unit is configured to adjust the capacity of the primary memory unit based on the memory usage rate, the image loading rate, and the image removal rate to obtain an adjusted primary memory unit. The adjustment includes: obtaining a first set weight for the memory usage rate, a second set weight for the image loading rate, and a third set weight for the image removal rate, wherein the first set weight is greater than the second set weight, and the second set weight is greater than the third set weight; performing a weighted sum operation on the memory usage rate, the image loading rate, and the image removal rate based on the first set weight, the second set weight, and the third set weight to obtain the memory utilization rate of the primary memory unit; and performing capacity reduction processing on the primary memory unit based on the memory utilization rate and a preset adjustment range until the memory utilization rate of the primary memory unit no longer increases, thus obtaining the adjusted primary memory unit. A creation unit is used to identify the image size of the reused image in the secondary memory unit and create a set size according to the image size, including: obtaining the maximum size and minimum size among the image sizes; performing size reduction processing on the maximum size based on a preset interval until the size obtained after size reduction processing is less than or equal to the minimum size, thereby obtaining the set size, wherein the reused image refers to the image read by the preset module and is not corresponding to any image in the primary memory unit; A partitioning unit is used to partition the capacity of the secondary memory units based on the reuse count and reuse rate of each set size to obtain a size memory unit for each set size. The partitioning includes: obtaining the reuse size of each reused image from the set sizes; counting the reuse count of each set size based on the number of times the reuse size is obtained; partitioning the capacity of the secondary memory units according to the reuse count of each set size to obtain an initial memory unit for each set size; calculating the product of the set capacity occupied by each set size and the reuse count to obtain the reuse capacity, and calculating the ratio of each reuse capacity to the size-occupied capacity of the initial memory unit to obtain the reuse rate of each set size; adjusting the capacity of multiple initial memory units according to the reuse rate until the reuse rate of each set size is within a preset threshold range to obtain a size memory unit for each set size.

6. 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 memory allocation method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions that are executed by a processor in an electronic device to implement the memory allocation method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Image data caching method

    CN106802955A

  • Image caching and using method and device and terminal

    CN109685712A