Memory allocation method and device, electronic equipment and storage medium

By dynamically matching the algorithm complexity and memory type performance level of data processing tasks, the problem of unreasonable memory resource allocation is solved, efficient memory resource utilization is achieved, and task execution efficiency and system stability are improved.

CN121255451APending Publication Date: 2026-01-02ANHUI RONDS SCI & TECH INC CO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511396156.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-28
Publication Date
2026-01-02

AI Technical Summary

Technical Problem

Existing technologies lack mature memory scheduling strategies, making it impossible to reasonably match memory types according to algorithm requirements, resulting in resource waste or performance degradation.

Method used

By acquiring the algorithm complexity and pre-allocated memory size of the data processing task, the target memory type is dynamically matched, and when memory is insufficient, it is reallocated according to the algorithm complexity relationship between tasks. Combined with the preset memory type threshold and task priority sorting mechanism, the allocation of memory resources is optimized.

Benefits of technology

It improves the utilization efficiency of memory resources, avoids resource waste and performance bottlenecks, and is particularly suitable for scenarios with strict real-time requirements, such as health diagnosis of industrial equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121255451A_ABST
    Figure CN121255451A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a memory allocation method and device, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps of obtaining algorithm complexity of a current data processing task and a pre-applied memory size, determining a target memory type used for executing the current data processing task according to a matching relation between the algorithm complexity and a preset memory type threshold value, and executing the current data processing task if residual memory space of the target memory type is larger than or equal to the pre-applied memory size. And if not, allocating the target memory type to the current data processing task. Therefore, in the execution process of the data processing task, the memory type required by the data processing task can be dynamically adapted, the performance advantages of different types of memories are fully played, and the task execution efficiency is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and more specifically, to a memory allocation method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the increasing number of equipment required in industrial production, equipment health diagnostic services are currently used to monitor industrial equipment. As technology advances, the amount of data that these services need to process is growing, placing higher demands on the performance of data acquisition equipment. For example, data acquisition equipment needs to be able to complete large-scale data processing and analysis within seconds and provide equipment health diagnostic results. Currently, some data acquisition devices integrate multiple memory types (such as Tightly Coupled Memory (TCM), Random Access Memory (RAM), and Pseudo Static Random Access Memory (PSRAM)), each with different performance characteristics (such as access speed, capacity, and cost).

[0003] However, the lack of mature memory scheduling strategies in related technologies makes it impossible to reasonably match memory types according to algorithm requirements, resulting in resource waste or performance degradation. Summary of the Invention

[0004] In view of this, the object of the present invention is to provide a memory allocation method, apparatus, electronic device and storage medium to at least partially improve the above-mentioned problems.

