Embedded memory management method, device and equipment, medium and vehicle
By introducing proxy modules into embedded systems, dynamically allocating and managing memory areas, the resource shortage caused by low memory usage in embedded systems is solved, efficient memory usage and management is achieved, and system performance and stability are improved.
Patent Information
- Application Number
- CN202411997010.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-30
AI Technical Summary
In embedded systems, due to the early allocation of memory during the compilation phase, some memory areas are not used at high rates during program execution, resulting in the problem of memory resource shortage.
The proxy module dynamically allocates memory areas, responds to the memory read/write request of the embedded program, and allocates the address and length of available memory blocks based on the preset memory proxy management mechanism to realize dynamic memory management.
Under limited system resources, efficient memory usage and management can be achieved, system performance and stability can be improved, memory fragmentation can be reduced, and memory usage efficiency can be improved.
Smart Images

Figure CN120066762A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of embedded memory management, and particularly to an embedded memory management method, device, equipment, medium and vehicle. Background Art
[0002] In an embedded system, memory allocation is configured in advance during the compilation stage. That is, users who need to use memory define in advance the corresponding memory sizes they need during the coding stage, such as the definition of global variables, etc. During compilation, the compiler assigns corresponding addresses to each pre-defined memory according to the current available resources. During program execution, users can perform corresponding read and write operations on the allocated memory areas. Memory allocation in the embedded system is pre-defined and allocated, and cannot be changed. However, since the usage frequencies of each memory during the execution of the program are inconsistent, some areas are not read or written for most of the program execution cycle. And the memory resources of the embedded system are very limited, resulting in the problem that the previous program writer occupies the memory area but the utilization rate is not high, and subsequent developers do not have enough resources to design the program, thus causing a shortage of memory resources. Summary of the Invention
[0003] To overcome the problems existing in the related art, the present disclosure provides an embedded memory management method, device, equipment, medium and vehicle.
[0004] According to the first aspect of the embodiments of the present disclosure, an embedded memory management method is provided, including:
[0005] Applying to the system through a proxy module for a memory area for reading / writing by an embedded program, so as to obtain the address and length of the memory area;
[0006] In response to a memory read / write request of the embedded program, the proxy module allocates the address and length of a memory block to be operated in the available memory area based on a preset memory proxy management mechanism, and performs a memory read / write operation on the memory block to be operated according to the address and length of the memory block to be operated;
[0007] According to the second aspect of the embodiments of the present disclosure, an embedded memory management device is provided, including a memory acquisition proxy module, which applies to the system through a proxy module for a memory area for reading / writing by an embedded program, so as to obtain the address and length of the memory area;
[0008] A memory multiplexing module, in response to a memory read / write request of the embedded program, the proxy module allocates the address and length of a memory block to be operated in the available memory area based on a preset memory proxy management mechanism, and performs a memory read / write operation on the memory block to be operated according to the address and length of the memory block to be operated;
[0009] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including: a processor; a memory for storing executable instructions executable by the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the embedded memory management method provided in the first aspect of the present disclosure.
[0010] According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of the embedded memory management method provided in the first aspect of the present disclosure are implemented.
[0011] According to a fifth aspect of the embodiments of the present disclosure, there is provided a vehicle, which stores a set of instruction sets, and the instruction sets are executed by the vehicle to implement the embedded memory management method provided in the first aspect of the present disclosure.
[0012] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects: The dynamic allocation of memory areas is realized according to the operation of the program through the proxy module, fully considering the characteristics of low-resource systems. By optimizing memory management, efficient memory use and management can be achieved under limited system resources, improving system performance and stability.
[0013] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0015] Figure 1 is a flowchart of an embedded memory management method shown according to an exemplary embodiment;
[0016] Figure 2 is a block diagram of an embedded memory management device shown according to an exemplary embodiment;
[0017] Figure 3 is a schematic diagram of the initialization of a dynamic memory pool and the process of memory application and release shown according to an exemplary embodiment;
[0018] Figure 4 is a schematic diagram of analyzing and statistics of the memory usage during program operation shown according to an exemplary embodiment;
[0019] Figure 5 is a schematic diagram of generating a static memory pool by a dynamic memory pool according to operation statistics shown according to an exemplary embodiment;
[0020] Figure 6 It is a block diagram of a vehicle shown according to an exemplary embodiment.
[0021] Figure 7 It is a block diagram of an electronic device shown according to an exemplary embodiment. Detailed implementation manners
[0022] Exemplary embodiments will be described in detail below with reference to the accompanying drawings.
[0023] It should be noted that the related embodiments and the accompanying drawings are only used to describe and illustrate the exemplary embodiments provided by the present disclosure, rather than all embodiments of the present disclosure, nor should it be understood that the present disclosure is limited by the related exemplary embodiments.
[0024] It should be noted that the terms "first", "second", etc. used in the present disclosure are only used to distinguish different steps, devices or modules, etc. The related terms neither represent any specific technical meaning nor indicate the order or interdependence relationship between them.
[0025] It should be noted that the modifications of the terms "a", "multiple", "at least one" used in the present disclosure are illustrative rather than restrictive. Unless otherwise clearly stated in the context, it should be understood as "one or more".
[0026] It should be noted that the term "and / or" used in the present disclosure is used to describe the association relationship between associated objects, and generally represents at least three association relationships. For example, A and / or B can represent at least the following three association relationships: A exists alone, A and B exist simultaneously, and B exists alone.
[0027] It should be noted that the steps recorded in the method embodiments of the present disclosure can be executed in different orders and / or executed in parallel. Unless otherwise specified, the scope of the present disclosure is not limited by the description order of the steps in the related embodiments.
[0028] It should be noted that all actions of obtaining signals, information or data in the present disclosure are carried out on the premise of complying with the corresponding data protection regulations and policies of the country where it is located and obtaining the authorization given by the owner of the corresponding device.
[0029] Exemplary method
[0030] Figure 1 It is a flowchart of an embedded memory management method shown according to an exemplary embodiment, as Figure 1 shown, including the following steps.
[0031] In step S110, the proxy module is used to apply to the system for a memory area for the embedded program to read / write, so as to obtain the address and length of the memory area;
[0032] Establish a general memory management proxy method in the embedded system, stipulating that users do not customize additional memory requirements (such as global variables, etc.) during the program writing stage, and all requirements are obtained through a unified interface via the proxy module. The proxy module realizes the dynamic management of the memory area of the embedded system. During the program compilation stage, the system allocates corresponding SRAM resources for it according to the memory management configuration.
[0033] During the program execution stage, the proxy module initializes the memory area into a dynamically distributed memory pool with the same size and a fixed count. The proxy module allocates memory blocks with the corresponding number of blocks for the user according to the memory size applied by the user. Figure 3 It is a schematic diagram showing the dynamic memory pool initialization and memory application and release process according to an exemplary embodiment.
[0034] As Figure 3 shown, in a specific implementation of the embodiment of the present invention, during the debugging stage, the dynamic memory pool in the memory area is divided into multiple 64B dynamic memory blocks. When applying for 192B for the first time, 3 64B dynamic memory blocks are allocated. When applying for 192B for the second memory request, the subsequent 3 64B dynamic memory blocks connected to the dynamic memory blocks allocated for the first time are allocated to the memory request. When applying for the third time, and so on, the subsequent dynamic memory blocks of the corresponding size are allocated to the memory request. When releasing the memory resources subsequently, the corresponding dynamic memory blocks are released.
[0035] In step S120, in response to the memory read / write request of the embedded program, the proxy module allocates the address and length of the memory block to be operated in the available memory area based on the preset memory proxy management mechanism, and performs memory read / write operations on the memory block to be operated according to the address and length of the memory block to be operated.
[0036] The preset memory proxy management mechanism analyzes and statistics the memory application and release situations of the program based on a preset time period during the program trial run, and realizes the dynamic division of the memory area. The specific steps for realizing the dynamic division of the memory area include:
[0037] Analyze and statistics the memory usage situation during the program trial debugging stage within a preset time period, and generate a static distribution memory pool configuration table;
[0038] The memory proxy management mechanism generates a static memory pool according to the static distribution memory pool configuration table, and then initializes the dynamic memory pool.
[0039] Among them, the generation steps of the static distribution memory pool configuration table include:
[0040] Obtain the memory usage data during the program operation within a preset time period. The usage data includes: the memory size applied by the user, the number of memory blocks used during stable operation, the peak number of memory blocks used, the resource waste number for a single application, the steady-state waste rate, and the peak waste rate.
[0041] Compare the steady-state waste rate and the peak waste rate with the preset thresholds, obtain the memory application sizes with the steady-state waste rate and the peak waste rate greater than the preset waste rate threshold, and add the corresponding memory sizes to the static memory pool configuration information table.
[0042] The calculation method of the steady-state waste rate is:
[0043]
[0044] The calculation method of the peak waste rate is:
[0045]
[0046] In a specific implementation of the embodiment of the present invention, in the debug mode, the proxy module initializes the memory area as a dynamic memory pool. As Figure 3 shown, after the program runs stably for a period of time, the program will count the memory usage data, such as the memory size applied, the count occupied during stable operation, the memory waste rate, etc. As Figure 4 shown is a schematic diagram for analyzing and counting the memory usage during the program operation. Figure 5 is a schematic diagram of the static memory pool generated by the dynamic memory pool according to the running statistics. A static distribution memory pool configuration table mainly based on different sizes and counts is generated according to the frequently used application information in the statistical information. As Figure 4 shown, set the waste rate threshold to 5%. That is, if the waste rate of the applied memory exceeds 5%, the memory of the corresponding size will be added to the static memory pool configuration table. For example, when the program is executed and repeatedly applies for 130B of memory, and the memory block in the memory pool is 64B at this time, 3 memory blocks need to be applied to meet the program operation. At this time, 64 * 3 - 130 = 62B is wasted, then 130B will be added to the static memory pool configuration information table.
[0047] In the normal mode, the memory management program first generates a static memory pool according to the static distribution memory pool configuration table, and then initializes the dynamic memory pool. The dynamic distribution memory pool includes dynamic memory blocks of different sizes and numbers, and the static memory pool includes static memory blocks of different sizes and different numbers; when responding to the memory read / write request of the embedded program, the static memory block with the same size as the requested memory in the static memory pool is preferentially allocated. If the requirement is met, it is used; if not, the corresponding memory is obtained from the dynamic memory pool.
[0048] Compared with the prior art, the present technical solution mainly solves the following problems:
[0049] In a low-resource system, how to effectively manage and utilize memory to improve the performance and stability of the system; how to effectively reduce memory fragmentation and improve the memory utilization efficiency and system performance. By means of dynamic-static conversion, the memory utilization rate is improved, different operating scenarios are quickly adapted, and combined with dynamic and static memory pools, the memory application and release time is reduced, and the program execution efficiency is improved.
[0050] Due to the advancement of the present technical solution, it can be widely applied in application fields such as computer systems, big data processing, cloud computing, and mobile application development. With the development of technology, the demand for memory in computer systems is increasing, and the problems of memory management and protection are becoming more and more important. The memory pool management and memory protection method based on a low-resource system proposed by the present invention can effectively improve the memory management efficiency, reduce memory fragmentation, and thus improve the performance and stability of the system. At the same time, the present invention can also effectively protect the memory and prevent the system from crashing due to memory access errors or illegal operations, thereby enhancing the robustness of the system. Therefore, the present invention has broad market demand and good application prospects.
[0051] By adopting the embodiments of the present invention, the following beneficial effects are achieved: The proxy module dynamically allocates memory areas according to the operation of the program, fully considering the characteristics of a low-resource system, can manage memory more effectively, improve the memory utilization efficiency, and reduce memory fragmentation. Combined with dynamic and static memory pools, the memory application and release time is reduced, and the program execution efficiency is improved. The design of the present invention considers the characteristics of a low-resource system. By optimizing memory management, efficient memory use and management can be achieved under limited system resources, and the system performance and stability can be improved.
[0052] Exemplary device
[0053] Figure 2 It is a block diagram of an embedded memory management method device shown according to an exemplary embodiment. Refer to Figure 2 , the device 200 includes a memory acquisition proxy module 210 and a memory reuse module 220
[0054] The memory acquisition proxy module 210 is used to apply to the system through the proxy module for a memory area for an embedded program to read / write, so as to obtain the address and length of the memory area;
[0055] The memory reuse module 220 is used to respond to a memory read / write request of an embedded program, and the proxy module allocates the address and length of a memory block to be operated in an available memory area based on a preset memory proxy management mechanism, and performs a memory read / write operation on the memory block to be operated according to the address and length of the memory block to be operated.
[0056] The embodiments of the disclosed device correspond to the technical solutions of the above-mentioned invention embodiments. For the specific operations of each module, reference may be made to the descriptions in the method embodiments and will not be elaborated herein.
[0057] Exemplary vehicle
[0058] Figure 6 FIG. is a block diagram of a vehicle 600 shown according to an exemplary embodiment. The vehicle 600 may be a fuel vehicle, a hybrid vehicle, an electric vehicle, a fuel cell vehicle, or other types of vehicles.
[0059] Refer to Figure 6 , the vehicle 600 may include multiple subsystems. For example, a drive system 610, a control system 620, a perception system 630, a communication system 640, an information display system 650, and a computing and processing system 660. The vehicle 600 may also include more or fewer subsystems, and each subsystem may further include multiple components, which will not be elaborated one by one herein.
[0060] The drive system 610 includes components that provide power motion for the vehicle 600. For example, an engine, an energy source, a transmission, etc.
[0061] The control system 620 includes components that provide control for the vehicle 600. For example, vehicle control, cockpit equipment control, driving assistance control, etc.
[0062] The perception system 630 includes components that provide perception of the surrounding environment for the vehicle 600. For example, a vehicle positioning system, a laser sensor, a voice sensor, an ultrasonic sensor, a camera device, etc.
[0063] The communication system 640 includes components that provide communication connections for the vehicle 600. For example, a mobile communication network (such as, 3G, 4G, 5G networks, etc.), WiFi, Bluetooth, vehicle networking, etc.
[0064] The information display system 650 includes components that provide various information displays for the vehicle 600. For example, vehicle information display, navigation information display, entertainment information display, etc.
[0065] The computing and processing system 660 includes components that provide data computing and processing capabilities for the vehicle 600. The computing and processing system 660 may include at least one processor 661 and a memory 662. The processor 661 may execute instructions stored in the memory 662.
[0066] The processor 661 can be any conventional processor, such as a commercially available CPU. The processor may also include, for example, a Graphic Process Unit (GPU), a Field Programmable Gate Array (FPGA), a System on Chip (SOC), an Application Specific Integrated Circuit (ASIC), or a combination thereof.
[0067] The memory 662 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0068] In an embodiment of the present disclosure, a set of instruction sets is stored in the memory 662, and the processor 661 can execute the instruction sets to implement all or part of the steps of the memory management method described in any of the above exemplary embodiments.
[0069] Exemplary electronic device
[0070] Figure 7 is a block diagram of an electronic device 700 shown according to an exemplary embodiment. The electronic device 700 can be a vehicle controller, an in-vehicle terminal, an in-vehicle computer, or other types of electronic devices.
[0071] Refer to Figure 7 , the electronic device 700 may include at least one processor 710 and a memory 720. The processor 710 can execute instructions stored in the memory 720. The processor 710 is communicatively connected to the memory 720 via a data bus. In addition to the memory 720, the processor 710 can also be communicatively connected to an input device 730, an output device 740, and a communication device 750 via the data bus.
[0072] The processor 710 can be any conventional processor, such as a commercially available CPU. The processor may also include, for example, a Graphic Process Unit (GPU), a Field Programmable Gate Array (FPGA), a System on Chip (SOC), an Application Specific Integrated Circuit (ASIC), or a combination thereof.
[0073] The memory 720 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0074] In an embodiment of the present disclosure, executable instructions are stored in the memory 720, and the processor 710 can read the executable instructions from the memory 720 and execute the instructions to implement all or part of the steps of any of the above-described exemplary embodiments of the embedded memory management method.
[0075] Exemplary computer-readable storage medium
[0076] In addition to the above methods and apparatuses, an exemplary embodiment of the present disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product. The computer program product includes computer program instructions that can be executed by a processor to implement all or part of the steps described in any of the above methods.
[0077] The computer program product can be written in any combination of one or more programming languages for programming code to perform the operations of the embodiments of the present application. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages and scripting languages (such as Python). The program code can be executed entirely on the user computing device, partially on the user device, executed as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0078] The computer-readable storage medium can adopt any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium can, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the readable storage medium include: static random access memory (SRAM) with one or more wire electrical connections, electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk, or any suitable combination of the above.
[0079] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include well-known common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and examples are only regarded as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
[0080] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.
Claims
1. An embedded memory management method, characterized in that: include: Apply to the system for a memory area for reading / writing by the embedded program through the proxy module, thereby obtaining the address and length of the memory area; In response to the memory read / write request of the embedded program, the proxy module allocates the address and length of the memory block to be operated in the available memory area based on the preset memory proxy management mechanism, and performs memory read / write operations on the memory block to be operated according to the address and length of the memory block to be operated.
2. The embedded memory management method according to claim 1, characterized in that: The memory area for embedded programs to read / write includes a dynamically distributed memory pool or a statically distributed memory pool, wherein the dynamically distributed memory pool includes dynamic memory blocks of different sizes and numbers, and the static memory pool includes static memory blocks of different sizes and numbers; When responding to a memory read / write request of an embedded program, a static memory block in a static memory pool having the same size as the requested memory is preferentially allocated.
3. The embedded memory management method according to claim 1, characterized in that: The preset memory proxy management mechanism analyzes and counts the memory application and release status of the program within a preset time period during program trial operation, thereby realizing dynamic division of the memory area.
4. The embedded memory management method according to claim 3, characterized in that: The specific steps of implementing the dynamic division of the memory area include: During the program trial debugging phase, the memory usage of the program during runtime within a preset time period is analyzed and counted to generate a static distributed memory pool configuration table; The memory agent management mechanism generates a static memory pool according to the static distributed memory pool configuration table, and then initializes the dynamic memory pool.
5. The embedded memory management method according to claim 4, characterized in that: The steps of generating the static distributed memory pool configuration table include: Obtaining memory usage data when the program is running within a preset time period, the usage data including: the memory size requested by the user, the number of memory blocks used during stable operation, the peak number of memory blocks used, the number of wasted resources in a single request, the steady-state waste rate, and the peak waste rate; The steady-state waste rate and the peak waste rate are compared with a preset threshold, the memory application size of the steady-state waste rate and the peak waste rate greater than the preset waste rate threshold is obtained, and the corresponding memory size is added to the static memory pool configuration information table.
6. The embedded memory management method according to claim 5, characterized in that: The steady-state waste rate calculation method is: The peak waste rate calculation method is:
7. An embedded memory management device, characterized in that: include: Obtain a memory proxy module, and apply to the system for a memory area for the embedded program to read / write through the proxy module, thereby obtaining the address and length of the memory area; A memory multiplexing module, in response to a memory read / write request of an embedded program, the proxy module allocates the address and length of a memory block to be operated in an available memory area based on a preset memory proxy management mechanism, and performs a memory read / write operation on the memory block to be operated according to the address and length of the memory block to be operated.
8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the embedded memory management method described in any one of claims 1-6.
9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the embedded memory management method described in any one of claims 1-6 are implemented.
10. A vehicle, characterized in that: A set of instruction sets is stored, and the instruction sets are executed by the vehicle to implement the embedded memory management method described in any one of claims 1-6.