Memory management function detection method and system, electronic equipment and storage medium

By introducing task priority and simulating multiple memory environments in real-time operating systems, the problems of insufficient load construction and high failure rate detected by memory management function in the prior art are solved, and higher equipment reliability and service life are achieved.

CN120066831AActive Publication Date: 2025-05-30BEIJING SMARTCHIP MICROELECTRONICS TECHNOLOGY CO LTD

Patent Information

Application Number
CN202510005040.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-02
Publication Date
2025-05-30
Estimated Expiration
2045-01-02

AI Technical Summary

Technical Problem

When detecting the memory management function of a real-time operating system, the prior art has problems such as insufficient load construction and high failure rate, resulting in reduced equipment reliability and short service life.

Method used

By introducing task priority, simulating different memory load rates and fragmentation situations, performing memory preemption operations and allocation operations, and comprehensively detecting memory management functions.

Benefits of technology

It improves the service life of the real-time operating system and equipment reliability, reduces the failure rate, and meets the real-time requirements of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066831A_ABST
    Figure CN120066831A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer memory management, and discloses a memory management function detection method and system, electronic equipment and a storage medium, and the method comprises the following steps: establishing a high-load and fragmented memory environment for an initial memory pool of a target system to obtain a target memory pool, and in the memory environment, performing memory management on the target memory pool; executing memory preemption operation of the first target task on the target memory pool, recording first execution time of preemption of the load memory block and the fragment memory block by the first target task, judging whether the first execution time exceeds a first preset time threshold, and responding to the condition that the first execution time exceeds the first preset time threshold, and determining that the memory management function of the target system is abnormal. According to the detection method, the task priority is introduced, the memory preemption condition is triggered, and the memory management is comprehensively detected, so that the failure rate after the real-time operating system is put into use is avoided, the service life of the real-time operating system is prolonged, the reliability of equipment is improved, and the real-time requirement of detection is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer memory management, and in particular, to a method for detecting a memory management function, a system for detecting a memory management function, an electronic device, and a computer-readable storage medium. Background Art

[0002] Currently, memory management algorithms need to find an idle memory block in memory that is suitable for a piece of data according to the length of the stored data, and then store the data in it. The time consumed to find such an idle memory block is uncertain. A real-time operating system must ensure that the memory block allocation process needs to be completed within a predictable and determined time, otherwise the response of real-time tasks to external events will also become uncertain. Therefore, in order to ensure the functions, performance, and reliability of a real-time operating system, it is necessary to detect the memory management function.

[0003] In related technologies, detection is performed through memory testing tools. Most testing methods only study a certain aspect of the memory performance metrics testing of real-time operating systems, and there are limitations in considering less application load construction. Among them, most methods only consider the test evaluation under no-load conditions, and a few testing methods that consider load conditions only set a load environment with undefined magnitude and priority, increasing the failure rate after the real-time operating system is put into use, reducing the service life of the real-time operating system, and reducing the reliability of the device. Summary of the Invention

[0004] The present invention aims to solve at least one of the technical problems in related technologies to some extent. To this end, the first object of the present invention is to propose a method for detecting a memory management function. By introducing task priorities, memory preemption situations are triggered to comprehensively detect the memory management situation. The load rate can be adjusted according to the actual situation to create a situation where different memory load rates and memory fragmentation coexist, so as to simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, increase the service life of the real-time operating system, increase the reliability of the device, and meet the real-time requirements of detection.

[0005] The second object of the present invention is to propose a system for detecting a memory management function.

[0006] The third object of the present invention is to propose an electronic device.

[0007] The fourth object of the present invention is to propose a computer-readable storage medium.

[0008] To achieve the above object, an embodiment of the first aspect of the present invention provides a method for detecting a memory management function, which creates a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain a target memory pool; wherein the target memory pool includes load memory blocks and fragmented memory blocks; in the memory environment, perform a memory preemption operation on the target memory pool for a first target task, and record the first execution time when the first target task preempts the load memory blocks and the fragmented memory blocks; wherein the memory space required by the first target task is greater than the memory space of the fragmented memory blocks, and the priority of the first target task is greater than the priority of the preset memory task stored in the load memory block; determine whether the first execution time exceeds a first preset time threshold; in response to the first execution time exceeding the first preset time threshold, determine that there is an abnormality in the memory management function of the target system.

[0009] In addition, the method for detecting a memory management function according to the above embodiment of the present invention may further have the following additional technical features:

[0010] According to some embodiments of the present invention, the above method further includes: in the memory environment, perform a memory allocation operation on the target memory pool for a second target task, and record the second execution time when the second target task occupies the fragmented memory block; wherein the memory space required by the second target task is not greater than the memory space of the fragmented memory block; determine whether the second execution time exceeds a second preset time threshold; in response to the second execution time exceeding the second preset time threshold, determine that there is an abnormality in the memory management function of the target system.

[0011] According to some embodiments of the present invention, creating a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain a target memory pool includes: creating a number of preset memory tasks, allocating corresponding free memory blocks from the initial memory pool for the number of preset memory tasks to obtain load memory blocks; in response to the memory space of the remaining free memory blocks in the initial memory pool being less than the memory space required by a single preset memory task, releasing at least one memory block occupied by a preset memory task in the initial memory pool according to a preset load rate to obtain fragmented memory blocks; obtaining the target memory pool according to the load memory blocks and the fragmented memory blocks.

[0012] According to some embodiments of the present invention, in a memory environment, perform a memory preemption operation on a target memory pool for a first target task, and record a first execution time for the first target task to preempt load memory blocks and fragmented memory blocks, including: establishing at least one first target task; wherein, the priority of the first target task is higher than a preset memory task; in response to starting to perform the memory preemption operation on the target memory pool for the first target task, record a first timestamp; in response to the memory space required by the first target task being completely allocated to load memory blocks and fragmented memory blocks, determine that the memory preemption operation is completed, and record a second timestamp; calculate the difference between the second timestamp and the first timestamp to obtain the first execution time.

[0013] According to some embodiments of the present invention, before responding to starting to perform the memory preemption operation on the target memory pool for the first target task, the method further includes: determining whether the memory space required by the first target task is greater than the memory space of the fragmented memory blocks; in response to the memory space required by the first target task being greater than the memory space of the fragmented memory blocks, determine to start performing the memory preemption operation on the target memory pool for the first target task.

[0014] According to some embodiments of the present invention, before responding to starting to perform the memory preemption operation on the target memory pool for the first target task, the method further includes: in response to the memory space required by the first target task not being greater than the memory space of the fragmented memory blocks, determining whether all fragmented memory blocks are fully occupied; in response to all fragmented memory blocks being fully occupied, determining whether there is an unallocated first target task; in response to there being an unallocated first target task, determine to start performing the memory preemption operation on the target memory pool for the first target task.