[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: In a first aspect, embodiments of the present invention provide a memory allocation method, including: Obtain the algorithm complexity and pre-allocated memory size of the current data processing task; the pre-allocated memory size represents the memory capacity required to execute the current data processing task. Based on the matching relationship between the algorithm complexity and the preset memory type threshold, the target memory type for executing the current data processing task is determined; If the remaining memory space of the target memory type is greater than or equal to the pre-allocated memory size, then the target memory type is allocated to the current data processing task.

[0006] Optionally, the method further includes: If the remaining memory space of the target memory type is less than the pre-allocated memory size, then based on the relationship between the algorithm complexity of the current data processing task and the algorithm complexity of other tasks that have occupied the target memory type, a decision is made on whether to reallocate the other tasks to the next priority memory type.

[0007] Optionally, deciding whether to reallocate the other tasks to a lower priority memory type based on the relationship between the algorithm complexity of the current data processing task and the algorithm complexity of other tasks already occupying the target memory type includes: Determine whether the algorithm complexity of the current data processing task is greater than the algorithm complexity of the other tasks; If so, the other tasks are reassigned to the next priority memory type to free up space in the target memory type, and the target memory type is allocated to the current data processing task; If not, the current data processing task is assigned to the next priority memory type.

[0008] Optionally, deciding whether to reallocate the other tasks to a lower priority memory type based on the relationship between the algorithm complexity of the current data processing task and the algorithm complexity of other tasks already occupying the target memory type includes: Determine whether the algorithm complexity of the current data processing task satisfies a preset relationship with the algorithm complexity of other tasks; If so, the other tasks are reassigned to the next priority memory type to free up space in the target memory type, and the target memory type is allocated to the current data processing task; If not, the current data processing task is assigned to the next priority memory type.

[0009] Optionally, the algorithm complexity includes both time complexity and space complexity. The time complexity of the algorithm is determined by the number of lines of code, loop complexity, and halogen complexity of the current data processing task. The space complexity of the algorithm is determined by the frequency of memory usage, actual scope, and data stability of the current data processing task.

[0010] Optionally, the memory type includes tightly coupled memory, random access memory, and pseudo-static random access memory; the preset memory type threshold includes a tightly coupled memory threshold and a random access memory threshold. Wherein, the tightly coupled memory threshold is greater than the random access memory threshold.

[0011] Optionally, the method further includes: When there are multiple data processing tasks to be processed, calculate the ratio of the algorithm complexity of each data processing task to the pre-allocated memory size. Based on the ratio, the priority order of each data processing task to be processed is determined, and memory allocation is performed for each data processing task to be processed in turn according to the priority order.

[0012] Secondly, embodiments of the present invention provide a memory allocation device, comprising: The data acquisition unit is used to acquire the algorithm complexity and pre-allocated memory size of the current data processing task; the pre-allocated memory size represents the memory capacity required to execute the current data processing task. The target memory type determination unit is used to determine the target memory type for executing the current data processing task based on the matching relationship between the algorithm complexity and the preset memory type threshold. A target memory type allocation unit is used to allocate the target memory type to the current data processing task if the remaining memory space of the target memory type is greater than or equal to the pre-allocated memory size.

[0013] Thirdly, embodiments of the present invention provide an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the method described in any of the above-mentioned embodiments.

[0014] Fourthly, embodiments of the present invention provide a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in any of the preceding claims.

[0015] The present invention provides a memory allocation method, apparatus, electronic device and storage medium that intelligently determines and allocates the most suitable target memory type by matching the algorithm complexity of the data processing task with a preset memory type threshold. This enables the task to make full use of the access advantages of high-performance memory, improves execution efficiency while meeting memory requirements, and effectively avoids the waste of memory resources or performance bottlenecks.

[0016] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A schematic structural block diagram of an electronic device provided in an embodiment of the present invention; Figure 2 A flowchart illustrating a memory allocation method provided in an embodiment of the present invention; Figure 3 This is another flowchart illustrating a memory allocation method provided in an embodiment of the present invention; Figure 4 A flowchart illustrating step S240 provided in an embodiment of the present invention; Figure 5 Another flowchart illustrating step S240 provided in an embodiment of the present invention; Figure 6 This is another flowchart illustrating a memory allocation method provided in an embodiment of the present invention; Figure 7 This is a schematic structural block diagram of a memory allocation device provided in an embodiment of the present invention.

[0019] Icons: 100-Electronic device; 101-Memory; 102-Communication interface; 103-Processor; 104-Communication bus; 300-Memory allocation device; 310-Data acquisition unit; 320-Target memory type determination unit; 330-Target memory type allocation unit. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0021] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0022] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0023] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0024] With the increasing number of industrial equipment and the growing complexity of production, traditional manual equipment inspection and maintenance methods are no longer sufficient to meet the demands for high efficiency and real-time performance, spurring the development of equipment health diagnostic services. This service collects equipment operating data and performs intelligent analysis to achieve real-time monitoring of equipment status and fault early warning. In recent years, with the increasing complexity of health diagnostic technologies and the surge in data processing volume, higher demands have been placed on the performance of data acquisition equipment, especially the need to complete large-scale data analysis within seconds. To address this, some equipment has introduced multiple memory types (such as TCM, RAM, and PSRAM) to balance speed, capacity, and cost. However, the current lack of a mature memory scheduling mechanism makes it impossible to rationally match memory resources according to algorithm requirements, resulting in underutilization of memory performance and issues such as resource waste or performance bottlenecks.

