Address adjustment method and device, equipment and storage medium
Patent Information
- Application Number
- CN202210774943.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-01
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-07-01
AI Technical Summary
这样一来,可能导致多个对象占用相同的内存空间,进而造成数据发生错乱
[0027]本公开提供的技术方案至少带来以下有益效果:当接收到热更新请求时,服务器可以获取多个对象中每个对象的内存地址和多个对象更新后的对象大小,内存地址为对象占用的内存空间对应的地址。之后,服务器可以根据多个对象中每个对象占用的内存空间和多个对象更新后的对象大小,确定第一类对象和第二类对象,第一类对象为多个对象中占用的内存空间小于更新后的对象大小的对象,第二类对象为多个对象中占用的内存空间大于或者等于更新后的对象大小的对象。然后,服务器可以将第一类对象按照更新后的对象大小调整至第一目标地址,第一目标地址的起始地址为第一目标对象的内存地址之后的地址,第一目标对象为第二类对象中最后一个对象。也就是说,服务器可以将第一目标地址的起始地址作为存储第一类对象的起始地址,将内存空间中的末位内存地址作为存储第一类对象的末位内存地址,扩大了存储第一类对象的存储空间。并且,将第一类对象调整至第一目标地址之后,第一类对象占用的内存空间大于或者等于第一类对象更新后的对象大小。如此,可以避免对象大小增大而导致多个对象占用相同的内存空间,避免了数据发生错乱的风险,保障了数据的完整性。
Smart Images