[0015] According to some embodiments of the present invention, in a memory environment, perform a memory allocation operation on a target memory pool for a second target task, and record a second execution time for the second target task to occupy fragmented memory blocks, including: establishing at least one second target task; wherein, the priority of the second target task is equal to a preset memory task; in response to starting to perform the memory allocation operation on the target memory pool for the second target task, record a third timestamp; in response to the memory space required by the second target task being completely allocated to fragmented memory blocks, determine that the memory allocation operation is completed, and record a fourth timestamp; calculate the difference between the fourth timestamp and the third timestamp to obtain the second execution time.

[0016] According to some embodiments of the present invention, the above method further includes: in response to an abnormality in the memory management function of the target system, judging the cause of the abnormality in the memory management function; optimizing the memory management function according to the cause of the abnormality.

[0017] According to some embodiments of the present invention, the method further includes: during the memory preemption operation of the first target task on the target memory pool, monitoring in real time the number of fragmented memory blocks in the target memory pool; in response to the number exceeding a preset fragmentation threshold, stopping the memory preemption operation of the first target task on the target memory pool, and optimizing the memory management function of the target system.

[0018] According to the detection method of the memory management function of the embodiments of the present invention, a high-load and fragmented memory environment is established for the initial memory pool of the target system to obtain a target memory pool; wherein, the target memory pool includes load memory blocks and fragmented memory blocks; in the memory environment, a memory preemption operation of the first target task is performed on the target memory pool, and the first execution time for the first target task to preempt the load memory blocks and the fragmented memory blocks is recorded; wherein, the memory space required by the first target task is greater than the memory space of the fragmented memory blocks, and the priority of the first target task is greater than the priority of the preset memory task stored in the load memory blocks; determining whether the first execution time exceeds a first preset time threshold; in response to the first execution time exceeding the first preset time threshold, determining that there is an abnormality in the memory management function of the target system. Thus, this method can comprehensively detect the memory management situation by introducing task priorities to trigger memory preemption situations, can adjust the load rate according to the actual situation, create a situation where different memory load rates and memory fragmentation exist simultaneously, simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, improve the service life of the real-time operating system, improve the reliability of the device, and meet the real-time requirements of the detection.

[0019] The second object of the present invention is to propose a detection system for the memory management function. By introducing task priorities to trigger memory preemption situations, it can comprehensively detect the memory management situation, can adjust the load rate according to the actual situation, create a situation where different memory load rates and memory fragmentation exist simultaneously, simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, improve the service life of the real-time operating system, improve the reliability of the device, and meet the real-time requirements of the detection.

[0020] To achieve the above object, an embodiment of the second aspect of the present invention provides a detection system for a memory management function, including an environment simulation module configured to establish a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain a target memory pool; wherein the target memory pool includes loaded memory blocks and fragmented memory blocks; a preemption module configured to perform a memory preemption operation on the target memory pool for a first target task in the memory environment and record a first execution time when the first target task preempts the loaded memory blocks and the fragmented memory blocks; wherein the memory space required by the first target task is greater than the memory space of the fragmented memory blocks, and the priority of the first target task is greater than the priority of the preset memory task stored in the loaded memory blocks; a judgment module configured to judge whether the first execution time exceeds a first preset time threshold; a detection module configured to determine that there is an abnormality in the memory management function of the target system in response to the first execution time exceeding the first preset time threshold.

[0021] According to the detection system for the memory management function of the embodiment of the present invention, the environment simulation module establishes a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain a target memory pool; wherein the target memory pool includes loaded memory blocks and fragmented memory blocks; the preemption module performs a memory preemption operation on the target memory pool for a first target task in the memory environment and records a first execution time when the first target task preempts the loaded memory blocks and the fragmented memory blocks; wherein the memory space required by the first target task is greater than the memory space of the fragmented memory blocks, and the priority of the first target task is greater than the priority of the preset memory task stored in the loaded memory blocks; the judgment module judges whether the first execution time exceeds a first preset time threshold; the detection module determines that there is an abnormality in the memory management function of the target system in response to the first execution time exceeding the first preset time threshold. Thus, by introducing task priorities, this system triggers memory preemption situations to comprehensively detect the memory management situation, can adjust the load rate according to actual conditions, create a situation where different memory load rates and memory fragmentation coexist, simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, extend the service life of the real-time operating system, improve the reliability of the device, and meet the real-time requirements of detection.

[0022] To achieve the above object, an embodiment of the third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above-mentioned detection method for the memory management function is implemented.

[0023] An electronic device according to an embodiment of the present invention, by executing the above-mentioned detection method of the memory management function, by introducing task priorities, triggering memory preemption situations, comprehensively detecting the memory management situation, can adjust the load rate according to the actual situation, create a situation where different memory load rates and memory fragmentation coexist, so as to simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, improve the service life of the real-time operating system, improve the reliability of the device, and meet the real-time requirements of detection.

[0024] To achieve the above object, a fourth aspect embodiment of the present invention proposes a computer-readable storage medium. The computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the above-mentioned detection method of the memory management function.

[0025] A computer-readable storage medium according to an embodiment of the present invention, by executing the above-mentioned detection method of the memory management function, by introducing task priorities, triggering memory preemption situations, comprehensively detecting the memory management situation, can adjust the load rate according to the actual situation, create a situation where different memory load rates and memory fragmentation coexist, so as to simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, improve the service life of the real-time operating system, improve the reliability of the device, and meet the real-time requirements of detection.

[0026] Additional aspects and advantages of the present invention will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present invention. Description of the Drawings

[0027] Figure 1 It is a flowchart of a detection method for a memory management function according to some embodiments of the present invention;

[0028] Figure 2 It is a schematic block diagram of an initial memory pool according to some embodiments of the present invention;

[0029] Figure 3 It is a schematic block diagram of a target memory pool according to some embodiments of the present invention;

[0030] Figure 4 It is a schematic diagram of a detection method for a memory management function according to some other embodiments of the present invention;

[0031] Figure 5 It is a schematic diagram of a detection method for a memory management function according to some further embodiments of the present invention;

[0032] Figure 6 It is a schematic diagram of a detection method for a memory management function according to some other embodiments of the present invention;

[0033] Figure 7 A block diagram of a detection system for a memory management function according to some embodiments of the present invention;

[0034] Figure 8 A block diagram of an electronic device according to some embodiments of the present invention. Detailed implementation manners

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