[0025] Based on the above, embodiments of the present invention provide a memory allocation method, apparatus, electronic device, and storage medium that can dynamically adapt to the required memory type during the execution of data processing tasks, fully leverage the performance advantages of different types of memory, and improve task execution efficiency.

[0026] To implement the process steps and functions of the various examples of this invention, please refer to [link / reference]. Figure 1 , Figure 1This is a schematic structural block diagram of an electronic device provided in an embodiment of the present invention. The electronic device 100 includes a memory 101 and a processor 103, which are electrically connected directly or indirectly to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 104 or signal lines. The memory 101 can be used to store software programs and modules, and the processor 103 executes the software programs and modules stored in the memory 101, thereby performing various functional applications and data processing.

[0027] Electronic device 100 can be, but is not limited to, a personal computer (PC), a server, a distributed computer, etc. It is understood that electronic device 100 is not limited to a physical server, but can also be a virtual machine on a physical server, a virtual machine built on a cloud platform, or any other computer that can provide the same functionality as the server or virtual machine. The operating system of electronic device 100 can be, but is not limited to, Windows, Linux, etc.

[0028] The memory 101 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0029] The communication connection between the electronic device 100 and external devices is achieved through at least one communication interface 102 (which can be wired or wireless).

[0030] Processor 103 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of this embodiment can be completed by integrated logic circuits in the hardware of processor 103 or by instructions in software form. Processor 103 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0031] Understandable. Figure 1 The structure shown is for illustrative purposes only; the electronic device 100 may also include components that are more advanced than those shown. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0032] The memory allocation method provided by this invention will be described below by way of example. See also Figure 2 The subject executing this method can be one of the above. Figure 1 The electronic device 100 shown, the method includes as follows Figure 2 The following steps are described: S210: Obtain the algorithm complexity and pre-allocated memory size of the current data processing task. The pre-allocated memory size represents the memory capacity required to execute the current data processing task.

[0033] S220: Determine the target memory type for executing the current data processing task based on the matching relationship between the algorithm complexity and the preset memory type threshold.

[0034] S230: If the remaining memory space of the target memory type is greater than or equal to the pre-allocated memory size, then allocate the target memory type to the current data processing task.

[0035] This invention uses an industrial equipment health diagnosis system as an example for illustration. The data acquisition device in the system includes various memory types. For instance, when the data acquisition device needs to process a device anomaly identification task, this task requires running a vibration signal analysis algorithm based on wavelet transform to identify whether the device has early-stage faults. This task is the current data processing task. Before the task begins, the algorithm complexity of the task is automatically analyzed, and the required memory is estimated. After obtaining the algorithm complexity and the pre-allocated memory size, the "algorithm complexity" of the task is calculated and matched with the "performance level" of different memory types to select the most suitable target memory type for the task. Then, it is checked whether there is enough remaining space for this type of memory to accommodate the task. If there is enough space, the memory is officially allocated to the task. If there is not enough space, the next level of memory can be allocated to the task.

[0036] This method achieves intelligent allocation of memory resources by dynamically matching the algorithm complexity of data processing tasks with the performance level of memory types, thereby improving task execution efficiency and optimizing memory utilization.

[0037] Algorithm complexity can include both time complexity and space complexity.

[0038] The time complexity of the algorithm is determined by the number of lines of code, loop complexity, and halogen complexity of the current data processing task.

[0039] The space complexity of an algorithm is determined by the frequency of memory usage, actual scope, and data stability of the current data processing task.