Figure CN115237452B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of network technology, and in particular to a method, apparatus, device and storage medium for adjusting addresses. Background Technology
[0002] With the development of internet technology, users have increasingly higher demands for applications, leading to more frequent application updates. Simply releasing updated applications through app stores is no longer sufficient to meet the needs of developers.
[0003] Currently, developers can update applications using hot updates. Hot updates allow developers to modify code, frameworks, or development toolkits while the application is running. For example, a developer can add attributes (such as fields or methods) to a target class. Afterward, objects created before the hot update (objects created before the attribute addition) will include the added attributes. Furthermore, the size of the object (i.e., the number of bytes it occupies) will change after the hot update. For instance, adding a field 'a' to the target class via hot update will result in a larger object size after the hot update compared to before.
[0004] However, when an electronic device creates an object, it allocates memory space (i.e., memory address) for the object based on its size in bytes, and different objects are allocated different amounts of memory. During hot updates, if the size of an object increases, the actual memory space it occupies may exceed the memory space allocated to it by the electronic device. This could lead to multiple objects occupying the same memory space, causing data corruption. Summary of the Invention
[0005] This disclosure provides a method, apparatus, device, and storage medium for adjusting memory addresses, which can prevent multiple objects from occupying the same memory space and ensure data integrity. The technical solution of this disclosure is as follows:
[0006] According to a first aspect of this disclosure, a method for adjusting an address is provided, the method comprising:
[0007] When a hot update request is received, the memory address of each of the multiple objects and the updated size of the multiple objects are obtained. The memory address corresponds to the address of the memory space occupied by the object. Based on the memory space occupied by each of the multiple objects and the updated size of the multiple objects, a first type of object and a second type of object are determined. The first type of object is the object whose memory space occupied is less than the updated size, and the second type of object is the object whose memory space occupied is greater than or equal to the updated size. The first type of object is adjusted to a first target address according to the updated size. The starting address of the first target address is the address after the memory address of the first target object. The first target object is the last object in the second type of object. After adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object.
[0008] Optionally, the memory addresses of multiple objects are located in a first memory region. The method for adjusting these addresses may further include: adjusting each object in the first type of objects to a second target address in a second memory region according to its updated size; the second memory region and the first memory region do not intersect; after adjustment to the second target address, the memory space occupied by the first type of objects is greater than or equal to its updated size; the starting memory address of the second target address is the starting memory address of the first object in the first type of objects, and the ending memory address of the second target address is the ending memory address of the last object in the first type of objects. The memory addresses of the second type of objects are adjusted according to their memory addresses and their updated sizes, such that the ending memory address of the first object is adjacent to the starting memory address of the second object; the first object and the second object are any two adjacent objects in the second type of objects. The data corresponding to the second target address is then moved to the first target address, and the memory space corresponding to the first target address is the same as the memory space corresponding to the second target address.
[0009] Optionally, the method of "adjusting each object in the first type of objects to a second target address in the second memory region according to the updated object size" may include: performing a first operation on each object in the first type of objects to adjust the first type of objects to a second target address; the first operation includes: adjusting a third object to a first sub-address according to the updated object size, where the third object is any object in the first type of objects, the first sub-address is an address in the second target address, and the memory space corresponding to the first sub-address is greater than or equal to the updated object size of the third object; and adjusting a fourth object to a second sub-address according to the updated object size, where the fourth object is any object in the first type of objects, the memory space corresponding to the second sub-address is greater than or equal to the updated object size of the fourth object, and the second sub-address is an address in the second target address adjacent to the first sub-address.
[0010] Optionally, the method of "adjusting the third object to the first sub-address according to the updated object size" may further include: if the sum of the last memory address of the fifth object and the updated object size of the third object is greater than the last memory address of the third object, then the third object is adjusted to the first sub-address according to the updated object size, and the fifth object is the object preceding the third object in the first memory region.
[0011] Optionally, the address adjustment method may also include: if the sum of the last memory address of the fifth object and the updated object size of the third object is less than or equal to the last memory address of the third object, then the third object is adjusted to the third sub-address according to the updated object size, and the third sub-address is adjacent to the last memory address of the fifth object.
[0012] Optionally, when the first object is the first object of the first type of object, the adjusted starting memory address of the first object is the starting memory address of the first memory region.
[0013] Optionally, the method described above for "determining the first type of object and the second type of object based on the memory space occupied by each object among multiple objects and the updated object size of the multiple objects" may include: performing a second operation on the multiple objects to determine the first type of object and the second type of object; the second operation includes: if the last memory address of the sixth object is less than the sum of the starting memory address of the sixth object and the updated object size of the sixth object, then the sixth object is determined to be a first type of object, and the sixth object is any one of the multiple objects. If the last memory address of the sixth object is greater than or equal to the sum of the starting memory address of the sixth object and the updated object size of the sixth object, then the sixth object is determined to be a second type of object.
[0014] According to a second aspect of this disclosure, an address adjustment apparatus is provided, the address adjustment apparatus comprising: an acquisition unit and a processing unit.
[0015] The acquisition unit is configured to, upon receiving a hot update request, acquire the memory address of each of the multiple objects and the updated size of the multiple objects, where the memory address corresponds to the address of the memory space occupied by the object. The processing unit is configured to, based on the memory space occupied by each of the multiple objects and the updated size of the multiple objects, determine a first type of object and a second type of object. The first type of object is the object whose memory space is less than the updated size, and the second type of object is the object whose memory space is greater than or equal to the updated size. The processing unit is further configured to, adjust the first type of object to a first target address according to the updated size, where the starting address of the first target address is an address after the memory address of the first target object, and the first target object is the last object in the second type of object; wherein, after adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object.
[0016] Optionally, the memory addresses of multiple objects are located in the first memory region. The processing unit is further configured to adjust each object in the first type of objects to a second target address in the second memory region according to its updated size. The second memory region does not intersect with the first memory region. After adjustment to the second target address, the memory space occupied by the first type of objects is greater than or equal to the updated size of the first type of objects. The starting memory address of the second target address is the starting memory address of the first object in the first type of objects, and the ending memory address of the second target address is the ending memory address of the last object in the first type of objects. The processing unit is further configured to adjust the memory address of the second type of objects according to their memory addresses and the updated size of the second type of objects. The adjusted ending memory address of the first object is adjacent to the starting memory address of the second object. The first object and the second object are any two adjacent objects in the second type of objects. The processing unit is further configured to adjust the data corresponding to the second target address to the first target address. The memory space corresponding to the first target address is the same as the memory space corresponding to the second target address.
[0017] Optionally, the processing unit is further configured to perform a first operation on each object in the first type of objects, adjusting the first type of objects to a second target address. The first operation includes: adjusting a third object to a first sub-address according to its updated object size, wherein the third object is any object in the first type of objects, the first sub-address is an address in the second target address, and the memory space corresponding to the first sub-address is greater than or equal to the updated object size of the third object; and adjusting a fourth object to a second sub-address according to its updated object size, wherein the fourth object is any object in the first type of objects, the memory space corresponding to the second sub-address is greater than or equal to the updated object size of the fourth object, and the second sub-address is an address in the second target address adjacent to the first sub-address.
[0018] Optionally, the processing unit is also configured to perform the following: if the sum of the last memory address of the fifth object and the updated object size of the third object is greater than the last memory address of the third object, then the third object is adjusted to the first sub-address according to the updated object size, and the fifth object is the object preceding the third object in the first memory region.
[0019] Optionally, the processing unit is also configured to perform the following action: if the sum of the last memory address of the fifth object and the updated object size of the third object is less than or equal to the last memory address of the third object, then the third object is adjusted to the third sub-address according to the updated object size, and the third sub-address is adjacent to the last memory address of the fifth object.
[0020] Optionally, when the first object is the first object of the first type of object, the adjusted starting memory address of the first object is the starting memory address of the first memory region.
[0021] Optionally, the processing unit is further configured to perform a second operation on multiple objects to determine a first type of object and a second type of object; the second operation includes: if the last memory address of the sixth object is less than the sum of the starting memory address of the sixth object and the updated size of the sixth object, then the sixth object is determined to be a first type of object, and the sixth object is any one of the multiple objects. If the last memory address of the sixth object is greater than or equal to the sum of the starting memory address of the sixth object and the updated size of the sixth object, then the sixth object is determined to be a second type of object.
[0022] According to a third aspect of this disclosure, a server is provided, the server comprising:
[0023] Processor. Memory for storing processor-executable instructions. The processor is configured to execute instructions to implement any of the optional address adjustment methods described in the first aspect above.
[0024] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided, on which instructions are stored, such that when the instructions in the computer-readable storage medium are executed by a processor of a computer, the computer is able to perform any of the optional address adjustment methods described in the first aspect above.
[0025] According to a fifth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements any of the optional address adjustment methods described in the first aspect.
[0026] According to a sixth aspect of this disclosure, this disclosure provides a chip including a processor and a communication interface coupled to the processor, the processor being configured to execute computer programs or instructions to implement the address adjustment method as described in the first aspect and any possible implementation thereof.
[0027] The technical solution provided in this disclosure offers at least the following beneficial effects: When a hot update request is received, the server can obtain the memory address of each of the multiple objects and the updated size of the multiple objects, where the memory address corresponds to the memory space occupied by the object. Then, based on the memory space occupied by each of the multiple objects and the updated size of the multiple objects, the server can determine a first type of object and a second type of object. The first type of object consists of objects whose memory space is smaller than the updated size, and the second type of object consists of objects whose memory space is greater than or equal to the updated size. The server can then adjust the first type of object to a first target address according to the updated size. The starting address of the first target address is the address following the memory address of the first target object, and the first target object is the last object in the second type of object. In other words, the server can use the starting address of the first target address as the starting address for storing the first type of object and the last memory address in the memory space as the last memory address for storing the first type of object, thus expanding the storage space for the first type of object. Furthermore, after adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object. In this way, we can avoid the risk of multiple objects occupying the same memory space due to the increase in object size, thus avoiding the risk of data corruption and ensuring data integrity.
[0028] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0029] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0030] Figure 1 This is an example schematic diagram illustrating a memory address according to an exemplary embodiment;
[0031] Figure 2 This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0032] Figure 3 This is a schematic diagram illustrating a communication system according to an exemplary embodiment;
[0033] Figure 4 This is a flowchart illustrating an address adjustment method according to an exemplary embodiment;
[0034] Figure 5 This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0035] Figure 6 This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0036] Figure 7 This is a flowchart illustrating another address adjustment method according to an exemplary embodiment;
[0037] Figure 8 This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0038] Figure 9A This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0039] Figure 9B This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0040] Figure 9C This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0041] Figure 9D This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0042] Figure 9E This is a schematic diagram illustrating an example of another memory address according to an exemplary embodiment;
[0043] Figure 10 This is a schematic diagram illustrating the structure of an address adjustment device according to an exemplary embodiment;
[0044] Figure 11 This is a schematic diagram illustrating the structure of another address adjustment device according to an exemplary embodiment. Detailed Implementation
[0045] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0046] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0047] 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 objects, memory addresses, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0048] First, the application scenarios of the embodiments of this disclosure will be introduced.
[0049] The address adjustment method of this disclosure is applied to hot-update scenarios. Currently, objects created according to the target class before hot-update (i.e., objects created before adding attribute information) can include the added attribute information. Furthermore, after hot-update, the size of the object (i.e., the number of bytes occupied by the object) changes. For example, a field 'a' can be added to the target class through hot-update, and the number of bytes occupied by the object after hot-update is greater than the number of bytes occupied by the object before hot-update. However, when the electronic device creates an object, it allocates memory space (i.e., the memory address) for the object according to the number of bytes occupied, and different objects allocate different amounts of memory space. During hot-update, if the number of bytes occupied by the object increases, the actual memory space occupied by the object is greater than the memory space allocated by the electronic device for the object. This may result in multiple objects occupying the same memory space, leading to data corruption.
[0050] For example, such as Figure 1As shown, before the hot update, the electronic device has created multiple objects (such as objects A1, A2, and A3 of class A, and objects B1 and B2 of class B). Furthermore, the electronic device has allocated corresponding memory addresses for objects A1, A2, A3, B1, and B2. If a field is added to class A, after the hot update, the sizes of objects A1, A2, and A3 will increase, and the memory space occupied by objects A1, A2, and A3 will also increase. Figure 2 As shown, the memory address occupied by object A1 overlaps with the memory address occupied by object A2 (e.g., address A), and the memory address occupied by object A2 overlaps with the memory address occupied by object A3 (e.g., address B). Thus, object A1 can replace the data of object A2 originally stored at address A with its own data, and object A2 can replace the data of object A3 originally stored at address B with its own data. In other words, the data stored at address A changes from object A2 to object A1, and the data stored at address B changes from object A3 to object A2; some data in objects A2 and A3 is overwritten.
[0051] In related technologies, within the spring-loaded approach, electronic devices can add an extra map field (such as Map) to each class.<String,Object> The additional map field can store fields added during hot updates. Afterwards, the electronic device can modify the bytecode (Java bytecode) accessing field 'a' to access the additional map field.
[0052] For example, an electronic device can modify the bytecode (Java bytecode) that accesses field a to access an additional map field.
[0053] For example, during a hot update, if an electronic device adds a field named 'a' with a value of 2, a mapping from 'a' to '2' will be added to the map of this additional field. This is illustrated in the following code:
[0054] public class A{Map<String,Object> __hotreload_extramap=new HashMap(); int a=2;}.
[0055] Subsequently, class B exists in the electronic device that accesses A. As shown in the following code:
[0056] class B{void test(){A a=new A(); System.out.println(aa);}}.
[0057] Then, to access field 'a' in class A from class B, the access code in class B can be modified to access the value with key 'a' in an additional map of class A. The modified access code in class B is shown below:
[0058] class B{void test(){A a=new A();
[0059] System.out.println(a.__hotreload_extramap.get("a"));}}.
[0060] However, the above technical solution requires adding a map field to each class, which increases the size of objects created from that class, meaning the memory space occupied by the objects increases. This can lead to wasted memory space when no new objects are created. Furthermore, in this solution, accessing fields changes from directly accessing the field to first obtaining an additional map and then calling the map's get method to retrieve the field value. This increases the field access operation process, resulting in reduced performance.
[0061] To address the aforementioned issues, this disclosure provides a method for adjusting memory addresses. In this method, upon receiving a hot update request, the server obtains the memory address of each of multiple objects and the updated size of all objects. Then, the memory address of each object is adjusted according to its updated size, ensuring that the adjusted object occupies memory space greater than or equal to its updated size. This avoids multiple objects occupying the same memory space (i.e., memory address), preventing data from being overwritten and ensuring data integrity. Furthermore, this disclosure eliminates the need for pre-setting a map, reducing memory usage and minimizing performance overhead by avoiding additional field access operations.
[0062] Figure 3 This is a schematic diagram of the structure of a server applying the method provided in this disclosure, as provided in an embodiment of the present disclosure. The server 10 includes a processor 101 and a memory 102.
[0063] The processor 101 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 101 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.
[0064] Memory 102 may include one or more computer-readable storage media, which may be non-transitory. Memory 102 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In one possible implementation, the non-transitory computer-readable storage media in memory 102 is used to store at least one instruction for execution by processor 101 to implement the group communication method provided in the embodiments of this disclosure.
[0065] In one possible implementation, server 10 may further include a peripheral device interface 103 and at least one peripheral device. The processor 101, memory 102, and peripheral device interface 103 can be connected via a bus or signal lines. Each peripheral device can be connected to peripheral device interface 103 via a bus, signal lines, or a circuit board. Specifically, the peripheral device includes at least one of the following: radio frequency circuitry 104, display screen 105, camera assembly 106, audio circuitry 107, positioning assembly 108, and power supply 109.
[0066] Peripheral interface 103 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 101 and memory 102. In one implementation, processor 101, memory 102, and peripheral interface 103 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 101, memory 102, and peripheral interface 103 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0067] The radio frequency (RF) circuit 104 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 104 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 104 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 104 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 104 can communicate with other servers via at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: metropolitan area networks (MANs), various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks (WLANs), and / or Wi-Fi (Wireless Fidelity) networks. In one possible implementation, the RF circuit 104 may also include circuitry related to NFC (Near Field Communication), which is not limited in this disclosure.
[0068] Display screen 105 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 105 is a touch screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 101 for processing. In this case, display screen 105 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In one possible implementation, display screen 105 can be a single unit, serving as the front panel of server 10; display screen 105 can be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0069] The camera assembly 106 is used to acquire images or videos. Optionally, the camera assembly 106 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the server, and the rear-facing camera is located on the back of the server. The audio circuit 107 may include a microphone and a speaker. The microphone is used to acquire sound waves from the user and the environment, and convert the sound waves into electrical signals that are input to the processor 101 for processing, or input to the radio frequency circuit 104 for voice communication. For stereo acquisition or noise reduction purposes, there may be multiple microphones, each located at a different location on the server 10. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert electrical signals from the processor 101 or the radio frequency circuit 104 into sound waves. The speaker may be a conventional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into sound waves that are audible to humans, but also into sound waves that are inaudible to humans for purposes such as ranging. In one possible implementation, the audio circuit 107 may also include a headphone jack.
[0070] The positioning component 108 is used to locate the current geographic location of the server 10 to enable navigation or LBS (Location Based Service). The positioning component 108 can be a positioning component based on the US GPS (Global Positioning System), China's BeiDou system, Russia's Granas system, or the European Union's Galileo system.
[0071] The power supply 109 is used to power the various components in the server 10. The power supply 109 can be AC power, DC power, a disposable battery, or a rechargeable battery. When the power supply 109 includes a rechargeable battery, the rechargeable battery can support wired or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0072] In one possible implementation, server 10 also includes one or more sensors 1010. These sensors 1010 include, but are not limited to, accelerometers, gyroscopes, pressure sensors, fingerprint sensors, optical sensors, and proximity sensors.
[0073] An accelerometer can detect the magnitude of acceleration along the three axes of a coordinate system established with respect to server 10. A gyroscope sensor can detect the orientation and rotation angle of server 10; the gyroscope sensor can work in conjunction with the accelerometer to acquire 3D motions of the user on server 10. A pressure sensor can be located on the side bezel of server 10 and / or on the lower layer of display screen 105. When the pressure sensor is located on the side bezel of server 10, it can detect the user's grip signal on server 10. A fingerprint sensor is used to acquire the user's fingerprint. An optical sensor is used to acquire ambient light intensity. A proximity sensor, also known as a distance sensor, is typically located on the front panel of server 10. The proximity sensor is used to acquire the distance between the user and the front of server 10.
[0074] The data processing method provided in this disclosure can be executed by a data processing device, which can be... Figure 3 The server shown is an example. The execution device can also be the server's central processing unit (CPU) or a control module within the server for processing data. This application embodiment uses a server executing a data processing method as an example to illustrate the data processing method provided in this application embodiment.
[0075] In one feasible approach, the server is used to provide voice and / or data connectivity services to the user. The server can have different names, such as UE (User Equipment), terminal unit, terminal station, mobile station, mobile station, remote station, remote terminal, mobile device, wireless communication device, vehicle user equipment, terminal agent, or terminal device, etc.
[0076] Optionally, the server can be various handheld devices, in-vehicle devices, wearable devices, or computers with communication capabilities, and this disclosure does not limit this in any way. For example, a handheld device can be a smartphone. An in-vehicle device can be an in-vehicle navigation system. A wearable device can be a smart bracelet. A computer can be a personal digital assistant (PDA) computer, a tablet computer, or a laptop computer.
[0077] After introducing the application scenarios and implementation environments of the embodiments of this disclosure, the following will be combined with... Figure 3 The implementation environment shown will be used to provide a detailed description of the address adjustment method provided in the embodiments of this disclosure.
[0078] Figure 4 This is a flowchart illustrating an address adjustment method according to an exemplary embodiment. Figure 4 As shown, the method may include steps 401-403.
[0079] 401. The server obtains the memory address of each of the multiple objects and the updated size of the multiple objects.
[0080] Here, the memory address is the address corresponding to the memory space occupied by the object.
[0081] For example, multiple objects include: object A1, object A2, object A3, object B1, and object B2. The memory addresses of object A1 are 0001-0010, object A2's are 0013-0019, object A3's are 0022-0029, object B1's are 0035-0042, and object B2's are 0045-0053. If the memory addresses are represented in decimal bytes, then object A1 occupies 10 bytes of memory, object A2 occupies 7 bytes, object A3 occupies 8 bytes, object B1 occupies 14 bytes, and object B2 occupies 9 bytes.
[0082] It should be noted that the representation of memory addresses in this disclosure is not limited. For example, memory addresses can be represented in decimal, hexadecimal, or octal. In the following embodiments, the memory addresses will be represented in decimal to illustrate the embodiments of this disclosure.
[0083] It's important to note that before hot updates, the size of an object is less than or equal to the memory space corresponding to its memory address. For example, if object A has a size of 8 bytes, its memory address is 0001-0008 (i.e., 8 bytes of memory space). Similarly, if object B has a size of 15 bytes, its memory address is 0009-00025 (i.e., 17 bytes of memory space). And if object C has a size of 10 bytes, its memory address is 00030-0039 (i.e., 10 bytes of memory space).
[0084] Optionally, the memory space corresponding to the memory addresses of multiple objects can be heap memory.
[0085] In this embodiment of the disclosure, when a hot update request is received, the server can obtain the memory address of each of the multiple objects and the updated size of the multiple objects.
[0086] It should be noted that this disclosure does not limit the timing of when the server receives a hot update request. For example, the server can receive a hot update request when adding a field to a class. Similarly, the server can receive a hot update request when adding a development toolkit. And again, the server can receive a hot update request when adding a method.
[0087] In one possible design, the size of the updated object is larger than the size of the object before hot updating.
[0088] For example, without hot updates, object A1 has a size of 10 bytes. After a hot update (e.g., adding a field), object A1 has a size of 15 bytes.
[0089] Optionally, the size of the updated object is less than or equal to the size of the object before hot updating.
[0090] For example, if there is no hot update, the object size of object A1 is 10 bytes. After a hot update (e.g., adding or removing a field), the object size of object A1 is 10 bytes. Alternatively, after a hot update (e.g., adding or removing a field), the object size of object A1 is 8 bytes.
[0091] In this embodiment of the disclosure, during the hot update process, when the object has not been hot updated, the server can determine the size of the updated object based on the hot update request.
[0092] It should be noted that the implementation method for the server to determine the size of the updated object can refer to the conventional technology for determining the size of the object after a hot update, and will not be elaborated here.
[0093] For example, multiple objects include object A, which is an object created according to class A, and the size of object A is 10 bytes. After receiving a hot update request to add field 'a', if field 'a' is not added to object A, the size of object A is 15 bytes.
[0094] 402. The server determines the first type of object and the second type of object based on the memory space occupied by each object in the multiple objects and the updated size of the multiple objects.
[0095] The first type of object is an object whose memory space is smaller than the updated object size among multiple objects, and the second type of object is an object whose memory space is greater than or equal to the updated object size among multiple objects.
[0096] For example, multiple objects include: object A1, object A2, object A3, object B1, and object B2. Object A1 occupies 10 bytes of memory, object A2 occupies 7 bytes, object A3 occupies 8 bytes, object B1 occupies 14 bytes, and object B2 occupies 9 bytes. The updated size of object A1 is 12 bytes, the updated size of object A2 is 11 bytes, the updated size of object A3 is 13 bytes, object B1 occupies 14 bytes, and object B2 occupies 8 bytes. Therefore, objects A1, A2, and A3 are classified as first-type objects, and objects B1 and B2 are classified as second-type objects.
[0097] In one possible implementation, the server can determine the memory space occupied by each object based on the memory address of each object among multiple objects. Then, the server can compare the memory space occupied by each object with the updated size of all objects. For each object, if the memory space occupied by the object is less than the updated size, the object is classified as a first-type object. If the memory space occupied by the object is greater than or equal to the updated size, the object is classified as a second-type object.
[0098] In another possible implementation, the memory space occupied by an object includes the object's starting memory address and the object's ending memory address. The server can perform a second operation on multiple objects to determine a first type of object and a second type of object. The second operation includes: if the ending memory address of the sixth object is less than the sum of the sixth object's starting memory address and the updated size of the sixth object, then the sixth object is determined to be a first type of object, and the sixth object is any one of the multiple objects. If the ending memory address of the sixth object is greater than or equal to the sum of the sixth object's starting memory address and the updated size of the sixth object, then the sixth object is determined to be a second type of object.
[0099] For example, suppose object A has a starting memory address of 0005 and an ending memory address of 0020. If the updated size of object A is 20, then object A is determined to be a first-class object. If the updated size of object A is 13, then object A is determined to be a second-class object.
[0100] Understandably, if the last memory address of the sixth object is less than the sum of its starting memory address and its updated size, it means the updated size of the sixth object occupies addresses exceeding its last memory address; that is, the updated size is greater than the total memory space occupied by the sixth object, thus classifying the sixth object as a first-type object. Conversely, if the last memory address of the sixth object is greater than or equal to the sum of its starting memory address and its updated size, it means the updated size does not exceed its last memory address; that is, the updated size is less than or equal to the total memory space occupied by the sixth object, thus classifying the sixth object as a second-type object.
[0101] 403. The server will adjust the first type of object to the first target address according to the updated object size.
[0102] The starting address of the first target address is the address after the memory address of the first target object, and the first target object is the last object in the second type of object.
[0103] For example, suppose there are multiple objects stored in memory, arranged in the following order: object B1, object A1, object A2, object A3, and object B2. Objects A1, A2, and A3 are first-class objects, and objects B1 and B2 are second-class objects. Then, object B2 is the first target object. If the memory address of object B2 is 00060-00073, then the first target address includes addresses after 00073, such as 00074-00200.
[0104] After adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object.
[0105] For example, suppose object A is a first-class object, and the updated object size of object AA is 15 bytes. Before object A is moved to the first target address, object A occupies 10 bytes of memory. After object A is moved to the first target address, object A occupies 15 bytes of memory. Alternatively, after object A is moved to the first target address, object A occupies 16 bytes of memory.
[0106] In one possible implementation, the server can resize all objects in the first type of object to the first target address according to the updated object size.
[0107] For example, suppose multiple objects include: object B1, object A1, object A2, object A3, and object B2. Combined Figure 1 ,like Figure 5As shown, the adjusted objects are stored in memory in the following order: object B1, object B2, object A1, object A2, and object A3. If the updated size of object A1 is 12 bytes, the updated size of object A2 is 11 bytes, and the updated size of object A3 is 13 bytes, then the memory addresses occupied by the adjusted object A1 are 00050-00062, the memory addresses occupied by the adjusted object A2 are 00063-00074, and the memory addresses occupied by the adjusted object A3 are 00080-00092.
[0108] Understandably, the server can resize all objects in the first type of object to the first target address according to the updated object size. The starting address of the first target address is the address after the memory address of the first target object (i.e., the last object in the second type of object). In other words, the server can use the starting address of the first target address as the starting address for storing the first type of object, and the last memory address in the memory space as the last memory address for storing the first type of object, thus expanding the storage space for the first type of object. This avoids the risk of multiple objects occupying the same memory space due to increased object size, preventing data corruption and ensuring data integrity.
[0109] In another possible implementation, the server can resize a portion of the objects in the first type of object to the first target address according to the updated object size.
[0110] For example, suppose multiple objects include: object B1, object A1, object A2, object A3, and object B2. Combined Figure 1 ,like Figure 6 As shown, the adjusted order of the multiple objects in memory is: object B1, object A1, object B2, object A2, and object A3.
[0111] Understandably, by adjusting some objects in the first type of object to the first target address according to the updated object size, the server can expand the storage space of the area storing multiple objects. This ensures that the first type of objects not adjusted to the first target address have sufficient memory space, thus preventing them from occupying the memory space of other objects and guaranteeing data integrity.
[0112] The technical solution provided by the above embodiments brings at least the following beneficial effects: When a hot update request is received, the server can obtain the memory address of each object in the multiple objects and the updated size of the multiple objects, where the memory address is the address corresponding to the memory space occupied by the object. Then, the server can determine a first type of object and a second type of object based on the memory space occupied by each object in the multiple objects and the updated size of the multiple objects. The first type of object is the object whose memory space is smaller than the updated size, and the second type of object is the object whose memory space is greater than or equal to the updated size. Then, the server can adjust the first type of object to a first target address according to the updated size. The starting address of the first target address is the address after the memory address of the first target object, and the first target object is the last object in the second type of object. That is, the server can use the starting address of the first target address as the starting address for storing the first type of object and the last memory address in the memory space as the last memory address for storing the first type of object, thus expanding the storage space for the first type of object. Furthermore, after adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object. In this way, we can avoid the risk of multiple objects occupying the same memory space due to the increase in object size, thus avoiding the risk of data corruption and ensuring data integrity.
[0113] In one feasible approach, the memory addresses of individual objects reside in a first memory region. The server can move a first type of object from the first memory region to a second memory region, where the second and first memory regions do not overlap. Then, the server can concatenate second type objects from the first memory region and move the first type of object from the second memory region back to the first memory region, concatenating them together.
[0114] Figure 7 This is a flowchart illustrating an address adjustment method according to an exemplary embodiment. Figure 7 As shown, after step 402, the method may include steps 701-702.
[0115] 701. The server adjusts each object in the first type of object to the second target address in the second memory region according to the updated object size.
[0116] The second memory region does not overlap with the first memory region.
[0117] In one possible design, the first memory region and the second memory region belong to the same memory region, but the memory addresses of the first memory region and the second memory region are different.
[0118] It should be noted that when we say the first memory region and the second memory region are the same, it means that the hardware devices corresponding to the first memory region and the second memory region are the same. For example, both the first memory region and the second memory region are memory resources within a memory module.
[0119] For example, the memory addresses corresponding to the memory space in the memory module include: 000001-900000. Wherein, the first memory region includes the memory space corresponding to memory addresses 000001-200000, and the second memory region includes part or all of the memory space corresponding to memory addresses 200001-900000.
[0120] In another possible design, the first memory region and the second memory region belong to different memory regions, and the memory address of the first memory region is different from the memory address of the second memory region.
[0121] It should be noted that the first memory region and the second memory region are different memory regions because the hardware devices corresponding to the first memory region and the second memory region are different. For example, the first memory region is the memory resource in the memory module, while the second memory region is the memory resource in the hard drive.
[0122] Optionally, when the server receives a hot update request, the server may request a second memory region.
[0123] In this embodiment of the disclosure, after being adjusted to the second target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object. The starting memory address of the second target address is the starting memory address of the first object in the first type of object, and the ending memory address of the second target address is the ending memory address of the last object in the first type of object.
[0124] For example, the first type of objects adjusted to the second target address include: object A1, object A2, and object A3. If the updated size of object A1 is 12 bytes, the updated size of object A2 is 11 bytes, and the updated size of object A3 is 13 bytes, then the memory addresses occupied by the adjusted object A1 are 00050-00062, the memory addresses occupied by the adjusted object A2 are 00063-00074, and the memory addresses occupied by the adjusted object A3 are 00080-00092. Therefore, the second target address is 00050-00092.
[0125] In one possible implementation, the server determines the memory address of each object in the second memory region based on the updated object size of each object in the first type of objects. Then, the server can sequentially adjust each object in the first type of objects to its corresponding memory address in the second memory region.
[0126] In another possible implementation, the server can perform a first operation on each object in the first type of objects, adjusting the first type of objects to a second target address. The first operation includes: the server adjusting a third object to a first sub-address according to its updated object size. The third object is any object in the first type of objects, and the first sub-address is an address within the second target address, where the memory space corresponding to the first sub-address is greater than or equal to the updated object size of the third object. Then, the server adjusts a fourth object to a second sub-address according to its updated object size. The fourth object is any object in the first type of objects, and the memory space corresponding to the second sub-address is greater than or equal to the updated object size of the fourth object, where the second sub-address is an address within the second target address adjacent to the first sub-address.
[0127] It should be noted that "adjacent to the first sub-address" means that the starting memory address of the second sub-address is adjacent to the last memory address of the first sub-address, or the last memory address of the second sub-address is adjacent to the starting memory address of the first sub-address.
[0128] For example, suppose the first type of objects includes: object A1, object A2, and object A3. The updated size of object A1 is 12 bytes, the updated size of object A2 is 11 bytes, and the updated size of object A3 is 13 bytes. The adjusted memory addresses for object A1 are 00050-00061, for object A2 are 00062-00072, and for object A3 are 00073-00085.
[0129] Understandably, for each object in the first type of objects, the first operation is performed to adjust the first type of objects to the second target address. The first operation includes: adjusting the third object to the first sub-address according to its updated size; the third object being any object in the first type of objects; the first sub-address being an address within the second target address; and the memory space corresponding to the first sub-address being greater than or equal to the updated size of the third object. The fourth object is then adjusted to the second sub-address according to its updated size; the fourth object being any object in the first type of objects; the memory space corresponding to the second sub-address being greater than or equal to the updated size of the fourth object; and the second sub-address being an address within the second target address adjacent to the first sub-address. This ensures that after adjusting the first type of objects from the first memory region to the second memory region, there will be no free memory space between two adjacent objects. This improves the space utilization of the second memory region.
[0130] 702. The server adjusts the memory address of the second type of object according to the memory address of the second type of object and the updated size of the second type of object.
[0131] In this context, the adjusted last memory address of the first object is adjacent to the starting memory address of the second object, and the first object and the second object are any two adjacent objects in the second type of object.
[0132] For example, in combination Figure 5 ,like Figure 8 As shown, if objects B1 and B2 are second-class objects, the memory address of object B1 is 00005-00012, and the memory address of object B2 is 00013-00021.
[0133] In one possible implementation, the server can perform a third operation on each of the second type of objects, adjusting the memory address of the second type of objects. The third operation includes: adjusting the first object to a fourth sub-address, where the fourth address is the address after the last memory address of the second object, and the starting memory address of the first object is adjacent to the last memory address of the second object.
[0134] In one feasible approach, when the first object is the first object of the first class of objects, the adjusted starting memory address of the first object is the starting memory address of the first memory region.
[0135] For example, in combination Figure 5 If the memory address of object B1 is 00005-00010, then the adjusted memory address of object B1 is 00001-00006.
[0136] It is understandable that adjusting the first object to the starting memory address of the first memory region can reduce the fragmented memory space in the memory region, which is conducive to the consolidation of memory space and improves the utilization of memory space.
[0137] In this embodiment of the disclosure, step 403 may include step 703.
[0138] 703. The server adjusts the data corresponding to the second target address to the first target address.
[0139] The memory space corresponding to the first target address is the same as the memory space corresponding to the second target address.
[0140] For example, the second target address is 00020-00070, and the first target address is 00050-00100. Alternatively, the second target address is 00001-00070, and the first target address is 00100-00169. Or, the second target address is 00005-00070, and the first target address is 00030-00095.
[0141] In one possible implementation, the server can copy the data corresponding to the second target address and paste the data corresponding to the second target address to the first target address.
[0142] Optionally, the starting memory address of the first target address is adjacent to the last memory address of the last object in the first memory region.
[0143] The technical solution provided by the above embodiments brings at least the following beneficial effects: The server adjusts each object in the first type of objects to a second target address in the second memory region according to the updated object size. The second memory region and the first memory region do not overlap. Then, the server can adjust the memory address of the second type of objects according to the memory address of the second type of objects and the updated object size of the second type of objects. The adjusted last memory address of the first object is adjacent to the starting memory address of the second object. The first object and the second object are any two adjacent objects in the second type of objects. This reduces the unused memory space between objects in the first memory region and increases the usable memory space in the first memory region. Then, the server can adjust the data corresponding to the second target address to the first target address. The memory space corresponding to the first target address is the same as the memory space corresponding to the second target address. That is, the server can adjust the data at the second target address to the first target address as a whole, using the data stored at the memory address as a unit. Furthermore, after adjusting to the second target address, the memory space occupied by the first type of objects is greater than or equal to the updated object size of the first type of objects. The starting memory address of the second target address is the starting memory address of the first object in the first type of objects, and the last memory address of the second target address is the last memory address of the last object in the first type of objects. In this way, it can be ensured that the first type of object (in the first target address or the second target address) will not occupy the same memory space, thus improving data integrity.
[0144] In one feasible approach, the server adjusts the third object to the first sub-address according to the updated object size, which may include: if the sum of the last memory address of the fifth object and the updated object size of the third object is greater than the last memory address of the third object, then the third object is adjusted to the first sub-address according to the updated object size, and the fifth object is the object preceding the third object in the first memory region.
[0145] For example, if the last memory address of object A1 (i.e., the fifth object) is 000020, the last memory address of object A2 (i.e., the third object) is 000030, and the updated object size of object A2 is 15 bytes, then object A2 will be adjusted to the first sub-address (e.g., 000080-000094) according to 15 bytes.
[0146] Understandably, if the sum of the last memory address of the fifth object and the updated size of the third object is greater than the last memory address of the third object, it means that the memory space occupied by the updated size of the third object is higher than the sum of the currently occupied memory space and the free memory space between the fifth and third objects. Therefore, the server can adjust the third object to the first sub-address according to its updated size. This prevents the third object from occupying the memory space of other objects, ensuring data integrity.
[0147] Optionally, if the sum of the last memory address of the fifth object and the updated size of the third object is less than or equal to the last memory address of the third object, then the third object is adjusted to the third sub-address according to the updated object size, and the third sub-address is adjacent to the last memory address of the fifth object.
[0148] For example, if the last memory address of object A1 (i.e., the fifth object) is 000020, the last memory address of object A2 (i.e., the third object) is 000030, and the updated object size of object A2 is 9 bytes, then object A2 will be adjusted to the third sub-address (e.g., 000021-000029) according to the 9-byte size.
[0149] It's understandable that if the sum of the last memory address of the fifth object and the updated size of the third object is less than or equal to the last memory address of the third object, it means the memory space occupied by the updated size of the third object will not exceed the sum of its currently occupied memory space and the free memory space between the fifth and third objects. Therefore, the server adjusts the third object to an address adjacent to the last memory address of the fifth object according to its updated size. This means the server can utilize the free memory space between the fifth and third objects and the memory space currently occupied by the third object to store it. This prevents the third object from occupying the memory space of other objects, ensuring data integrity.
[0150] The embodiments of this disclosure are described below with reference to specific examples. Figure 1 Suppose that the memory addresses of object B1 are 00002-00021, object A1's memory addresses are 00026-00031, object A2's memory addresses are 00034-00043, object A3's memory addresses are 00050-00060, and object B2's memory addresses are 00070-00081. Combined with... Figure 2 If the updated object size of object A1 is 10 bytes, the updated object size of object A2 is 14 bytes, and the updated object size of object A3 is 15 bytes.
[0151] like Figure 9AAs shown, the server can iterate through the first object (i.e., object B1), compare the sum of the starting memory address of the first memory region (e.g., 00001) and the size of object B1 with the last memory address of object B1, and determine that the sum of the starting memory address of the first memory region and the size of object B1 is less than the last memory address of object B1. Then, the server uses the starting memory address of the first memory region as the starting memory address of object B1 (i.e., the adjusted starting memory address of object B1 is 00001, and the last memory address is 00020). Then, as... Figure 9B As shown, the server iterates through the second object (object A1), compares the sum of the adjusted last memory address of object B1 (00020) and the updated size of object A1 with the last memory address of object A1, and determines that the sum of the adjusted last memory address of object B1 and the updated size of object A1 is less than the last memory address of object A1. Then, the server uses the address after the last address of object B1 as the starting memory address of object A1 (i.e., the adjusted starting memory address of object A1 is 00021, and the last memory address is 00030). Then, as... Figure 9C As shown, the server iterates through the third object (object A2), comparing the sum of the adjusted last memory address of object A1 (00030) and the updated size of object A2 with the last memory address of object A2. It determines that the sum of the adjusted last memory address of object A1 and the updated size of object A2 (00044) is greater than the last memory address of object A2. Then, the server moves object A2 to the second memory region, and the adjusted memory address of object A2 is 00080 (the starting memory address of the second memory region) - 00093. Then, as... Figure 9D As shown, the server iterates through the fourth object (object A3), comparing the sum of the adjusted last memory address of object A1 (00030) and the updated size of object A3 with the last memory address of object A3. It determines that the sum of the adjusted last memory address of object A1 and the updated size of object A2 (00045) is less than the last memory address of object A3. Then, the server uses the address following the last address of the adjusted object A1 as the starting memory address of object A3 (i.e., the starting memory address of the adjusted object A3 is 00031, and the last memory address is 00045). Then, as... Figure 9EThe server iterates through the fifth object (object B2) and uses the address after the last memory address of the adjusted object A3 as the starting memory address of object B2 (i.e., the starting memory address of the adjusted object B2 is 00046, and the last memory address is 00060). Then, the server adjusts all objects in the second memory region (i.e., object A2) to the address after the last address of object B2 (i.e., the starting memory address of the adjusted object A2 is 00061, and the last memory address is 00074).
[0152] It is understood that the above method can be implemented by an address adjustment device. To achieve the above functions, the address adjustment device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, the embodiments of this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this disclosure.
[0153] This disclosure embodiment can divide the address adjustment device and the like into functional modules according to the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this disclosure embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0154] Figure 10 This is a structural block diagram illustrating an address adjustment device according to an exemplary embodiment. (Refer to...) Figure 10 The address adjustment device 100 includes an acquisition unit 1001 and a processing unit 1002.
[0155] The acquisition unit 1001 is configured to, upon receiving a hot update request, acquire the memory address of each of the multiple objects and the updated size of the multiple objects, where the memory address corresponds to the address of the memory space occupied by the object. The processing unit 1002 is configured to, based on the memory space occupied by each of the multiple objects and the updated size of the multiple objects, determine a first type of object and a second type of object. The first type of object is the object whose memory space is less than the updated size, and the second type of object is the object whose memory space is greater than or equal to the updated size. The processing unit 1002 is further configured to, according to the updated size, adjust the first type of object to a first target address, where the starting address of the first target address is an address after the memory address of the first target object, and the first target object is the last object in the second type of object; wherein, after adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object.
[0156] Optionally, the memory addresses of multiple objects are located in the first memory region. Processing unit 1002 is further configured to adjust each object in the first type of objects to a second target address in the second memory region according to its updated object size. The second memory region does not intersect with the first memory region. After adjustment to the second target address, the memory space occupied by the first type of objects is greater than or equal to the updated object size of the first type of objects. The starting memory address of the second target address is the starting memory address of the first object in the first type of objects, and the ending memory address of the second target address is the ending memory address of the last object in the first type of objects. Processing unit 1002 is further configured to adjust the memory address of the second type of objects according to their memory addresses and the updated object size of the second type of objects. The adjusted ending memory address of the first object is adjacent to the starting memory address of the second object. The first object and the second object are any two adjacent objects in the second type of objects. Processing unit 1002 is further configured to adjust the data corresponding to the second target address to the first target address. The memory space corresponding to the first target address is the same as the memory space corresponding to the second target address.
[0157] Optionally, the processing unit 1002 is further configured to perform a first operation on each object in the first type of objects, adjusting the first type of objects to a second target address. The first operation includes: adjusting a third object to a first sub-address according to its updated object size, wherein the third object is any object in the first type of objects, the first sub-address is an address in the second target address, and the memory space corresponding to the first sub-address is greater than or equal to the updated object size of the third object; and adjusting a fourth object to a second sub-address according to its updated object size, wherein the fourth object is any object in the first type of objects, the memory space corresponding to the second sub-address is greater than or equal to the updated object size of the fourth object, and the second sub-address is an address in the second target address adjacent to the first sub-address.
[0158] Optionally, the processing unit 1002 is further configured to perform the following: if the sum of the last memory address of the fifth object and the updated object size of the third object is greater than the last memory address of the third object, then the third object is adjusted to the first sub-address according to the updated object size, and the fifth object is the object preceding the third object in the first memory region.
[0159] Optionally, the processing unit 1002 is further configured to perform the following: if the sum of the last memory address of the fifth object and the updated object size of the third object is less than or equal to the last memory address of the third object, then the third object is adjusted to the third sub-address according to the updated object size, and the third sub-address is adjacent to the last memory address of the fifth object.
[0160] Optionally, when the first object is the first object of the first type of object, the adjusted starting memory address of the first object is the starting memory address of the first memory region.
[0161] Optionally, the processing unit 1002 is further configured to perform a second operation on multiple objects to determine a first type of object and a second type of object; the second operation includes: if the last memory address of the sixth object is less than the sum of the starting memory address of the sixth object and the updated size of the sixth object, then the sixth object is determined to be a first type of object, and the sixth object is any one of the multiple objects. If the last memory address of the sixth object is greater than or equal to the sum of the starting memory address of the sixth object and the updated size of the sixth object, then the sixth object is determined to be a second type of object.
[0162] Regarding the address adjustment device in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated here.
[0163] Figure 11 This is a schematic diagram of the structure of an address adjustment device 110 provided in this disclosure. Figure 11The address adjustment device 110 may include at least one processor 1101 and a memory 1103 for storing executable instructions of the processor 1101. The processor 1101 is configured to execute instructions in the memory 1103 to implement the address adjustment method described in the above embodiments.
[0164] In addition, the address adjustment device 110 may also include a communication bus 1102 and at least one communication interface 1104.
[0165] The processor 1101 may be a GPU, a microprocessor unit, an ASIC, or one or more integrated circuits for controlling the execution of programs according to the present disclosure.
[0166] The communication bus 1102 may include a path for transmitting information between the aforementioned components.
[0167] Communication interface 1104 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0168] Memory 1103 may be read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed discs, laser discs, optical discs, digital universal discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory may exist independently and be connected to the processing unit via a bus. Memory may also be integrated with the processing unit as a volatile storage medium within the GPU.
[0169] The memory 1103 stores instructions for executing the present invention, and the processor 1101 controls the execution of these instructions. The processor 1101 executes the instructions stored in the memory 1103 to implement the functions of the present invention.
[0170] In a specific implementation, as one example, the processor 1101 may include one or more GPUs, for example... Figure 11 GPU0 and GPU1 in the dataset.
[0171] In a specific implementation, as one example, the address adjustment device 110 may include multiple processors, for example... Figure 11 Processors 1101 and 1107 are mentioned. Each of these processors can be a single-core (CPU) processor or a multi-core (GPU) processor. A processor here can refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).
[0172] In a specific implementation, as one embodiment, the address adjustment device 110 may further include an output device 1105 and an input device 1106. The output device 1105 communicates with the processor 1101 and can display information in various ways. For example, the output device 1105 may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device 1106 communicates with the processor 1101 and can accept user input in various ways. For example, the input device 1106 may be a mouse, keyboard, touchscreen device, or sensing device, etc.
[0173] Those skilled in the art will understand that Figure 11 The structure shown does not constitute a limitation on the address adjustment device 110, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0174] This disclosure also provides a computer-readable storage medium storing instructions that, when executed by a computer's processor, enable the computer to perform the group communication method provided in the embodiments of this disclosure described above.
[0175] This disclosure also provides a computer program product comprising a computer program that, when executed by a processor, implements the address adjustment method provided in the above-described embodiments of this disclosure.
[0176] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0177] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method for adjusting an address, characterized in that, The method includes: When a hot update request is received, the memory address of each of the multiple objects and the updated size of the multiple objects are obtained, wherein the memory address is the address corresponding to the memory space occupied by the object; the memory addresses of the multiple objects are located in the first memory region; Based on the memory space occupied by each of the plurality of objects and the updated size of the plurality of objects, a first type of object and a second type of object are determined. The first type of object is the object whose memory space is less than the updated size of the plurality of objects, and the second type of object is the object whose memory space is greater than or equal to the updated size of the plurality of objects. Each object in the first type of object is adjusted to the second target address in the second memory region according to the updated object size, and the second memory region has no intersection with the first memory region; Adjust the memory address of the second type of object according to the memory address of the second type of object and the updated size of the second type of object; The data corresponding to the second target address is adjusted to the first target address, and the memory space corresponding to the first target address is the same as the memory space corresponding to the second target address; the starting address of the first target address is the address after the memory address of the first target object, and the first target object is the last object in the second type of object; wherein, after adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated object size of the first type of object.
2. The method according to claim 1, characterized in that, After each object in the first type of object is adjusted to the second target address, the memory space occupied by the first type of object is greater than or equal to the updated size of the first type of object. The starting memory address of the second target address is the starting memory address of the first object in the first type of object, and the ending memory address of the second target address is the ending memory address of the last object in the first type of object. After adjusting the memory address of the second type of object, the last memory address of the first object is adjacent to the starting memory address of the second object. The first object and the second object are any two adjacent objects in the second type of object.
3. The method according to claim 2, characterized in that, The step of adjusting each object in the first type of objects to the second target address in the second memory region according to the updated object size includes: Perform a first operation on each object in the first type of objects, adjusting the first type of objects to the second target address, wherein the first operation includes: The third object is adjusted to the first sub-address according to the updated object size. The third object is any object in the first type of object. The first sub-address is the address in the second target address. The memory space corresponding to the first sub-address is greater than or equal to the updated object size of the third object. The fourth object is adjusted to the second sub-address according to the updated object size. The fourth object is any object in the first type of object. The memory space corresponding to the second sub-address is greater than or equal to the updated object size of the fourth object. The second sub-address is the address in the second target address that is adjacent to the first sub-address.
4. The method according to claim 3, characterized in that, The step of adjusting the third object to the first sub-address according to the updated object size includes: If the sum of the last memory address of the fifth object and the updated size of the third object is greater than the last memory address of the third object, then the third object is adjusted to the first sub-address according to the updated object size, and the fifth object is the object preceding the third object in the first memory region.
5. The method according to claim 4, characterized in that, The method further includes: If the sum of the last memory address of the fifth object and the updated size of the third object is less than or equal to the last memory address of the third object, then the third object is adjusted to the third sub-address according to the updated object size, and the third sub-address is adjacent to the last memory address of the fifth object.
6. The method according to any one of claims 1-5, characterized in that, The step of determining the first type of objects and the second type of objects based on the memory space occupied by each of the plurality of objects and the updated object size of the plurality of objects includes: A second operation is performed on the plurality of objects to determine the first type of object and the second type of object; the second operation includes: If the last memory address of the sixth object is less than the sum of the starting memory address of the sixth object and the updated size of the sixth object, then the sixth object is determined to be the first type of object, and the sixth object is any one of the plurality of objects; If the last memory address of the sixth object is greater than or equal to the sum of the starting memory address of the sixth object and the updated size of the sixth object, then the sixth object is determined to be the second type of object.
7. An address adjustment device, characterized in that, include: The acquisition unit is configured to, when a hot update request is received, acquire the memory address of each of the multiple objects and the updated size of the multiple objects, wherein the memory address is the address corresponding to the memory space occupied by the object; The memory addresses of the plurality of objects are located in the first memory region; The processing unit is configured to perform the following: determining a first type of object and a second type of object based on the memory space occupied by each of the plurality of objects and the updated object size of the plurality of objects; the first type of object is an object whose memory space occupied is less than the updated object size, and the second type of object is an object whose memory space occupied is greater than or equal to the updated object size. The processing unit is further configured to adjust each object in the first type of object to a second target address in the second memory region according to the updated object size, wherein the second memory region has no intersection with the first memory region; The processing unit is further configured to adjust the memory address of the second type of object according to the memory address of the second type of object and the updated size of the second type of object; The processing unit is further configured to adjust the data corresponding to the second target address to the first target address, wherein the memory space corresponding to the first target address is the same as the memory space corresponding to the second target address; the starting address of the first target address is the address after the memory address of the first target object, and the first target object is the last object in the second type of object; wherein, after adjusting the first type of object to the first target address, the memory space occupied by the first type of object is greater than or equal to the updated object size of the first type of object.
8. A server, characterized in that, The server includes: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the address adjustment method as described in any one of claims 1-6.
9. A computer-readable storage medium storing instructions thereon, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of a computer, the computer is able to perform the address adjustment method as described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the address adjustment method according to any one of claims 1-6.
Citation Information
Patent Citations
Method and apparatus for managing storage space
CN109241178A
Application program updating method and device and storage medium
CN113110864A