[0036] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present invention should have the ordinary meanings understood by those of ordinary skill in the art to which the present invention belongs. The "first", "second" and similar terms used in the embodiments of the present invention do not denote any order, quantity or importance, but are only used to distinguish different components. Words such as "including" or "comprising" mean that the elements or objects appearing before this word cover the elements or objects listed after this word and their equivalents, without excluding other elements or objects. Words such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Upper", "lower", "left", "right", etc. are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0037] As described in the background art section, embedded devices usually have limited memory resources. Effective memory management can maximize the use of memory space, reduce memory fragmentation problems, and improve memory utilization. To ensure the functions, performance, and reliability of a real-time operating system, it is necessary to detect the memory management function.

[0038] In the related art, memory testing tools are usually used for detection, such as Memtester, Stressapptest, Rhealstone, etc. These memory testing tools have different focuses.

[0039] Among them, Memtester belongs to a lightweight testing tool and has low requirements for system resources. It can test the stability of memory and detect errors in memory. The main items tested by Memtester include random values, exclusive OR comparison, subtraction, multiplication, division, AND / OR operations, etc. By specifying the size and number of times of the test memory, the above items can be tested on the existing memory of the system. By specifying the physical address, memtester can also be used to test memory-mapped I / O devices and similar devices.

[0040] Stressapptest can simulate concurrent access to memory, create memory stress, and test the stability of memory. By injecting a large amount of load into the system to simulate real-world workloads, the stability and tolerance of the system can be tested. By continuously increasing the load, the limit performance of the system can be discovered, and the performance of the system under different workloads can be evaluated. By stress-testing each component of the system, potential problems in the system can be discovered in a timely manner and resolved in a timely manner to ensure the stability and reliability of the system.

[0041] Through multiple dimensions of testing, Rhealstone can comprehensively understand the performance and potential bottlenecks of real-time operating systems. Rhealstone tests the read and write speed and performance of memory by accessing system memory. These memory access operations impose a load on the system's memory system, helping to evaluate the system's performance when dealing with memory-intensive tasks.

[0042] In the process of implementing the present invention, the applicant found that most of the current testing methods only study one aspect of the memory performance metrics testing of real-time operating systems, and there are generally limitations in considering less construction of application loads. Among them, most methods only consider the test evaluation under no-load conditions, and a few testing methods considering load conditions only set a load environment without specifying the magnitude and priority. However, in actual applications, the operating environment load of real-time operating systems is complex and diverse, the memory resources are extremely limited, and the time requirements are particularly strict.

[0043] The following describes a method for detecting a memory management function, a system for detecting a memory management function, an electronic device, and a storage medium according to embodiments of the present invention with reference to the accompanying drawings.

[0044] Reference Figure 1 , which is a flowchart of a method for detecting a memory management function according to some embodiments of the present invention.

[0045] As Figure 1 shown, the method for detecting a memory management function according to an embodiment of the present invention may include the following steps:

[0046] S101, establish a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain a target memory pool; wherein, the target memory pool includes load memory blocks and fragmented memory blocks.

[0047] Specifically, reference Figure 2, which is a block diagram of the initial memory pool according to some embodiments of the present invention. In the initial memory pool of the target system, there are multiple free memory blocks. Then, multiple preset memory tasks are set. Among them, the multiple preset memory tasks have the same priority. The multiple free memory blocks in the initial memory pool are sequentially allocated to the multiple corresponding preset memory tasks, and the allocated memory blocks will become loaded memory blocks.

[0048] When the memory space of the remaining free memory blocks in the initial memory pool is not enough to store the memory space required by a preset memory task, it can be understood that the free memory blocks in the initial memory pool have been fully allocated. At this time, the loaded memory blocks are released. After the loaded memory blocks are released, the released loaded memory blocks will become fragmented memory blocks. At this time, the memory pool includes loaded memory blocks and fragmented memory blocks. Take this memory pool as the target memory pool for reference Figure 3 , which is a block diagram of the target memory pool according to some embodiments of the present invention. Therefore, in the target memory pool, there is a memory environment with high load and fragmentation.

[0049] In some embodiments of the present invention, creating a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain the target memory pool includes: creating several preset memory tasks, allocating corresponding free memory blocks from the initial memory pool for the several preset memory tasks to obtain loaded memory blocks; in response to the memory space of the remaining free memory blocks in the initial memory pool being less than the memory space required by a single preset memory task, releasing at least one memory block occupied by a preset memory task in the initial memory pool according to a preset load rate to obtain fragmented memory blocks; obtaining the target memory pool according to the loaded memory blocks and the fragmented memory blocks. Among them, the preset memory tasks can be set according to the actual situation.

[0050] Specifically, a number of preset memory tasks are established according to the memory size of the initial memory pool and the memory task requirements. Among them, the number of preset memory tasks has the same priority, and the memory space required for each preset memory task is the same. The initial memory pool includes multiple free memory blocks. By calling the memory allocation function, corresponding free memory blocks are sequentially allocated from the initial memory pool for the number of preset memory tasks, and the allocated memory blocks will become loaded memory blocks. When the memory space of the remaining free memory blocks in the initial memory pool is less than the memory space required for a single preset memory task, it indicates that the memory space of the remaining free memory blocks in the initial memory pool is insufficient and cannot store the memory space required for a single preset memory task (allocation fails). At this time, the release function is called according to the preset load rate to release the memory of the loaded memory blocks. Among them, the preset load rate is set according to the task memory requirements, and the release quantity is set according to the preset load rate. After the memory of the loaded memory blocks is released, the released loaded memory blocks will become fragmented memory blocks. At this time, the memory pool includes loaded memory blocks and fragmented memory blocks. The memory pool at this time is used as the target memory pool. Therefore, in the target memory pool, there is a high-load and fragmented memory environment.

[0051] As a specific embodiment, when the preset load rate is 50% (that is, the memory pool should have 1 / 2 loaded memory blocks and 1 / 2 fragmented memory blocks), in order to avoid the situation where two fragmented memory blocks will merge into one fragmented memory block when they are adjacent, at this time, the odd-numbered or even-numbered loaded memory blocks are released to ensure that any two fragmented memory blocks are not adjacent. When the preset load rate is 80% (that is, the memory pool should have 4 / 5 loaded memory blocks and 1 / 5 fragmented memory blocks), the loaded memory blocks that are multiples of 5 are released (that is, every 4 loaded memory blocks are connected to one fragmented memory block).

[0052] As a specific embodiment, as Figure 4 shown, the flowchart of the detection method for the memory management function of the present invention may include the following steps:

[0053] S401, establish a number of preset memory tasks.

[0054] S402, allocate corresponding free memory blocks from the initial memory pool for the number of preset memory tasks to obtain loaded memory blocks.

[0055] S403, when the memory space of the remaining free memory blocks in the initial memory pool is less than the memory space required for a single preset memory task, release at least one memory block occupied by the preset memory task in the initial memory pool according to the preset load rate to obtain fragmented memory blocks.