[0040] Algorithm complexity is quantified and evaluated along two dimensions: time complexity and space complexity. Algorithm complexity can be expressed by the following formula:

[0041] in This represents the algorithm's complexity; a larger value indicates a higher algorithm complexity, and vice versa. Indicates the time complexity of the algorithm. The factor representing the impact of time complexity. Indicates the space complexity of the algorithm. The coefficient representing the impact of space complexity.

[0042] Algorithm time complexity measures the resource consumption of an algorithm during execution, reflecting the computational intensity of the task. Evaluation of algorithm time complexity includes the number of lines of code, loop complexity, and halogen complexity of the current data processing task.

[0043] Lines of code: The total number of lines of program code. As a basic indicator of task scale, the more lines of code, the higher the time complexity of the algorithm is considered to be, and vice versa.

[0044] Loop complexity: measures the complexity of control flow in a program, especially reflecting the number of conditional branches and loop structures, indirectly indicating the number and uncertainty of the algorithm's execution paths. The more branches an algorithm has, the higher its time complexity, and vice versa.

[0045] Halogen complexity: Calculated based on the number and frequency of operators and operands in a program, reflecting the program's structural complexity and development difficulty. A higher number of operators and operands results in higher time complexity, and vice versa.

[0046] The time complexity of the algorithm can be expressed by the following formula:

[0047] in This represents the time complexity of the algorithm; the larger the value, the greater the time complexity of the algorithm. Indicates the number of lines of code. The influence coefficient representing the number of lines of code. Indicates the loop complexity. The coefficient representing the impact of loop complexity. Indicates halogen complexity, The coefficient representing the influence of halogen complexity.

[0048] Algorithm space complexity measures the resource consumption of an algorithm in terms of memory usage, reflecting the intensity of the task's memory requirements. Algorithm space complexity is evaluated based on the frequency of memory usage, the actual scope of the data processing task, and data stability.

[0049] Memory usage frequency: The number of times a task uses the requested memory during execution, reflecting the activity level of memory access. The more frequent the memory usage, the higher the space complexity, and vice versa.

[0050] Actual scope: The effective lifespan of memory variables used by a task. A longer scope means a longer period of resource occupation. The longer the actual scope, the higher the space complexity of the algorithm, and vice versa.

[0051] Data stability: Whether the data changes frequently during the task, such as frequent writes and reads, affects the efficiency and stability of memory usage. The more frequently the stored data is modified, the higher the space complexity, and vice versa.

[0052] The space complexity of the algorithm can be expressed by the following formula:

[0053] in This represents the space complexity of the algorithm; the larger the value, the greater the space complexity of the algorithm. Indicates frequency of use. The influence coefficient represents the frequency of use. Indicates the actual scope. Indicates the influence coefficient of the actual scope. Indicates stability. The coefficient representing the influence of stability.

[0054] By breaking down algorithm complexity into time and space complexity and quantifying each from multiple technical dimensions, this invention achieves multi-dimensional modeling of task resource requirements. This comprehensive evaluation method can more accurately reflect the combined pressure of a task in terms of both computation and memory, thereby providing a more scientific and fine-grained decision-making basis for memory type matching and further improving the intelligence and applicability of memory allocation strategies.

[0055] Optionally, the memory types include tightly coupled memory, random access memory, and pseudo-static random access memory; the preset memory type thresholds include tightly coupled memory threshold and random access memory threshold.

[0056] Among them, the tightly coupled memory threshold is greater than the random access memory threshold.

[0057] In this embodiment of the invention, the data acquisition device provides three types of memory: TCM, RAM, and PSRAM. TCM is typically integrated inside the processor, offering extremely fast access speeds and low latency, making it suitable for high real-time, computationally intensive tasks, but it has small capacity and high cost. RAM is general-purpose main memory; compared to TCM, its access performance is lower, but its size is several times that of TCM. PSRAM, compared to RAM, has slightly inferior access performance, but it offers larger storage capacity and lower cost, making it suitable for scenarios with strict cost and capacity requirements.

