Memory allocation method and device, computing equipment, storage medium and program product
By pre-stored the display parameters of the display unit into global memory and extracted to local memory during initialization, the problem of excessive memory usage during complex display objects is solved, and processing efficiency and system performance are improved.
Patent Information
- Application Number
- CN202411351736.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-20
AI Technical Summary
In the prior art, when processing complex display objects, the memory usage of the processing system is too high, resulting in reduced display processing efficiency and lag problems.
By storing the display parameters of the display unit to be used into global memory, and when initializing the target processing system, the required display parameters are extracted into local memory, and the memory is dynamically managed to avoid unnecessary memory usage.
It effectively reduces memory fragmentation, improves memory usage efficiency, simplifies memory management, and improves the system's processing speed and overall performance.
Smart Images

Figure CN119166546A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a memory allocation method and apparatus, a computing device, a storage medium, and a program product. Background Art
[0002] With the continuous development of Internet technology and display technology, people have higher and higher requirements for display scenes such as games, animations, and virtual worlds. In particular, for display objects such as special effects, the elements that need to be displayed are many and complex, and the display processing is even more complicated.
[0003] In current technology, developers often use a processing system that includes multiple display units to perform display processing on the above-mentioned complex display objects. By configuring multiple display units in the processing system, such as an emission display unit, a shape display unit, a color display unit, a collision display unit, etc., each display unit can be individually configured with display parameters, and the display of a display object can be achieved based on the display parameters configured by multiple display units.
[0004] However, since each display unit of the processing system is configured with specific display parameters, this will cause the processing system to occupy a high memory consumption. When it is necessary to display complex display objects in a large scene, many different processing systems will be called. When the number of processing systems reaches a certain scale, the display parameters based on the display processing will increase massively, and the required memory will also increase, resulting in reduced display processing efficiency, further causing problems such as display freezes in the display scene. Therefore, it is urgent to propose a reasonable memory allocation solution. Summary of the invention
[0005] In view of this, an embodiment of this specification provides a memory allocation method. One or more embodiments of this specification also relate to a memory allocation device, a computing device, a computer-readable storage medium and a computer program product to solve the technical defects existing in the prior art.
[0006] According to a first aspect of an embodiment of this specification, a memory allocation method is provided, including: Storing display parameters of each display unit to be used in a global memory, and setting the state of each display unit to a state to be used; Initializing a target processing system, and determining a first display unit in use in the target processing system; The display parameters of the first display unit are extracted from the global memory and stored in the local memory corresponding to the target processing system.
[0007] Optionally, after initializing the target processing system, the method further includes: Determine a second display unit in the target processing system that is in a ready-to-use state; The pointer of the first display unit is pointed to the local memory, and the pointer of the second display unit is pointed to the global memory.
[0008] Optionally, extracting the display parameters of the first display unit from the global memory and storing them in a local memory corresponding to the target processing system includes: extracting display parameters of the first display unit from the global memory; Determining a first target memory in a local memory corresponding to the target processing system based on a memory size occupied by display parameters of the first display unit; The display parameters of the first display unit are stored in the first target memory.
[0009] Optionally, after extracting the display parameters of the first display unit from the global memory and storing them in a local memory corresponding to the target processing system, the method further includes: When receiving a state switching instruction, switching the state of a third display unit indicated by the state switching instruction in the target processing system; Based on the state of the third display unit, the display parameters of the third display unit are stored in a local memory corresponding to the target processing system.
[0010] Optionally, based on the state of the third display unit, storing the display parameters of the third display unit in a local memory corresponding to the target processing system includes: Based on the state of the third display unit, determining a fourth display unit in use in the target processing system after the state switching; The display parameters of the fourth display unit are stored in a local memory corresponding to the target processing system.
[0011] Optionally, the state switching instruction is an on instruction; the fourth display unit includes the first display unit and the third display unit; and the state switching of the third display unit indicated by the state switching instruction in the target processing system includes: Switching the state of the third display unit indicated by the start instruction in the target processing system to a use state; The step of storing the display parameters of the fourth display unit into a local memory corresponding to the target processing system includes: Extracting the display parameters of the third display unit from the global memory, and extracting the display parameters of the first display unit from the local memory; The display parameters of the third display unit and the display parameters of the first display unit are stored in a local memory corresponding to the target processing system.
[0012] Optionally, the state switching instruction is a closing instruction; and the state switching of the third display unit indicated by the state switching instruction in the target processing system includes: The state of the third display unit indicated by the shutdown instruction in the target processing system is switched to a standby state.
[0013] According to a second aspect of an embodiment of this specification, a memory allocation device is provided, including: The storage module is configured to store the display parameters of each display unit to be used into the global memory, and set the state of each display unit to be in a ready-to-use state.
[0014] The initialization module is configured to initialize the target processing system and determine a first display unit in use in the target processing system.
[0015] The extraction module is configured to extract the display parameters of the first display unit from the global memory and store them in the local memory corresponding to the target processing system.
[0016] According to a third aspect of an embodiment of this specification, a computing device is provided, including: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the above-mentioned memory allocation method are implemented.
[0017] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and the computer program / instruction implements the steps of the above-mentioned memory allocation method when executed by a processor.
[0018] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instruction, which implements the steps of the above-mentioned memory allocation method when executed by a processor.
[0019] An embodiment of the present specification implements a memory allocation method, including: storing the display parameters of each display unit to be used in the global memory, and setting the state of each display unit to be used; initializing the target processing system, determining the target display unit used by the target processing system; extracting the display parameters of the target display unit from the global memory and storing them in the local memory corresponding to the target processing system, and setting the state of the target display unit to be used. By pre-storing the display parameters of the display unit in the global memory, and extracting the parameters of the display unit to be used into the local memory when initializing the target processing system, the memory fragmentation of the processing system is effectively reduced, the memory usage efficiency is improved, and the memory management is simplified. At the same time, by dynamically allocating local memory, unnecessary memory occupation is avoided, thereby improving the processing speed and overall performance of the system. BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 is a flowchart of a memory allocation method provided by an embodiment of this specification; Figure 2 It is a schematic diagram of building a global shared memory in a memory allocation method provided in one embodiment of this specification; Figure 3 It is a schematic diagram of memory after the processing system is optimized in a memory allocation method provided in one embodiment of this specification; Figure 4 It is a target memory diagram of an opening instruction in a memory allocation method provided in an embodiment of the present specification; Figure 5 is a target memory diagram of a close instruction in a memory allocation method provided in an embodiment of the present specification; Figure 6 It is a process flow chart of a memory allocation method applied to a game development scenario provided by an embodiment of this specification; Figure 7 It is a structural schematic diagram of a memory allocation device provided by an embodiment of this specification; Figure 8 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0020] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0021] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0022] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0023] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0024] First, the terms involved in one or more embodiments of this specification are explained.
[0025] Display unit: A display unit is an independent module or component used in modern display technology to handle specific types of display tasks, such as particle emission, shape drawing, color rendering, and collision detection. Each unit can be configured with display parameters independently and work together to achieve complex visual effects.
[0026] Memory Move: Memory Move refers to the operation of copying or moving data from one memory location to another. This operation is very common in computer programming, especially when it is necessary to reorganize the data structure in memory or migrate data.
[0027] Memory reallocation: Memory reallocation refers to changing the size or location of allocated memory to better meet current needs.
[0028] In this specification, a memory allocation method is provided. This specification also relates to a memory allocation device, a computing device, a computer-readable storage medium, and a computer program product, which are described in detail one by one in the following embodiments.
[0029] See also Figure 1 , Figure 1 A flowchart of a memory allocation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0030] Step 102: Store the display parameters of each display unit to be used into the global memory, and set the state of each display unit to be in a ready-to-use state.
[0031] The memory allocation method provided in the embodiments of this specification can be applied to various applications, websites or applets, including but not limited to: Unity development engine, 3DS Max development engine, Unreal Engine development engine, Maya development engine, Blender development engine, etc. Specifically, it can be executed by a personal computer (PC), a workstation, a game console, a personal mobile device, a server, etc., and this specification does not make specific limitations on this. Exemplarily, the memory allocation method provided in the embodiments of this specification can be applied to the Unity development engine running on a personal computer.
[0032] A display unit refers to a small software module or component in a processing system that is used to handle specific types of display tasks. Different display units can perform different display functions and achieve different display effects. For example, a speed display unit can display the moving speed of a target object that needs to be displayed. The display parameters of a display unit refer to the specific configuration parameter values that control the appearance and behavior of the display unit. For example, the display parameters of a speed display unit can be 500m / s, indicating that the moving speed of the target object that needs to be displayed is 500m / s. Global memory is a piece of memory allocated in the operating system that can be read by multiple different processing systems to read the display parameters of each display unit. The pending state means that the current display unit is not called by the processing system.
[0033] For example, Figure 2 FIG. 4 shows a schematic diagram of a global shared memory construction in a memory allocation method provided in an embodiment of the present specification. Figure 2As shown: the global memory stores display parameters of the emission display unit, size display unit, shape display unit, speed display unit, color display unit, and trailing display unit, and the state of each display unit is in a standby state. The display parameters stored in the global memory are the initial parameters of the display unit. When the display unit is in a standby state, it is not called by the processing system, so its initial parameters are determined and unchanged values.
[0034] In the embodiments of the present specification, by storing the display parameters of each display unit to be used in the global memory and setting the state of each display unit to be used, the display parameters of each display unit can be uniformly managed, the access operation can be simplified, the memory copy can be reduced, and the data transmission efficiency can be improved, thereby improving the overall performance and data consistency.
[0035] Step 104: Initialize the target processing system and determine the first display unit in the target processing system that is in use.
[0036] The processing system is an architecture for managing the display unit and its display parameters. Different processing systems can be selected according to different usage scenarios or application fields, such as graphics rendering system, audio processing system, network communication system, particle system, etc. This specification does not make specific limitations on this. For example, the processing system can be a particle system (Particle System), and the display unit can include an emission display unit, a size display unit, a shape display unit, a speed display unit, a color display unit, and a trailing display unit, etc. This specification does not make specific limitations on this.
[0037] Initializing the target processing system refers to the process of setting various parameters of the target processing system before it starts running. Specifically, the reference for initialization can be preset by the user in advance or calculated by the current application. The initialization process can include creating a processing object of the target processing system, setting the initial display parameters and status of each display unit in the target processing system, etc. Exemplarily, the A particle system is initialized, and according to the display units and display parameters included in the display units that should be used in the A particle system preset by the user in advance, the emission display unit, color display unit, and size display unit included in the A particle system are set to be in use, and the shape display unit, speed display unit, and trailing display unit are set to be in a ready-to-use state, and the initial display parameters of each display unit are configured.
[0038] After the target processing system is initialized, the display unit in use is determined as the first display unit according to the states of the set display units.
[0039] In the embodiments of the present specification, the target processing system is initialized, the initial parameters and status of each display unit are set, and the display unit in use is determined to be the first display unit, thereby ensuring that the target processing system operates according to the predetermined configuration from the beginning. At the same time, the display units actually used by the target processing system can be determined, avoiding processing of unused display units, thereby improving the processing efficiency of the target processing system.
[0040] Step 106: extract the display parameters of the first display unit from the global memory and store them in the local memory corresponding to the target processing system.
[0041] The local memory is a piece of memory allocated to each processing system in the memory space, and is used to store display parameters of the display unit of each usage state of the processing system.
[0042] After determining the first display unit in use in the target processing system, various display parameters corresponding to the first display unit are extracted from the global memory, and the display parameters are stored in the local memory corresponding to the target processing system.
[0043] Exemplarily, it is determined that the first display unit in use in the A particle system is an emission display unit, a color display unit, and a size display unit, then the display parameters of these three display units are extracted from the global memory and stored in the local memory corresponding to the A particle system for the A particle system to call during processing.
[0044] In the embodiment of the present specification, by extracting the display parameters of the first display unit in use from the global memory and storing them in the local memory corresponding to the target processing system, it is ensured that the target processing system can quickly and efficiently access and use the display parameters of each display unit in use, thereby optimizing the overall performance and response speed.
[0045] In an optional embodiment of the present specification, after step 104, the following specific steps are also included: Determine a second display unit in the target processing system that is in a ready-to-use state; The pointer of the first display unit points to the local memory, and the pointer of the second display unit points to the global memory.
[0046] The pointer of each display unit in the processing system will point to the specific memory address block in the memory where the display parameters of each display unit are stored. After determining the first display unit in use and the second display unit in the waiting state, for the first display unit, since its display parameters will be extracted from the global memory and stored in the memory address block of the local memory corresponding to the processing system, the pointer of the first display unit is set to point to the memory address block of the local memory. For the second display unit, its display parameters are not extracted from the global memory, so the pointer of the second display unit is set to point to the memory address block of the global memory.
[0047] For example, Figure 3 FIG. 1 shows a schematic diagram of memory after the processing system is optimized in a memory allocation method provided in one embodiment of the present specification, such as Figure 3 As shown: the display parameters of the emission display unit, color display unit, and size display unit in use are stored in the local memory, and their pointers point to themselves (not shown by arrows in the figure); while the display parameters of the shape display unit, speed display unit, and trailing display unit in the waiting state are stored in the global memory, so their pointers point to the display parameters stored in the corresponding display units in the global memory.
[0048] In the embodiment of the present specification, by pointing the pointer of the first display unit in use to the local memory and the pointer of the second display unit in the to-be-used state to the global memory, it can be ensured that the target processing system can quickly access the display parameters of the display unit currently in use, thereby improving processing efficiency. At the same time, the parameters of the to-be-used unit are retained in the global memory for rapid switching during subsequent use, thereby optimizing overall performance and resource utilization.
[0049] In an optional embodiment of the present specification, step 106 includes the following specific steps: Extracting display parameters of the first display unit from the global memory; Determining a first target memory in a local memory corresponding to the target processing system based on a memory size occupied by display parameters of the first display unit; The display parameters of the first display unit are stored in the first target memory.
[0050] After the display parameters of the first display unit are extracted from the global memory, the size of the memory space occupied by the display parameters of the first display unit is counted, and then a first target memory of the same size is determined in the local memory of the target processing system, and the display parameters of the first display unit are stored in the first target memory. Preferably, the first target memory is a continuous memory, and the display parameters of the first display unit are continuously stored in the first target memory.
[0051] Exemplarily, taking the aforementioned particle system A as an example, after extracting the display parameters of the emission display unit, color display unit, and size display unit belonging to the first display unit from the global memory, the size of the memory space occupied by these display parameters is counted, and then in the local memory corresponding to the particle system A, a continuous and same-size memory is determined as the first target memory, and then the emission display unit display parameters, color display unit display parameters, and size display unit display parameters are continuously stored in the first target memory.
[0052] In the embodiments of the present specification, by extracting the display parameters of the first display unit from the global memory and allocating a first target memory of the same size in the local memory of the target processing system, and continuously storing the display parameters in this continuous memory, the data access speed and processing efficiency can be significantly improved, memory fragmentation can be reduced, and data integrity and continuity can be ensured, thereby optimizing the performance and response speed of the system.
[0053] In an optional embodiment of the present specification, after step 106, the following specific steps are also included: When receiving the state switching instruction, switching the state of the third display unit indicated by the state switching instruction in the target processing system; Based on the state of the third display unit, the display parameters of the third display unit are stored in the local memory corresponding to the target processing system.
[0054] After the display parameters of the first display unit are stored in the local memory, the target processing system starts the processing operation. When the application needs to display the display effect of the new target object during the processing, the state of each display unit in the target processing system will be switched as required, thereby generating a state switching instruction to instruct one or more display units in the target processing system to switch the state, and the display unit that needs to switch the state is the third display unit.
[0055] Based on the state of the third display unit after switching, the display parameters of the third display unit are stored in the local memory of the target processing system. The storage process includes storing the display parameters of the third display unit and deleting the display parameters of the third display. In actual applications, after the state switching of the third display unit is completed, for the display parameters of the third display unit, an independent memory can be reallocated in the local memory of the processing system for storage operations; or the storage operation can be performed after the memory corresponding to the first display unit that has been allocated previously; or the previously allocated memory can be released and a continuous memory can be reallocated for storage operations. This specification does not make specific limitations on this.
[0056] In the embodiments of the present specification, when a state switching instruction is received, the state of the third display unit in the target processing system is switched, and the corresponding display parameters are stored or deleted in the local memory according to the switched state. In this way, the state and parameters of the display unit can be dynamically adjusted, the flexibility and response speed of the system can be improved, and resource allocation in the processing process can be ensured to be more efficient and timely.
[0057] In an optional embodiment of the present specification, based on the state of the third display unit, the display parameters of the third display unit are stored in the local memory corresponding to the target processing system, including the following specific steps: Based on the state of the third display unit, determining a fourth display unit in the target processing system that is in use after the state switching; The display parameters of the fourth display unit are stored in a local memory corresponding to the target processing system.
[0058] After the state switching of the third display unit is completed, the display unit in the target processing system that is in use is re-determined as the fourth display unit. Specifically, the third display unit that has completed the state switching can be directly used as the fourth display unit; the third display unit that is in use after the state switching is completed and the first display unit that was originally in use can also be used together as the fourth display unit; the other display units of the first display unit that was originally in use, except for the third display unit that is in a waiting state due to the state switching, can also be used as the fourth display unit. After the fourth display unit is determined, the display parameters of the fourth display unit can be stored in the local memory corresponding to the target processing system.
[0059] In the embodiment of the present specification, after completing the state switching of the third display unit, the fourth display unit in use is re-determined, and its display parameters are stored in the local memory corresponding to the target processing system. This ensures that the display unit currently in use can quickly access its parameters, improves processing efficiency, and optimizes memory usage to ensure smooth system operation and quick response.
[0060] In an optional embodiment of the present specification, the state switching instruction is an on instruction; the fourth display unit includes a first display unit and a third display unit; and the state of the third display unit indicated by the state switching instruction in the target processing system is switched, including the following specific steps: Switching the state of the third display unit indicated by the start instruction in the target processing system to a use state; Storing the display parameters of the fourth display unit into a local memory corresponding to the target processing system includes: Extracting display parameters of the third display unit from the global memory, and extracting display parameters of the first display unit from the local memory; The display parameters of the third display unit and the display parameters of the first display unit are stored in a local memory corresponding to the target processing system.
[0061] When the state switching instruction is an on instruction, it indicates that the target processing system needs to dynamically enable the second display unit which is in the standby state, and switches the state of the second display unit from the standby state to the use state according to the state switching instruction. At this time, the switched display unit is used as the third display unit, and the fourth display unit includes the first display unit and the third display unit.
[0062] When storing the display parameters of the fourth display unit into the local memory corresponding to the target processing system, since the display parameters of the first display unit have been extracted from the global memory and stored in the local memory after initialization, it is only necessary to extract the display parameters of the third display unit from the global memory and extract the display parameters of the first display unit from the local memory. Then, the display parameters of the fourth display unit are stored into the local memory corresponding to the target processing system.
[0063] For example, Figure 4 FIG. 1 shows a schematic diagram of a target memory of an open instruction in a memory allocation method provided by an embodiment of the present specification, such as Figure 4 As shown: before the state switching, the display parameters of the emission display unit, color display unit, and size display unit in the target processing system that are in use are stored in the local memory, and the display parameters of the shape display unit, speed display unit, and trailing display unit that are in the waiting state are stored in the global memory. When the state switching instruction is an on instruction and the indicated display unit is the speed display unit, the state of the speed display unit in the target processing system is switched from the waiting state to the used state, and the display parameters corresponding to the speed display unit are extracted from the global memory and stored at the end of the display parameters of the display unit in the used state that have been stored in the local memory of the target processing system, and memory reallocation (Reallocate) is used to expand the memory allocation, and then the pointers of each display unit in the target processing system are updated.
[0064] In the embodiment of the present specification, after receiving the start-up command, the state of the third display unit is switched to the use state, and its display parameters are stored in the local memory together with the display parameters of the first display unit already in the local memory. This ensures that all currently used display units can efficiently access the display parameters, improves the processing speed and response efficiency of the system, and optimizes memory usage, making the system run more smoothly.
[0065] In an optional embodiment of the present specification, the state switching instruction is a closing instruction; and the state of the third display unit indicated by the state switching instruction in the target processing system is switched, further comprising the following specific steps: The state of the third display unit indicated by the shutdown instruction in the target processing system is switched to a standby state.
[0066] In the case where the state switching instruction is a closing instruction, it means that the target processing system needs to dynamically close the first display unit in the use state. At this time, the third display unit is the display unit to be dynamically closed, and the fourth display unit includes the display units in the first display unit except the third display unit. After determining the fourth display unit, the display parameters corresponding to the fourth display unit can be obtained and stored in the local memory of the target processing system. Specifically, because the fourth display unit is the display unit in the first display unit except the third display unit, it has been set to the use state when the target processing system is initialized, so its corresponding display parameters have been stored in the memory address block previously allocated in the local memory of the target processing system. At this time, it is only necessary to obtain the display parameters from the previously allocated memory address block, and then reallocate a new memory address block for storage according to the size of the memory space occupied by the display parameters.
[0067] For example, Figure 5 FIG. 1 shows a schematic diagram of a target memory of a close instruction in a memory allocation method provided by an embodiment of the present specification, such as Figure 5 As shown: before the state switching, the display parameters of the emission display unit, color display unit, and size display unit in the target processing system that are in use are stored in the local memory, and the display parameters of the shape display unit, speed display unit, and trailing display unit that are in the waiting state are stored in the global memory. When the state switching instruction is a closing instruction and the indicated display unit is a color display unit, the state of the color display unit in the target processing system is switched from the use state to the waiting state, and its corresponding display parameters are deleted from the local memory of the target processing system, and the display parameters of the subsequent size display units are moved forward to cover the memory of the display parameters of the original color display unit by using memory move, and the memory space occupied by the display parameters of the emission display unit and the size display unit in the open state is recalculated, and memory reallocation is used to reduce the memory allocation, and then the pointers of each display unit in the target processing system are updated.
[0068] In an embodiment of the present specification, after receiving a shutdown command, the state of the third display unit is switched to a standby state, and its display parameters are removed from the local memory, while the display parameters of other display units that are still in use are retained in the local memory. This can release memory resources that are no longer in use, optimize memory usage, improve system efficiency and response speed, and ensure that resource allocation is more reasonable and efficient.
[0069] The following combination Figure 6 , taking the application of the memory allocation method provided in this specification in the game development scenario as an example, the memory allocation method is further explained. Figure 6 A processing flow chart of a memory allocation method applied to a game development scenario provided by an embodiment of the present specification is shown, which specifically includes the following steps.
[0070] Step 602: construct a globally shared memory containing display parameters of all modules, and set all modules to a closed state. The global memory block will serve as the default memory space for unused modules; Step 604: Initialize the particle system, count the modules actually used by the particle system, calculate the memory size occupied by the display parameters of the modules used in the particle system, and apply for a continuous memory according to the occupied memory size, allocate it to the modules actually used in the particle system, and set the pointers of other unused modules in the particle system to point to the memory address blocks in the global shared memory; Step 606: when a module needs to be dynamically enabled, the dynamically enabled module is merged into the end of the enabled modules, the memory size occupied by the display parameters of the modules used in the particle system is recalculated, and according to the occupied memory size, new memory is reallocated for storage using memory reallocation technology, and the used module pointer is pointed to the newly allocated memory; Step 608: When it is necessary to dynamically close a module, the memory movement technology is used to move the module behind the deleted module forward to overwrite the memory of the dynamically closed module, and the memory size occupied by the display parameters of the module used in the particle system is recalculated. Based on the occupied memory size, the memory reallocation technology is used to reallocate new memory for storage, and the used module pointer is pointed to the newly allocated memory.
[0071] In the embodiments of the present specification, efficient memory utilization and fast state switching are achieved by constructing a global shared memory and dynamically managing the display parameters of the modules in the particle system. Specifically, unused module parameters are stored in the global memory, and continuous memory is allocated to the modules actually used, thereby reducing memory fragmentation and improving memory access efficiency. When it is necessary to dynamically open and close the module, the continuity and compactness of the memory are ensured through memory reallocation and movement technology, further optimizing memory usage and improving the response speed and overall performance of the system.
[0072] Corresponding to the above method embodiment, this specification also provides a memory allocation device embodiment, Figure 7 FIG. 2 shows a schematic diagram of the structure of a memory allocation device provided by an embodiment of the present specification. Figure 7 As shown, the device comprises: The storage module 702 is configured to store the display parameters of each display unit to be used into the global memory, and set the state of each display unit to be in a ready-to-use state.
[0073] The initialization module 704 is configured to initialize the target processing system and determine a first display unit in use in the target processing system.
[0074] The extraction module 707 is configured to extract the display parameters of the first display unit from the global memory and store them into the local memory corresponding to the target processing system.
[0075] Optionally, the initialization module further includes: a pointing module configured to determine a second display unit in a used state in a target processing system; The pointer of the first display unit points to the local memory, and the pointer of the second display unit points to the global memory.
[0076] Optionally, the extraction module is further configured to: Extracting display parameters of the first display unit from the global memory; Determining a first target memory in a local memory corresponding to the target processing system based on a memory size occupied by display parameters of the first display unit; The display parameters of the first display unit are stored in the first target memory.
[0077] Optionally, the device further comprises: A state switching module is configured to switch the state of a third display unit indicated by the state switching instruction in the target processing system when receiving the state switching instruction; Based on the state of the third display unit, the display parameters of the third display unit are stored in the local memory corresponding to the target processing system.
[0078] Optionally, the state switching module is further configured as follows: Based on the state of the third display unit, determining a fourth display unit in the target processing system that is in use after the state switching; The display parameters of the fourth display unit are stored in a local memory corresponding to the target processing system.
[0079] Optionally, the state switching instruction is an on instruction; the fourth display unit includes the first display unit and the third display unit; the state switching module further includes: an opening instruction unit configured to switch the state of the third display unit indicated by the opening instruction in the target processing system to a use state; Storing the display parameters of the fourth display unit into a local memory corresponding to the target processing system includes: Extracting display parameters of the third display unit from the global memory, and extracting display parameters of the first display unit from the local memory; The display parameters of the third display unit and the display parameters of the first display unit are stored in a local memory corresponding to the target processing system.
[0080] Optionally, the state switching instruction is a closing instruction; the state switching module further includes: Shutdown command unit, configured as: The state of the third display unit indicated by the shutdown instruction in the target processing system is switched to a standby state.
[0081] The above is a schematic scheme of a memory allocation device of this embodiment. It should be noted that the technical scheme of the memory allocation device and the technical scheme of the above-mentioned memory allocation method belong to the same concept, and the details not described in detail in the technical scheme of the memory allocation device can be found in the description of the technical scheme of the above-mentioned memory allocation method.
[0082] Figure 8 The structure block diagram of a computing device provided by an embodiment of the present specification is shown. The components of the computing device 800 include but are not limited to a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and the database 850 is used to store data.
[0083] The computing device 800 also includes an access device 840 that enables the computing device 800 to communicate via one or more networks 860. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 840 may include one or more of any type of network interface (e.g., a Network Interface Controller (NIC)) of wired or wireless type, such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, and a Near Field Communication (NFC).
[0084] In one embodiment of the present specification, the above components of the computing device 800 and Figure 8 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 8 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0085] The computing device 800 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 800 may also be a mobile or stationary server.
[0086] The processor 820 is used to execute the following computer program / instruction, which implements the steps of the above-mentioned memory allocation method when executed by the processor.
[0087] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned memory allocation method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned memory allocation method.
[0088] An embodiment of the present specification further provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned memory allocation method when executed by a processor.
[0089] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned memory allocation method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned memory allocation method.
[0090] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned memory allocation method when executed by a processor.
[0091] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the above-mentioned memory allocation method belong to the same concept, and the details not described in detail in the technical scheme of the computer program product can be referred to the description of the technical scheme of the above-mentioned memory allocation method.
[0092] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0093] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the contents contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0094] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0095] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0096] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A memory allocation method, characterized in that: include: Storing the display parameters of each display unit to be used in the global memory, and setting the state of each display unit to be in a state to be used; Initializing a target processing system, and determining a first display unit in use in the target processing system; The display parameters of the first display unit are extracted from the global memory and stored in the local memory corresponding to the target processing system.
2. The memory allocation method according to claim 1, characterized in that: After the target processing system is initialized, the method further includes: Determine a second display unit in the target processing system that is in a ready-to-use state; The pointer of the first display unit is pointed to the local memory, and the pointer of the second display unit is pointed to the global memory.
3. The memory allocation method according to claim 1, characterized in that: The step of extracting the display parameters of the first display unit from the global memory and storing them in a local memory corresponding to the target processing system includes: extracting display parameters of the first display unit from the global memory; Determining a first target memory in a local memory corresponding to the target processing system based on a memory size occupied by display parameters of the first display unit; The display parameters of the first display unit are stored in the first target memory.
4. The memory allocation method according to any one of claims 1 to 3, characterized in that: After extracting the display parameters of the first display unit from the global memory and storing them in the local memory corresponding to the target processing system, the method further includes: When receiving a state switching instruction, switching the state of a third display unit indicated by the state switching instruction in the target processing system; Based on the state of the third display unit, the display parameters of the third display unit are stored in a local memory corresponding to the target processing system.
5. The memory allocation method according to claim 4, characterized in that: Based on the state of the third display unit, storing the display parameters of the third display unit in a local memory corresponding to the target processing system includes: Based on the state of the third display unit, determining a fourth display unit in use in the target processing system after the state switching; The display parameters of the fourth display unit are stored in a local memory corresponding to the target processing system.
6. The memory allocation method according to claim 5, characterized in that: The state switching instruction is an on instruction; the fourth display unit includes the first display unit and the third display unit; the state switching of the third display unit indicated by the state switching instruction in the target processing system includes: Switching the state of the third display unit indicated by the start instruction in the target processing system to a use state; The step of storing the display parameters of the fourth display unit into a local memory corresponding to the target processing system includes: Extracting the display parameters of the third display unit from the global memory, and extracting the display parameters of the first display unit from the local memory; The display parameters of the third display unit and the display parameters of the first display unit are stored in a local memory corresponding to the target processing system.
7. The memory allocation method according to claim 5, characterized in that: The state switching instruction is a closing instruction; and the state switching of the third display unit indicated by the state switching instruction in the target processing system includes: The state of the third display unit indicated by the shutdown instruction in the target processing system is switched to a standby state.
8. A memory allocation device, characterized in that: include: A setting module, configured to store the display parameters of each display unit to be used into a global memory, and set the state of each display unit to be used; An initialization module is configured to initialize the target processing system and determine a first display unit in use in the target processing system; The allocation module is configured to extract the display parameters of the first display unit from the global memory and store them in the local memory corresponding to the target processing system.
9. A computing device, characterized in that include: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the memory allocation method described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: A computer program / instruction is stored, and when the computer program / instruction is executed by a processor, the steps of the memory allocation method according to any one of claims 1 to 7 are implemented.
11. A computer program product, characterized in that It includes a computer program / instruction, which, when executed by a processor, implements the steps of the memory allocation method described in any one of claims 1 to 7.