[0056] S404, obtain the target memory pool according to the loaded memory blocks and the fragmented memory blocks.

[0057] S102. Under the memory environment, perform a memory preemption operation on the target memory pool for the first target task, and record the first execution time of the first target task preemption of the load memory block and the fragmented memory block. Among them, the memory space required by the first target task is greater than the memory space of the fragmented memory block, and the priority of the first target task is greater than the priority of the preset memory task stored in the load memory block.

[0058] Specifically, in a high-load and fragmented memory environment, establish the first target task. Among them, the priority of the first target task is higher than that of the preset memory task. For example, the preset memory task can be a low-priority or medium-priority task, and the first target task can be a high-priority task. When the memory space required by the first target task is greater than the memory space of the fragmented memory block, it means that the memory space of the fragmented memory block can no longer store the memory space required by the first target task. At this time, perform a memory preemption operation on the target memory pool for the first target task. When starting to perform a memory preemption operation on the target memory pool for the first target task, record the current time node, and then perform a memory preemption operation on the target memory pool for the first target task. When the memory preemption operation on the target memory pool for the first target task is completed, record the current time node. According to the difference between the time node before preemption and the time node when the preemption operation is completed, the execution time of the first target task occupying the load memory block and the fragmented memory block can be obtained, which is recorded as the first execution time. Loop the above operations until the memory preemption of the target system fails. When the memory preemption fails, check the memory usage of the target system and evaluate the memory management of the target system according to the memory usage.

[0059] S103. Judge whether the first execution time exceeds the first preset time threshold, where the first preset time threshold can be calibrated according to the actual situation.

[0060] Among them, judging whether the first execution time exceeds the first preset time threshold is to judge the working state of the memory management function of the target system.

[0061] S104. In response to the first execution time exceeding the first preset time threshold, determine that there is an abnormality in the memory management function of the target system.

[0062] Specifically, it is determined whether the first execution time exceeds the first preset time threshold. When the first execution time exceeds the first preset time threshold, it indicates that the first execution time is relatively long and the detection efficiency is poor. At this time, it is determined that there is an abnormality in the memory management function of the target system. When the first execution time does not exceed the first preset time threshold, it indicates that the first execution time is within the specified time and the detection efficiency is good. At this time, it is determined that the memory management function of the target system is normal. Thus, by introducing task priorities, memory preemption situations can be triggered to comprehensively detect memory management. The load rate can be adjusted according to the actual situation to create a situation where different memory load rates and memory fragmentation coexist, avoiding failure rates after the real-time operating system is put into use, increasing the service life of the real-time operating system, improving the reliability of the device, and meeting the real-time requirements of detection.

[0063] In some embodiments of the present invention, the above method further includes: in a memory environment, performing a memory allocation operation for a second target task on a target memory pool, and recording the second execution time of the second target task occupying a fragmented memory block; wherein, the memory space required by the second target task is not greater than the memory space of the fragmented memory block; determining whether the second execution time exceeds a second preset time threshold; in response to the second execution time exceeding the second preset time threshold, determining that there is an abnormality in the memory management function of the target system. The second preset time threshold can be calibrated according to the actual situation.

[0064] Further, in some embodiments of the present invention, in a memory environment, performing a memory allocation operation for a second target task on a target memory pool and recording the second execution time of the second target task occupying a fragmented memory block includes: establishing at least one second target task; wherein, the priority of the second target task is equal to a preset memory task; in response to starting the memory allocation operation for the second target task on the target memory pool, recording a third timestamp; in response to the memory space required by the second target task being completely allocated to the fragmented memory block, determining that the memory allocation operation is completed, and recording a fourth timestamp; calculating the difference between the fourth timestamp and the third timestamp to obtain the second execution time.

[0065] Specifically, in a high-load and fragmented memory environment, the computer first runs the load memory blocks in the target memory pool and creates at least one second target task. The priority of the second target task is equal to the preset memory task. For example, the second target task can be a low-priority task, and the preset memory task can be a low-priority task. The memory space required by the second target task is less than or equal to the memory space of the fragmented memory block (i.e., the memory space of the fragmented memory block can be allocated to the second target task for storage). When starting to perform the memory allocation operation of the second target task on the target memory pool, record the current time node as the third timestamp, and then perform the memory allocation operation of the second target task on the target memory pool. When the memory space required by the first target task is completely allocated to the fragmented memory block, it indicates that the memory space required by the first target task has been allocated. At this time, it is determined that the memory allocation operation is completed, and the current time node is recorded as the fourth timestamp. According to the difference between the time node before allocation and the time node when the allocation operation is completed, the execution time of the second target task occupying the fragmented memory block can be obtained, denoted as the second execution time. Repeat the above operations until all available memory spaces of the target system are allocated. Then, it is determined whether the second execution time exceeds the second preset time threshold. When the second execution time exceeds the second preset time threshold, it indicates that the second execution time is long and the detection efficiency is poor. At this time, it is determined that there is an abnormality in the memory management function of the target system. When the second execution time does not exceed the second preset time threshold, it indicates that the second execution time is within the specified time and the detection efficiency is good. At this time, it is determined that the memory management function of the target system is normal.

[0066] When the allocation fails, it indicates that the possible reason for the target system is insufficient available memory space. At this time, view the memory usage of the target system and evaluate the memory management situation based on the memory usage of the target system.

[0067] As a specific embodiment, when creating multiple second target tasks, the priority of the second target task is equal to the preset memory task. For example, the second target task can be a low-priority task, and the preset memory task can be a low-priority task. Since the priority of the second target task and the preset memory task is the same priority, the second target task cannot perform a preemption operation. When the memory space of the remaining free memory blocks in the initial memory pool is less than the memory space required by multiple second target tasks, it indicates that the memory space of the remaining free memory blocks in the initial memory pool is insufficient and cannot store the memory space required by multiple second target tasks. At this time, the allocation fails.

[0068] As a specific embodiment, as Figure 5 shown, the flowchart of the detection method for the memory management function of the present invention may include the following steps:

[0069] S501. Establish a second target task, where the second target task includes at least one second memory task.

[0070] S502. When starting the memory allocation operation for the second target task on the target memory pool, record the third timestamp.

[0071] S503. When the memory space required for the first target task is completely allocated to fragmented memory blocks, determine that the memory allocation operation is completed, and record the fourth timestamp.

[0072] S504. Calculate the difference between the fourth timestamp and the third timestamp to obtain the second execution time.

[0073] S505. Determine whether the second execution time exceeds the second preset time threshold. If so, execute step S506; if not, execute step S507.

[0074] S506. Determine that there is an abnormality in the memory management function of the target system.

[0075] S507. Determine that the memory management function of the target system is normal.