[0058] The preset memory type thresholds serve as a standard for determining whether a task can be allocated a certain type of memory; essentially, they represent a tiered threshold for algorithm complexity. Tightly coupled memory threshold > Random access memory threshold > Pseudo-static random access memory threshold, meaning that only when a task's algorithm complexity is sufficiently high (exceeding the tightly coupled memory threshold) is it eligible to apply for TCM; medium-complexity tasks can apply for RAM; and low-complexity tasks use PSRAM. In step S220, the matching relationship between algorithm complexity and the preset memory type thresholds can be expressed by the following formula:

[0059] in, Indicates memory type, This indicates the algorithm's complexity.

[0060] When there is insufficient space in the target memory type, memory can be reallocated by considering the relationship between the algorithmic complexity of other tasks already occupying the target memory type and the current data processing task. Therefore, in one optional implementation, see... Figure 3 The method may also include the following steps: S240: If the remaining memory space of the target memory type is less than the pre-allocated memory size, then based on the relationship between the algorithm complexity of the current data processing task and the algorithm complexity of other tasks that have occupied the target memory type, decide whether to reallocate the other tasks to the next priority memory type.

[0061] When allocating a target memory type for the current data processing task, if it is found that the remaining space of that memory type is less than the pre-allocated memory size of the current data processing task, it will not be immediately downgraded to the next priority memory. Instead, it will attempt to free up space for the target memory type by dynamically adjusting the memory allocation of existing tasks.

[0062] Analyze the algorithm complexity relationship between the current task and other tasks occupying the target memory type to decide whether to downgrade the current task to the next lower priority memory or reallocate existing tasks in the target memory type to the next lower priority memory to free up space in the target memory type.

[0063] When there is insufficient remaining memory space for the target memory type, there can be multiple decision-making logics for memory allocation. One possible implementation is to make a decision based on a direct comparison of algorithm complexity; see [link to relevant documentation]. Figure 4 Step S240 may include the following steps: S241: Determine whether the algorithm complexity of the current data processing task is greater than the algorithm complexity of other tasks.

[0064] S242: If so, reallocate other tasks to the next priority memory type to free up space for the target memory type and allocate the target memory type for the current data processing task.

[0065] S243: If not, assign the current data processing task to the next priority memory type.

[0066] Determine if the algorithm complexity of the current task is greater than that of other tasks. If so, migrate other tasks and allocate target memory to the current task; otherwise, demote the previous task to the next priority memory.

[0067] For example, the memory priority order is TCM, RAM, PSRAM, with a tight-coupled memory threshold of 100 and a random access memory threshold of 60. The algorithm complexity of the current task is 110, and the pre-allocated memory size is 100KB. Therefore, the target memory type is TCM, but the remaining space in TCM is less than 100KB. At this point, find another task that is already occupying TCM, and obtain its algorithm complexity. If the algorithm complexity of this other task is 105, then the other task will be moved to RAM, and TCM will be allocated to the current task. If the algorithm complexity of this other task is 115, then the current task will be downgraded and allocated to the next priority RAM. If the RAM space is still insufficient, further judgment is made, which will not be elaborated here.

[0068] In another possible implementation, decisions can be made based on a pre-defined relational formula for algorithm complexity, see [link to relevant documentation]. Figure 5 Step S240 may include the following steps: S241`: Determine whether the algorithm complexity of the current data processing task satisfies a preset relationship with the algorithm complexity of other tasks.

[0069] S242`: If so, reallocate other tasks to the next priority memory type to free up space for the target memory type and allocate the target memory type for the current data processing task.