[0076] In some embodiments of the present invention, in a memory environment, when performing a memory preemption operation for a first target task on a target memory pool, recording the first execution time for the first target task to preempt load memory blocks and fragmented memory blocks includes: establishing at least one first target task; where the priority of the first target task is higher than that of a preset memory task; in response to starting the memory preemption operation for the first target task on the target memory pool, recording the first timestamp; in response to the memory space required for the first target task being completely allocated to load memory blocks and fragmented memory blocks, determining that the memory preemption operation is completed, and recording the second timestamp; calculating the difference between the second timestamp and the first timestamp to obtain the first execution time.

[0077] Specifically, in a high-load and fragmented memory environment, the computer first runs the load memory blocks in the target memory pool and creates a first target task, where the priority of the first target task is higher than that of a preset memory task. The first target task can be a high-priority task, and the preset memory task can be a low-priority or medium-priority task. Since the priority of the first memory task is high, it will preempt the low-priority memory tasks to ensure that the high-priority memory tasks are executed first. When starting the memory preemption operation of the first target task on the target memory pool, record the current time node as the first timestamp, and then perform the memory preemption operation of the first target task on the target memory pool. When the memory space required by the first target task is completely allocated to the load memory blocks and the fragmented memory blocks, it indicates that the memory space required by the first target task has been allocated. At this time, it is determined that the memory preemption operation has been completed, and the current time node is recorded as the second timestamp. According to the difference between the time node before preemption and the time node when the preemption operation is completed, the execution time of the first target task occupying the fragmented memory blocks can be obtained, denoted as the first execution time.

[0078] In some embodiments of the present invention, before responding to starting the memory preemption operation of the first target task on the target memory pool, the method further includes: determining whether the memory space required by the first target task is greater than the memory space of the fragmented memory blocks; in response to the memory space required by the first target task being greater than the memory space of the fragmented memory blocks, determining to start the memory preemption operation of the first target task on the target memory pool.

[0079] Specifically, before starting the memory preemption operation of the first target task on the target memory pool, it is judged whether the memory space required by the first target task is greater than the memory space of the fragmented memory blocks. When the memory space required by the first target task is greater than the memory space of the fragmented memory blocks, it indicates that the memory space of the fragmented memory blocks can no longer store the memory space required by the first target task. At this time, a part of the memory needs to be released to meet the memory space required by the first target task. Therefore, start the memory preemption operation of the first target task on the target memory pool so that the target memory pool can store the memory space required by the first target task.

[0080] In some embodiments of the present invention, before responding to starting the memory preemption operation of the first target task on the target memory pool, the method further includes: in response to the memory space required by the first target task not being greater than the memory space of the fragmented memory blocks, determining whether all the fragmented memory blocks are completely occupied; in response to all the fragmented memory blocks being completely occupied, determining whether there is a first target task that has not been allocated; in response to there being a first target task that has not been allocated, determining to start the memory preemption operation of the first target task on the target memory pool.

[0081] Specifically, when the memory space required for the first target task is less than or equal to the memory space of the fragmented memory block, it indicates that the memory space of the fragmented memory block can store the memory space required for the first target task. Determine whether all fragmented memory blocks are fully occupied. When all fragmented memory blocks are fully occupied, it indicates that although the memory space of the fragmented memory block can store the memory space required for the first target task, there is no additional memory space of the fragmented memory block available for further storage. Then determine whether there is an unallocated first target task. When there is an unallocated first target task, it indicates that when all fragmented memory blocks are fully occupied, the first target task has not been completely allocated. At this time, start the memory preemption operation for the first target task on the target memory pool so that the target memory pool can store the memory space required for the first target task.

[0082] When determining whether all fragmented memory blocks are fully occupied, when all fragmented memory blocks are not fully occupied, it indicates that there is at least one fragmented memory block whose memory space can store the memory space required for the first target task.

[0083] As a specific embodiment, when the memory space required for the first target task is greater than the memory space of the fragmented memory block, and the memory space required for the first target task is the size of two memory blocks in the target memory pool, it is necessary to perform a memory preemption operation for the first target task on one loaded memory block and one fragmented memory block in the target memory pool so that the memory space required for the first target task is not greater than the memory space of the fragmented memory block. When the memory space required for the first target task is 1.5 times the size of the memory block in the target memory pool, it is necessary to perform a memory preemption operation for the first target task on one fragmented memory block and half of the loaded memory block so that the memory space required for the first target task is not greater than the memory space of the fragmented memory block.

[0084] As a specific embodiment, when establishing multiple first target tasks, the priority of the first target task is higher than that of the preset memory task. For example, the first target task can be a high-priority task, and the preset memory task can be a low-priority task. Since the priorities of the first target task and the preset memory task are different, the first target task can perform a preemption operation. When the memory space of the remaining free memory blocks in the initial memory pool is less than the memory space required for multiple first target tasks, it indicates that the memory space of the remaining free memory blocks in the initial memory pool is insufficient and cannot store the memory space required for multiple first target tasks. At this time, the first target task performs a preemption operation to preempt the loaded memory blocks in the target memory pool until the memory space of the remaining free memory blocks in the initial memory pool is greater than or equal to the memory space required for multiple first target tasks, and then stops the preemption operation.

[0085] In some embodiments of the present invention, the above method further includes: in response to an abnormality in the memory management function of the target system, determining the cause of the abnormality in the memory management function; and optimizing the memory management function according to the cause of the abnormality.

[0086] Specifically, when there is an abnormality in the memory management function of the target system, it indicates that the detection efficiency is poor at this time. It is necessary to determine the cause of the abnormality in the memory management function and optimize the memory management function according to the cause of the abnormality in the memory management function to keep the memory management function in a normal state. For example, when memory allocation fails but the memory is used, the pointer should be checked to see if it is NULL before using the memory. If the pointer p is a parameter of a function, then use assert(p!= NULL) to check at the entrance of the function. If memory is allocated using malloc or new, error prevention processing should be performed using if(p == NULL) or if(p!= NULL). Another example is that although memory allocation is successful, the memory is referenced without initialization. In this case, an initial value should be assigned when creating an array.

[0087] In some embodiments of the present invention, the above method further includes: during the memory preemption operation of the first target task on the target memory pool, real-time monitoring the number of fragmented memory blocks in the target memory pool; in response to the number exceeding a preset fragmentation threshold, stopping the memory preemption operation of the first target task on the target memory pool and optimizing the memory management function of the target system. The preset fragmentation threshold can be calibrated according to the actual situation.

[0088] Specifically, during the memory preemption operation of the first target task on the target memory pool, the number of fragmented memory blocks in the target memory pool can be counted by a counter set in the target memory pool to monitor in real time whether to continue the preemption operation. When the number of fragmented memory blocks exceeds the preset fragmentation threshold, it indicates that there is an abnormality in the memory management function of the target system. At this time, stop the memory preemption operation of the first target task on the target memory pool and optimize the memory management function of the target system to keep the memory management function of the target system in a normal state.

[0089] In some embodiments, the embedded real-time operating system needs to ensure that high-priority tasks can be allocated the required memory within the specified time and thus can be executed smoothly after running for a long time (with more memory fragmentation) under limited resource conditions (limited memory). And simulate this running state to dynamically detect the memory management system to ensure that the memory management module of the embedded real-time operating system meets the usage requirements in terms of function and performance.

[0090] Compared with the Stressapptest method, the present invention fully considers the characteristics and usage scenarios of an embedded real-time operating system. By creating different memory load rates, it simulates the memory fragmentation situation after the system has been running for a long time. By recording the memory allocation time of real-time tasks, it achieves the purpose of dynamically testing the memory management function. Compared with the Stressapptest method, the present invention not only considers a large amount of load to simulate the workload in the real world, but also simulates the memory fragmentation state. Compared with simple load testing, it can better discover problems in actual applications. Compared with the Stressapptest method, the present invention not only increases the number of concurrent tasks to increase the load, but also introduces task priorities to trigger memory preemption situations, comprehensively detecting the memory management. By adjusting the load rate and task priorities, it detects whether the time for task allocation / detecting memory remains within a stable range. If the time is less than the required threshold, it proves that the reliability of the system's memory management function meets the requirements, and it also demonstrates the effectiveness of this detection method.

[0091] As a specific embodiment, as Figure 6 shown, the flowchart of the detection method for the memory management function of the present invention may include the following steps:

[0092] S601, establish a first target task, where the first target task includes at least one first memory task.

[0093] S602, determine whether the memory space required by any one of the first target tasks is greater than the memory space of any one of the fragmented memory blocks. If so, execute step S603; if not, execute step S610.

[0094] S603, determine to start the memory preemption operation for the first target task on the target memory pool.

[0095] S604, when starting the memory preemption operation for the first target task on the target memory pool, record the first timestamp.

[0096] S605, when the memory space required by the first target task is completely allocated to the load memory block and the fragmented memory block, determine that the memory preemption operation is completed, and record the second timestamp.

[0097] S606, calculate the difference between the second timestamp and the first timestamp to obtain the first execution time.

[0098] S607, determine whether the first execution time exceeds the first preset time threshold. If so, execute step S608; if not, execute step S609.

[0099] S608, determine that there is an abnormality in the memory management function of the target system.

[0100] S609. Determine that the memory management function of the target system is normal.

[0101] S610. Determine whether all fragmented memory blocks are fully occupied. If so, execute step S611.

[0102] S611. Determine whether there is a first target task that has not been allocated. If so, execute step S612.

[0103] S612. Determine to start the memory preemption operation for the first target task on the target memory pool.

[0104] Thus, after creating multiple tasks with the same priority and allocating memory, the present invention releases memory at intervals according to the load rate, creating a situation where different memory load rates and memory fragmentation coexist, so as to simulate the actual running situation. In this case, ordinary memory allocation tests and memory preemption tests are carried out, and the memory allocation time of the tasks is recorded. The memory allocation time should be within a certain threshold range. Otherwise, the memory management algorithm should be optimized. At the end of the loop, the memory situation needs to be checked; in the task preemption process, the memory fragmentation situation is checked. If there are too many fragments, the memory management algorithm should be considered for optimization.

[0105] The embedded system memory can be comprehensively detected under different conditions by adjusting the preset load rate, the initial application memory size, the number of tasks, and the task application memory size; by means of ordinary task memory allocation and high-priority task memory preemption and recording time, the real-time requirements of the detection system are met; by means of multi-task memory allocation and memory preemption and checking the memory allocation situation, the superiority of the dynamic detection memory management function is reflected, and the reliability and reproducibility of the detection method are improved.

[0106] In summary, according to the detection method of the memory management function in the embodiments of the present invention, a memory environment with high load and fragmentation is established for the initial memory pool of the target system to obtain a target memory pool; wherein, the target memory pool includes load memory blocks and fragmented memory blocks; in the memory environment, a memory preemption operation of a first target task is performed on the target memory pool, and a first execution time for the first target task to preempt the load memory blocks and the fragmented memory blocks is recorded; wherein, the memory space required by the first target task is larger than the memory space of the fragmented memory blocks, and the priority of the first target task is higher than the priority of the preset memory task stored in the load memory blocks; it is determined whether the first execution time exceeds a first preset time threshold; in response to the first execution time exceeding the first preset time threshold, it is determined that there is an abnormality in the memory management function of the target system. Thus, by introducing task priorities, this method causes memory preemption situations to comprehensively detect the memory management situation, can adjust the load rate according to the actual situation, create a situation where different memory load rates and memory fragmentation coexist, simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, extend the service life of the real-time operating system, improve the reliability of the device, and meet the real-time requirements of detection.

[0107] It should be noted that the method in the embodiments of the present invention can be executed by a single device, such as a computer or a server, etc. The method in this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In such a distributed scenario, one of the multiple devices can only execute one or more steps in the method in the embodiments of the present invention, and these multiple devices will interact with each other to complete the above method.

[0108] It should be noted that some embodiments of the present invention have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be executed in a different order than in the above embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0109] Corresponding to the above embodiments, the present invention also proposes a detection system for the memory management function.

[0110] As Figure 7 shown, the detection system for the memory management function in the embodiments of the present invention may include: an environment simulation module 710, a preemption module 720, a judgment module 730, and a detection module 740.

[0111] Among them, the environment simulation module 710 is configured to establish a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain a target memory pool; wherein, the target memory pool includes load memory blocks and fragmented memory blocks. The preemption module 720 is configured to perform a memory preemption operation on the target memory pool for the first target task in the memory environment, and record the first execution time when the first target task preempts the load memory blocks and the fragmented memory blocks; wherein, the memory space required by the first target task is greater than the memory space of the fragmented memory blocks, and the priority of the first target task is greater than the priority of the preset memory task stored in the load memory blocks. The judgment module 730 is configured to judge whether the first execution time exceeds a first preset time threshold. The detection module 740 is configured to determine that there is an abnormality in the memory management function of the target system in response to the first execution time exceeding the first preset time threshold.

[0112] In some embodiments of the present invention, the judgment module 730 is further configured to perform a memory allocation operation on the target memory pool for the second target task in the memory environment, and record the second execution time when the second target task occupies the fragmented memory blocks; wherein, the memory space required by the second target task is not greater than the memory space of the fragmented memory blocks; judge whether the second execution time exceeds a second preset time threshold; the detection module 740 determines that there is an abnormality in the memory management function of the target system in response to the second execution time exceeding the second preset time threshold.