[0070] S243`: If not, assign the current data processing task to the next priority memory type.

[0071] The preset relation can be:

[0072] in, This represents the algorithmic complexity of the current task. This represents the algorithmic complexity of allocating memory of the same type. , Indicates a constant. For example, It can be 2. This relationship means that if the algorithmic complexity of the current task is greater than the algorithmic complexity of other tasks by a certain value, then other tasks will be reallocated to the next priority memory type to prevent unnecessary reallocation due to a slight advantage.

[0073] This method differs from step S241 in its judgment logic, but the subsequent processing after judgment is the same as steps S242 and S243, which will not be elaborated here.

[0074] This embodiment does not simply downgrade the current task when target memory resources are insufficient. Instead, it intelligently decides whether to migrate a lower-complexity task to free up high-performance memory resources by evaluating the algorithmic complexity relationship between the current task and already occupied tasks. In particular, by introducing a "preset relationship" mechanism, it avoids frequent memory reallocation caused by minor differences in task complexity, effectively reducing system scheduling overhead and improving overall operational stability. This is especially suitable for scenarios in industrial real-time systems with high requirements for both response efficiency and resource utilization.

[0075] To improve the overall scheduling efficiency and resource utilization of the system when handling multiple data processing tasks, this embodiment of the invention further provides a priority sorting mechanism based on the ratio of task algorithm complexity to memory requirement. This mechanism can intelligently determine the memory allocation order of tasks when multiple tasks concurrently request memory resources, thereby optimizing the overall execution performance of the system. See also Figure 6 The method may also include the following steps: S208: When there are multiple data processing tasks to be processed, calculate the ratio of the algorithm complexity of each data processing task to the pre-allocated memory size.

[0076] S209: Determine the priority order of each data processing task according to the ratio, and perform memory allocation for each data processing task in order of priority.

[0077] When multiple data processing tasks exist in the system, each task is first analyzed independently to obtain its corresponding algorithm complexity and pre-allocated memory size. Then, the ratio of the task's algorithm complexity to the pre-allocated memory size is calculated. This ratio reflects the computational intensity of the task per unit of memory consumption and is an important indicator of the task's "resource efficiency." A higher ratio indicates that the task has high algorithm complexity with relatively small memory usage, usually meaning that the task is more dependent on high-performance memory. Prioritizing its memory allocation helps improve the overall system execution efficiency.

[0078] Based on the ratio calculated for each task in step S250, all tasks to be processed are sorted from highest to lowest ratio to determine their memory allocation priority. A higher ratio indicates that the task should have a higher priority in obtaining allocation opportunities for its target memory type. Subsequently, memory allocation operations are performed on each task in sequence according to this priority.

[0079] By introducing a priority sorting mechanism based on the ratio of algorithm complexity to pre-allocated memory size, in scenarios with intense resource competition and high task concurrency, tasks with high computational intensity and relatively low memory consumption can be prioritized, thereby making more efficient use of high-performance memory resources and reducing resource waste and system latency caused by inefficient allocation.

[0080] Furthermore, embodiments of the present invention also provide a memory allocation device, see [link to relevant documentation]. Figure 7 The memory allocation device 300 includes: The data acquisition unit 310 is used to acquire the algorithm complexity and pre-allocated memory size of the current data processing task; the pre-allocated memory size represents the memory capacity required to execute the current data processing task.

[0081] The target memory type determination unit 320 is used to determine the target memory type for performing the current data processing task based on the matching relationship between the algorithm complexity and the preset memory type threshold.

[0082] The target memory type allocation unit 330 is used to allocate the target memory type to the current data processing task if the remaining memory space of the target memory type is greater than or equal to the pre-allocated memory size.

[0083] In summary, the memory allocation method, apparatus, electronic device, and storage medium provided by this invention intelligently match different types of memory, such as TCM, RAM, and PSRAM, by comprehensively considering the algorithmic complexity (including time and space complexity) of data processing tasks and the pre-allocated memory size, combined with preset memory type thresholds. When the target memory resources are insufficient, a reallocation decision is further made based on the relationship between the algorithmic complexity of tasks, prioritizing the high-performance memory needs of high-complexity tasks. Simultaneously, a priority ranking mechanism based on the complexity-to-memory ratio is introduced in multi-task scenarios to optimize the overall scheduling order. This collaborative approach achieves refined and intelligent scheduling of memory resources, significantly improving the memory utilization efficiency and task execution performance of data acquisition devices under high load environments. It effectively alleviates the resource waste and system response latency problems caused by unreasonable memory scheduling in existing technologies, and is particularly suitable for scenarios with stringent real-time requirements, such as industrial equipment health diagnosis.

[0084] In the embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0085] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0086] If the functionality is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0087] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

[0088] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, 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 included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A memory allocation method, characterized in that, include: Obtain the algorithm complexity and pre-allocated memory size of the current data processing task; The pre-allocated memory size represents the memory capacity required to execute the current data processing task. Based on the matching relationship between the algorithm complexity and the preset memory type threshold, the target memory type for executing the current data processing task is determined; If the remaining memory space of the target memory type is greater than or equal to the pre-allocated memory size, then the target memory type is allocated to the current data processing task.

2. The method according to claim 1, characterized in that, The method further includes: If the remaining memory space of the target memory type is less than the pre-allocated memory size, then based on the relationship between the algorithm complexity of the current data processing task and the algorithm complexity of other tasks that have occupied the target memory type, a decision is made on whether to reallocate the other tasks to the next priority memory type.

3. The method according to claim 2, characterized in that, The step of deciding whether to reallocate the other tasks to a lower priority memory type based on the relationship between the algorithm complexity of the current data processing task and the algorithm complexity of other tasks already occupying the target memory type includes: Determine whether the algorithm complexity of the current data processing task is greater than the algorithm complexity of the other tasks; If so, the other tasks are reassigned to the next priority memory type to free up space in the target memory type, and the target memory type is allocated to the current data processing task; If not, the current data processing task is assigned to the next priority memory type.

4. The method according to claim 2, characterized in that, The step of deciding whether to reallocate the other tasks to a lower priority memory type based on the relationship between the algorithm complexity of the current data processing task and the algorithm complexity of other tasks already occupying the target memory type includes: Determine whether the algorithm complexity of the current data processing task satisfies a preset relationship with the algorithm complexity of other tasks; If so, the other tasks are reassigned to the next priority memory type to free up space in the target memory type, and the target memory type is allocated to the current data processing task; If not, the current data processing task is assigned to the next priority memory type.

5. The method according to claim 1, characterized in that, The algorithm complexity includes both time complexity and space complexity. The time complexity of the algorithm is determined by the number of lines of code, loop complexity, and halogen complexity of the current data processing task. The space complexity of the algorithm is determined by the frequency of memory usage, actual scope, and data stability of the current data processing task.

6. The method according to claim 1, characterized in that, The memory types include tightly coupled memory, random access memory, and pseudo-static random access memory; the preset memory type thresholds include a tightly coupled memory threshold and a random access memory threshold; wherein the tightly coupled memory threshold is greater than the random access memory threshold.

7. The method according to claim 1, characterized in that, The method further includes: When there are multiple data processing tasks to be processed, calculate the ratio of the algorithm complexity of each data processing task to the pre-allocated memory size. Based on the ratio, the priority order of each data processing task to be processed is determined, and memory allocation is performed for each data processing task to be processed in turn according to the priority order.

8. A memory allocation device, characterized in that, include: The data acquisition unit is used to obtain the algorithm complexity and pre-allocated memory size of the current data processing task; The pre-allocated memory size represents the memory capacity required to execute the current data processing task. The target memory type determination unit is used to determine the target memory type for executing the current data processing task based on the matching relationship between the algorithm complexity and the preset memory type threshold. A target memory type allocation unit is used to allocate the target memory type to the current data processing task if the remaining memory space of the target memory type is greater than or equal to the pre-allocated memory size.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 7.