[0113] In some embodiments of the present invention, the environment simulation module 710 establishes a memory environment with high load and fragmentation for the initial memory pool of the target system to obtain a target memory pool, specifically for: establishing a number of preset memory tasks, allocating corresponding free memory blocks from the initial memory pool for the number of preset memory tasks to obtain load memory blocks; in response to the memory space of the remaining free memory blocks in the initial memory pool being less than the memory space required by a single preset memory task, releasing at least one memory block occupied by a preset memory task in the initial memory pool according to a preset load rate to obtain fragmented memory blocks; obtaining the target memory pool according to the load memory blocks and the fragmented memory blocks.

[0114] In some embodiments of the present invention, the preemption module 720 performs a memory preemption operation on the target memory pool for the first target task in the memory environment, and records the first execution time when the first target task preempts the load memory blocks and the fragmented memory blocks, specifically for: establishing at least one first memory task; in response to starting to perform the memory preemption operation on the target memory pool for the first target task, recording a first time stamp; in response to the memory space required by the first target task being completely allocated to the load memory blocks and the fragmented memory blocks, determining that the memory preemption operation is completed, and recording a second time stamp; calculating the difference between the second time stamp and the first time stamp to obtain the first execution time.

[0115] In some embodiments of the present invention, the preemption module 720 is further configured to determine whether the memory space required for the first target task is greater than the memory space of the fragmented memory block before responding to the start of the memory preemption operation for the first target task on the target memory pool; in response to the memory space required for the first target task being greater than the memory space of the fragmented memory block, determine to start the memory preemption operation for the first target task on the target memory pool.

[0116] In some embodiments of the present invention, the preemption module 720 is further configured to, before responding to the start of the memory preemption operation for the first target task on the target memory pool, in response to the memory space required for the first target task not being greater than the memory space of the fragmented memory block, determine whether all the fragmented memory blocks are fully occupied; in response to all the fragmented memory blocks being fully occupied, determine whether there is a first target task that has not been allocated; in response to there being a first target task that has not been allocated, determine to start the memory preemption operation for the first target task on the target memory pool.

[0117] In some embodiments of the present invention, the environment simulation module 710 performs a memory allocation operation for the second target task on the target memory pool in a memory environment and records the second execution time of the second target task occupying the fragmented memory block, specifically: establishing at least one second memory task; in response to starting the memory allocation operation for the second target task on the target memory pool, recording a third time stamp; in response to the memory space required for the second target task being fully allocated to the fragmented memory block, determining that the memory allocation operation is completed and recording a fourth time stamp; calculating the difference between the fourth time stamp and the third time stamp to obtain the second execution time.

[0118] In some embodiments of the present invention, the detection module 740 is further configured to, in response to an abnormality in the memory management function of the target system, determine the cause of the abnormality in the memory management function; optimize the memory management function according to the cause of the abnormality.

[0119] In some embodiments of the present invention, the preemption module 720 is further configured to, during the process of performing the memory preemption operation for the first target task on the target memory pool, monitor the number of fragmented memory blocks in the target memory pool in real time; in response to the number exceeding the preset fragmentation threshold, stop the memory preemption operation for the first target task on the target memory pool and optimize the memory management function of the target system.

[0120] It should be noted that for the details not disclosed in the memory management function detection system of the embodiments of the present invention, please refer to the details disclosed in the memory management function detection method of the embodiments of the present invention, which will not be elaborated herein.

[0121] In summary, according to the detection system for the memory management function of the embodiments of the present invention, the environment simulation module creates a high-load and fragmented memory environment for the initial memory pool of the target system to obtain a target memory pool; wherein, the target memory pool includes load memory blocks and fragmented memory blocks; the preemption module performs a memory preemption operation on the target memory pool for the first target task in the memory environment, and records the first execution time when the first target task preempts the load memory blocks and the fragmented memory blocks; wherein, the memory space required by the first target task is larger than the memory space of the fragmented memory blocks, and the priority of the first target task is higher than the priority of the preset memory task stored in the load memory blocks; the judgment module judges whether the first execution time exceeds a first preset time threshold; the detection module determines that there is an abnormality in the memory management function of the target system in response to the first execution time exceeding the first preset time threshold. Thus, by introducing task priorities, this system causes memory preemption situations to comprehensively detect the memory management situation, can adjust the load rate according to the actual situation, create a situation where different memory load rates and memory fragmentation coexist, so as to simulate various memory environments during memory management, increase the diversity of the memory management function, reduce the failure rate after the real-time operating system is put into use, extend the service life of the real-time operating system, improve the reliability of the device, and meet the real-time requirements of detection.

[0122] For the convenience of description, when describing the above system, various modules are described separately according to their functions. Of course, when implementing the present invention, the functions of each module can be implemented in one or more software and / or hardware.

[0123] The system of the above embodiment is used to implement the corresponding method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0124] Corresponding to the above embodiment, the present invention also proposes an electronic device.

[0125] Refer to Figure 8 , which is a block diagram of an electronic device according to some embodiments of the present invention, showing a more specific schematic diagram of the hardware structure of the electronic device provided in this embodiment. The device may include: a processor 810, a memory 820, an input / output interface 830, a communication interface 840, and a bus 850. Among them, the processor 810, the memory 820, the input / output interface 830, and the communication interface 840 are communicatively connected to each other inside the device through the bus 850.

[0126] The processor 810 can be implemented in the form of a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0127] The memory 820 can be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 820 can store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 820 and called by the processor 810 for execution.

[0128] The input / output interface 830 is used to connect to the input / output module to achieve information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Among them, the input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.

[0129] The communication interface 840 is used to connect to a communication module (not shown in the figure) to achieve communication interaction between this device and other devices. Among them, the communication module can achieve communication through a wired method (such as USB, network cable, etc.) or through a wireless method (such as a mobile network, WIFI, Bluetooth, etc.).

[0130] The bus 850 includes a path for transmitting information between various components of the device (such as the processor 810, the memory 820, the input / output interface 830, and the communication interface 840).

[0131] It should be noted that although the above device only shows the processor 810, the memory 820, the input / output interface 830, the communication interface 840, and the bus 850, in the specific implementation process, this device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solutions of the embodiments of this specification, and does not necessarily include all the components shown in the figure.

[0132] The electronic device in the above embodiment is used to implement the corresponding method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0133] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present invention further provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the method of any of the above embodiments.

[0134] The above non-transitory computer-readable storage medium may be any available medium or data storage device accessible by a computer, including but not limited to magnetic memories (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical memories (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor memories (such as ROMs, EPROMs, EEPROMs, non-volatile memories (NAND FLASH), solid state drives (SSD), etc.).

[0135] The computer instructions stored in the storage medium of the above embodiments are used to cause a computer to execute the method of any of the embodiments in the above exemplary method part, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated herein.

[0136] In addition, although the operations of the method of the present invention are described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart may be changed in the order of execution. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution.

[0137] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.

[0138] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present invention should have the ordinary meanings understood by those of ordinary skill in the art to which the present invention pertains. The "first", "second" and similar terms used in the embodiments of the present invention do not denote any order, quantity or importance, but are only used to distinguish different components. Words such as "including" or "comprising" mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Words such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Upper", "lower", "left", "right", etc. are only used to indicate relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0139] Although the spirit and principles of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the specific embodiments disclosed, and the division of each aspect does not mean that the features in these aspects cannot be combined for benefit. This division is only for convenience of expression. The present invention aims to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the appended claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.

Claims

1. A method for detecting a memory management function, characterized in that: include: Establishing a high-load and fragmented memory environment for the initial memory pool of the target system to obtain a target memory pool; wherein the target memory pool includes a load memory block and a fragmented memory block; In the memory environment, a memory preemption operation of a first target task is performed on the target memory pool, and a first execution time of the first target task preempting the load memory block and the fragment memory block is recorded; wherein the memory space required by the first target task is larger than the memory space of the fragment memory block, and the priority of the first target task is larger than the priority of the preset memory task stored in the load memory block; Determining whether the first execution time exceeds a first preset time threshold; In response to the first execution time exceeding the first preset time threshold, it is determined that an abnormality exists in the memory management function of the target system.

2. The method for detecting the memory management function according to claim 1, characterized in that: The method further comprises: In the memory environment, a memory allocation operation of a second target task is performed on the target memory pool, and a second execution time of the second target task occupying the fragmented memory block is recorded; wherein the memory space required by the second target task is not greater than the memory space of the fragmented memory block; Determining whether the second execution time exceeds a second preset time threshold; In response to the second execution time exceeding a second preset time threshold, it is determined that an abnormality exists in the memory management function of the target system.

3. The method for detecting the memory management function according to claim 2, characterized in that: The step of establishing a high-load and fragmented memory environment for the initial memory pool of the target system to obtain a target memory pool includes: Establishing a plurality of the preset memory tasks, allocating corresponding free memory blocks to the plurality of the preset memory tasks from the initial memory pool, and obtaining the load memory blocks; In response to the memory space of the remaining free memory blocks in the initial memory pool being smaller than the memory space required by a single preset memory task, at least one memory block in the initial memory pool that has been occupied by the preset memory task is released according to a preset load rate to obtain the fragmented memory block; The target memory pool is obtained according to the load memory block and the fragment memory block.

4. The method for detecting the memory management function according to claim 3, characterized in that: The performing of the memory preemption operation of the first target task on the target memory pool under the memory environment, and recording the first execution time of the first target task preempting the load memory block and the fragment memory block, comprises: Establishing at least one first target task; wherein the priority of the first target task is higher than the preset memory task; In response to starting to execute the memory preemption operation of the first target task on the target memory pool, recording a first timestamp; In response to the memory space required by the first target task being completely allocated to the load memory block and the fragment memory block, determining that the memory preemption operation is completed, and recording a second timestamp; The difference between the second timestamp and the first timestamp is calculated to obtain the first execution time.

5. The method for detecting the memory management function according to claim 4, characterized in that: Before the memory preemption operation of executing the first target task in response to starting to execute the memory preemption operation on the target memory pool, the method further includes: Determining whether the memory space required by the first target task is greater than the memory space of the fragmented memory block; In response to the memory space required by the first target task being larger than the memory space of the fragmented memory block, it is determined to start executing a memory preemption operation of the first target task on the target memory pool.

6. The method for detecting the memory management function according to claim 5, characterized in that: Before the memory preemption operation of executing the first target task in response to starting to execute the memory preemption operation on the target memory pool, the method further includes: In response to the memory space required by the first target task being not greater than the memory space of the fragmented memory blocks, determining whether all the fragmented memory blocks are fully occupied; In response to all the fragmented memory blocks being completely occupied, determining whether there is any unassigned first target task; In response to the existence of the first target task that has not been assigned, it is determined to start executing a memory preemption operation of the first target task on the target memory pool.

7. The method for detecting the memory management function according to claim 2, characterized in that: The performing of a memory allocation operation of a second target task on the target memory pool under the memory environment and recording a second execution time of the second target task occupying the fragmented memory block comprises: Establishing at least one second target task; wherein the priority of the second target task is equal to the preset memory task; In response to starting to execute the memory allocation operation of the second target task on the target memory pool, recording a third timestamp; In response to the memory space required by the second target task being completely allocated to the fragmented memory block, determining that the memory allocation operation is completed, and recording a fourth timestamp; The difference between the fourth timestamp and the third timestamp is calculated to obtain the second execution time.

8. The method for detecting the memory management function according to claim 2, characterized in that: The method further comprises: In response to an abnormality in a memory management function of the target system, determining a cause of the abnormality in the memory management function; The memory management function is optimized according to the cause of the exception.

9. The method for detecting the memory management function according to claim 7, characterized in that: The method further comprises: In the process of executing the memory preemption operation of the first target task on the target memory pool, monitoring the number of fragmented memory blocks in the target memory pool in real time; In response to the number exceeding a preset fragmentation threshold, the memory preemption operation of the first target task on the target memory pool is stopped, and the memory management function of the target system is optimized.

10. A memory management function detection system, characterized in that: include: The environment simulation module is configured to establish a high-load and fragmented memory environment for the initial memory pool of the target system to obtain a target memory pool; wherein the target memory pool includes a load memory block and a fragmented memory block; The preemption module is configured to execute a memory preemption operation of a first target task on the target memory pool under the memory environment, and record a first execution time of the first target task preempting the load memory block and the fragment memory block; wherein the memory space required by the first target task is larger than the memory space of the fragment memory block, and the priority of the first target task is larger than the priority of the preset memory task stored in the load memory block; A determination module, configured to determine whether the first execution time exceeds a first preset time threshold; The detection module is configured to determine that there is an abnormality in the memory management function of the target system in response to the first execution time exceeding the first preset time threshold.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for detecting the memory management function as described in any one of claims 1 to 7 is implemented.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the memory management function detection method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Memory allocation method, device and system

    CN103810109A

  • Method and device for distributing memory

    CN105302738A

  • Memory management method and device, electronic device and computer readable storage medium

    CN110008021A

  • Memory exception monitoring method and device and computer storage medium

    CN113835920A

  • Memory allocation method and system, computer equipment and readable medium

    CN114924886A

Cited By

  • External device memory management method and system

    CN120386639A

  • External device memory management method and system

    CN120386639B