State recovery method, apparatus, device, storage medium, and program product

By generating memory snapshots containing memory and object information, the problem of low state recovery efficiency in existing technologies is solved, achieving efficient and accurate state recovery.

CN122111752APending Publication Date: 2026-05-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2024-11-25
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies require traversing all objects one by one for serialization and deserialization during state recovery in distributed systems, which is difficult to develop and has low performance.

Method used

By generating a memory snapshot of the program object, which contains memory and object information, the state can be restored to indicate memory data and runtime logic.

Benefits of technology

It improves the efficiency and accuracy of state recovery, enabling the one-time recovery of the state of program objects involved in the application, maintaining data integrity, and helping the application continue execution from the point of interruption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111752A_ABST
    Figure CN122111752A_ABST
Patent Text Reader

Abstract

The application discloses a state recovery method and device, equipment, storage medium and program product, and relates to the technical field of computers. The method comprises the following steps: in the running process of a first application program, generating a memory snapshot corresponding to a program object in the first application program at a first time, the memory snapshot comprising memory information and object information corresponding to the program object, the memory information being used for indicating memory data occupied by the program object and a memory structure used by a memory manager, and the object information being used for indicating the running logic of the program object; receiving a state recovery request, the state recovery request being used for requesting to recover the object state of the program object to the state at the first time; and acquiring the memory snapshot based on the state recovery request, the memory snapshot being used for indicating that the object state of the program object is recovered to the state at the first time according to the memory information and the object information, so that the memory structure and the state of the program object can be completely recovered, and the accuracy and efficiency of state recovery are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a state recovery method, apparatus, device, storage medium, and program product. Background Technology

[0002] In modern distributed systems and high-performance computing environments, state synchronization and recovery are key technologies for ensuring system stability and data consistency. As application complexity increases, especially in scenarios involving multiple users, processes, and devices, systems must be able to maintain state consistency and integrity under various failure and interruption conditions.

[0003] In related technologies, state recovery is achieved by serializing and deserializing all objects in memory. Serialization is the process of converting an object's state into a format that can be stored or transmitted (such as JSON, XML, or binary format), while deserialization is the process of restoring these formats to the original object state. This method allows the system to capture memory state at different points in time and save this state information in persistent storage. When recovery is needed, the system can reconstruct the object by deserializing this state information, thereby restoring it to its previous state.

[0004] However, the above method requires traversing all objects one by one to reconstruct their state through serialization and deserialization. Each object needs to have a clear constructor and recovery logic to achieve reconstruction, which is difficult to develop and has low state recovery performance. Summary of the Invention

[0005] This application provides a state recovery method, apparatus, device, storage medium, and program product, which can improve state recovery efficiency. The technical solution is as follows.

[0006] On the one hand, a state recovery method is provided, the method comprising:

[0007] During the execution of the first application, a memory snapshot corresponding to the program object in the first application at a first moment is generated. The memory snapshot includes memory information and object information corresponding to the program object. The memory information is used to indicate the memory data occupied by the program object and the memory structure used by the memory manager. The object information is used to indicate the execution logic of the program object.

[0008] Receive a state recovery request, the state recovery request being used to request the restoration of the object state of the program object to the state it was in at the first moment;

[0009] The memory snapshot is obtained based on the state recovery request. The memory snapshot is used to indicate that the object state of the program object is restored to the state it was in at the first moment according to the memory information and the object information.

[0010] On the other hand, a state recovery device is provided, the device comprising:

[0011] The generation module is used to generate a memory snapshot of a program object in the first application at a first moment during the execution of the first application. The memory snapshot includes memory information and object information corresponding to the program object. The memory information is used to indicate the memory data occupied by the program object and the memory structure used by the memory manager. The object information is used to indicate the running logic of the program object.

[0012] The receiving module is used to receive a state recovery request, wherein the state recovery request is used to request the restoration of the object state of the program object to the state it was in at the first moment;

[0013] The acquisition module is used to acquire the memory snapshot based on the state recovery request. The memory snapshot is used to indicate that the object state of the program object is restored to the state it was in at the first moment according to the memory information and the object information.

[0014] In some embodiments, the generation module includes:

[0015] The first acquisition unit is used to obtain the memory information based on the memory data corresponding to the program object in the first application at the first moment and the memory structure used by the memory manager;

[0016] The second acquisition unit is used to obtain the object information based on the state of the program object in the first application and the mapping relationship between the program object and the handle, wherein the handle is an index in memory used to uniquely identify the program object;

[0017] A snapshot generation unit is used to generate the memory snapshot based on the memory information and the object information.

[0018] In some embodiments, the first acquisition unit is further configured to:

[0019] At the first moment, the memory allocation status is obtained from the memory manager corresponding to the program object in the first application. The memory allocation status is used to indicate the free list and at least one first memory block that has been allocated for the program object in the first application at the first moment. The free list is used to indicate the memory blocks that are not used by the program object in the first application at the first moment.

[0020] Based on the memory allocation status, obtain the memory block information corresponding to each of the at least one first memory block;

[0021] The memory allocation status and the memory block information are used as the memory information.

[0022] In some embodiments, the second acquisition unit is further configured to:

[0023] Iterate through the program objects involved in the first application;

[0024] Obtain the handle, type information, and status information corresponding to the program object. The type information is used to indicate the virtual table address and base address corresponding to the program object. The status information is used to indicate the attributes and pointers of the program object. The virtual table address is used to indicate the memory address of the program object relative to the base address. The base address is used to indicate the memory block corresponding to the program object.

[0025] Determine the mapping relationship between the program object and the handle;

[0026] The mapping relationship, the type information, and the status information are used as the object information.

[0027] In some embodiments, the generation module is further configured to:

[0028] A memory snapshot corresponding to the program object in the first application is generated in real time, where the first moment is the current moment corresponding to the first application; or...

[0029] Memory snapshots corresponding to the program objects in the first application are generated at preset time intervals, where the first moment is a moment determined based on the preset time interval; or...

[0030] In response to receiving a snapshot generation request, a memory snapshot corresponding to the program object in the first application is generated, wherein the first moment is the moment specified based on the snapshot generation request.

[0031] In some embodiments, the memory snapshot is generated by a first device; the apparatus further includes a processing module.

[0032] The receiving module is further configured to receive a disconnection and reconnection request from the second device. The disconnection and reconnection request is used to request the restoration of the communication connection with the first device at the first moment. The disconnection and reconnection request includes the state restoration request. The first device is used to provide the second device with the state of the program object in the first application.

[0033] The processing module is used to send the memory snapshot to the second device based on the disconnection and reconnection request. The memory snapshot is used to instruct the second device to restore the object state of the program object to the state it was in at the first moment according to the memory information and the object information.

[0034] In some embodiments, the memory snapshot is generated by a first device;

[0035] The receiving module is also used to automatically generate the state recovery request;

[0036] The processing module is further configured to send the memory snapshot to at least two second devices based on the state recovery request, wherein the at least two second devices are configured to synchronize the state of program objects in the first application based on the memory snapshot sent by the first device; or,

[0037] Based on the state recovery request, the program object in the first application is restored locally on the first device based on the memory snapshot to the state it was in at the first moment.

[0038] In some embodiments, the processing module is further configured to restore the object state of the program object to the state it was in at the first moment according to the memory information and the object information in the memory snapshot.

[0039] In some embodiments, the processing module includes:

[0040] The memory recovery unit is used to allocate memory blocks in the memory manager according to the memory allocation status in the memory snapshot, rebuild the memory structure occupied by the program object, and restore the memory data.

[0041] The object recovery unit is used to recover the program object corresponding to the handle based on the mapping relationship between the handle and the program object in the memory snapshot.

[0042] In some embodiments, the object recovery unit is further configured to:

[0043] Restore the unused handles of the program objects in the first application according to the memory snapshot;

[0044] Restore the handle used by the program object in the first application according to the memory snapshot;

[0045] Obtain the object information corresponding to the program object that matches the mapping relationship based on the handle used by the program object;

[0046] The program object's memory address relative to its base address is recovered based on the type information in the object information, and the corresponding attributes and pointers of the program object are recovered based on the state information in the object information.

[0047] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the state recovery method as described in any of the embodiments of this application above.

[0048] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the state recovery method as described in any of the embodiments of this application above.

[0049] On the other hand, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the state recovery methods described in the above embodiments.

[0050] The beneficial effects of the technical solutions provided in this application include at least the following:

[0051] By using memory snapshots corresponding to program objects to archive the memory structure occupied by the program objects and the program objects' execution logic, the memory structure and the state of the program objects can be completely restored when restoring program objects in the application. Since the memory structure can indicate the layout of program objects in memory and the reference relationships between them, restoring the memory structure can maintain data integrity, preserve object references, and improve the accuracy of state restoration. This helps the application continue execution from where it was interrupted, and the state of the program objects involved in the application can be restored all at once based on the memory snapshot, without having to restore the state of each object individually, thus improving the efficiency of state restoration. Attached Figure Description

[0052] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 This is a schematic diagram of a state recovery system provided in an exemplary embodiment of this application;

[0054] Figure 2 This is a flowchart of a state recovery method provided in an exemplary embodiment of this application;

[0055] Figure 3 This is a flowchart of a memory snapshot generation method provided in an exemplary embodiment of this application;

[0056] Figure 4 This is a flowchart of a memory snapshot-based state recovery method provided in an exemplary embodiment of this application;

[0057] Figure 5 This is a schematic diagram of a memory manager provided in an exemplary embodiment of this application;

[0058] Figure 6 This is a schematic diagram of the object system structure provided in an exemplary embodiment of this application;

[0059] Figure 7 This is a schematic diagram of a memory snapshot generation process provided in an exemplary embodiment of this application;

[0060] Figure 8 This is a schematic diagram of a memory snapshot recovery process provided in an exemplary embodiment of this application;

[0061] Figure 9 This is a schematic diagram of a synchronization process based on a memory snapshot provided in an exemplary embodiment of this application;

[0062] Figure 10 This is a flowchart of a state recovery request acquisition method provided in an exemplary embodiment of this application;

[0063] Figure 11 This is a schematic diagram of a disconnection and reconnection scenario in a frame-synchronized game provided in an exemplary embodiment of this application;

[0064] Figure 12 This is a schematic diagram of a full-state synchronization scenario for a small memory system provided in an exemplary embodiment of this application;

[0065] Figure 13 This is a schematic diagram of a local save scenario for a single-player game provided in an exemplary embodiment of this application;

[0066] Figure 14 This is a structural block diagram of a state recovery device provided in an exemplary embodiment of this application;

[0067] Figure 15 This is a structural block diagram of a state recovery device module provided in an exemplary embodiment of this application;

[0068] Figure 16 This is a structural block diagram of a terminal provided in an exemplary embodiment of this application. Detailed Implementation

[0069] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0070] It should be understood that although the terms first, second, etc., may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, a first parameter may also be referred to as a second parameter without departing from the scope of this disclosure, and similarly, a second parameter may also be referred to as a first parameter. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."

[0071] In modern distributed systems and high-performance computing environments, state synchronization and recovery are key technologies for ensuring system stability and data consistency. As application complexity increases, especially in scenarios involving multiple users, processes, and devices, systems must maintain state consistency and integrity under various failure and interruption conditions. One related technology achieves state recovery by serializing and deserializing all objects in memory. Serialization is the process of converting an object's state into a format that can be stored or transmitted (such as JSON, XML, or binary format), while deserialization is the process of restoring these formats to the original object state. This approach allows the system to capture memory states at different points in time and store this state information in persistent storage. When recovery is needed, the system can reconstruct the object by deserializing this state information, thus restoring it to its previous state. However, this method requires traversing all objects one by one for serialization and deserialization, requiring each object to have an explicit constructor and recovery logic for reconstruction, resulting in high development difficulty and low state recovery performance.

[0072] The state recovery method provided in this application archives the memory data occupied by the program object, the memory structure used by the memory manager, and the running logic of the program object by using a memory snapshot corresponding to the program object. When restoring program objects in the application, the memory structure and the state of the program object can be completely restored. Since the memory structure can indicate the layout of program objects in memory and the reference relationships between them, restoring the memory structure can maintain data integrity, maintain object references, and improve the accuracy of state recovery. This is beneficial for helping the application to continue execution from the point of interruption. Moreover, the state of the program objects involved in the application can be restored at once based on the memory snapshot, without having to restore the state of each object separately, thus improving the efficiency of state recovery.

[0073] First, the status recovery system of this application will be introduced. Please refer to... Figure 1 The illustration shows a schematic diagram of a state recovery system provided in an exemplary embodiment of this application, which includes a terminal 10.

[0074] The terminal 10 runs a first application, which can be any application such as an online game, a single-player game, a cloud game, an online shopping program, a multimedia playback program, a social application, or an e-reading program. This application embodiment does not limit this.

[0075] In some embodiments, the terminal 10 may experience program interruption due to issues such as program crashes or network jitter, requiring the first application to be restored to its state before the interruption. The terminal 10 can restore the first application through a locally stored memory snapshot.

[0076] To illustrate, taking local storage on the terminal as an example, during the execution of the first application, the terminal 10 generates a memory snapshot corresponding to the program object in the first application at a first moment. The memory snapshot includes memory information and object information corresponding to the program object. The memory information is used to indicate the memory data occupied by the program object and the memory structure used by the memory manager. The object information is used to indicate the running logic of the program object. The terminal 10 receives a state recovery request, which is used to request the restoration of the object state value of the program object to the state it was in at the first moment. Based on the state recovery request, the terminal 10 obtains the memory snapshot and restores the object state of the program object to the state it was in at the first moment according to the memory information and object information of the memory snapshot.

[0077] In some embodiments, the state recovery system also includes a server 20, and the terminal 10 and the server 20 are connected via a network.

[0078] Optionally, server 20 is used to execute the logic layer of the first application, and terminal 10 is used to specify the presentation layer of the first application according to the logic layer status issued by server 20.

[0079] To illustrate, taking the reconnection of a frame-synchronized game as an example, server 20 runs a first application. Server 20 sends frame synchronization data to terminal 10 to keep the state of the first application running on terminal 10 synchronized with the program state on server 20. Server 20 obtains the first moment of disconnection of terminal 10 and generates a memory snapshot of the program objects in the first application at that moment during the execution of the first application. Server 20 receives a state restoration request from terminal 10 and sends the memory snapshot corresponding to the first moment to terminal 10 based on the state restoration request. Terminal 10 restores the object state of the program objects to the state at the first moment according to the memory information and object information of the memory snapshot, so that the logic layer of the first application in terminal 10 is restored to the first moment. Afterwards, terminal 10 can follow the frames to the current frame corresponding to server 20, realizing the reconnection of the frame-synchronized game.

[0080] Taking the full-state synchronization of a small memory system as an example, server 20 is responsible for calculating all the running logic of the first application and broadcasting the results to all clients (such as terminal 10) in the form of a memory snapshot.

[0081] It is worth noting that the above-mentioned application scenarios for state recovery are merely illustrative examples, and the embodiments of this application do not limit them.

[0082] The aforementioned terminal is optional and can be a desktop computer, laptop computer, mobile phone, tablet computer, e-book reader, Moving Picture Experts Group Audio Layer III (MP3) player, Moving Picture Experts Group Audio Layer IV (MP4) player, smart TV, smart vehicle, and other types of terminal devices. This application embodiment does not limit the specific terminal device to these types.

[0083] It is worth noting that the aforementioned servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud security, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0084] Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to achieve data computing, storage, processing, and sharing.

[0085] In some embodiments, the server described above can also be implemented as a node in a blockchain system.

[0086] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant regions. For example, the operational data and account information involved in this application were obtained with full authorization.

[0087] To further explain, this application can display a prompt interface, pop-up window, or output voice prompts before and during the collection of user-related data (e.g., program objects, memory structures, etc. involved in this application). These prompt interfaces, pop-ups, or voice prompts are used to inform the user that their relevant data is being collected. This ensures that the application only begins executing the steps related to acquiring user-related data after receiving confirmation from the user regarding the prompt interface or pop-up window; otherwise (i.e., without receiving confirmation from the user), the steps to acquire user-related data end, meaning no user-related data is acquired. In other words, all user data collected in this application is collected with the user's consent and authorization, and the collection, use, and processing of related user data must comply with the relevant laws, regulations, and standards of the relevant regions.

[0088] This is illustrative; please refer to it. Figure 2 This document illustrates a flowchart of a state recovery method provided in an exemplary embodiment of this application. This method can be executed by a terminal, a server, or both. This embodiment uses the execution of the method by a terminal as an example for illustration. Figure 2 As shown, the method includes the following steps:

[0089] Step 210: During the execution of the first application, a memory snapshot of the program object in the first application at the first moment is generated.

[0090] A memory snapshot includes memory information and object information corresponding to a program object. The memory information indicates the memory data occupied by the program object and the memory structure used by the memory manager, while the object information indicates the running logic of the program object.

[0091] Optionally, the first application can be any application such as an online game, a single-player game, a cloud game, an online shopping program, a multimedia player, a social application, or an e-reader; this application embodiment does not limit this.

[0092] Program objects are the basic elements that constitute the first application. They are logical objects in the first application and are used to represent entities that have specific logical meanings and functions in the first application.

[0093] A memory snapshot is a comprehensive record of the memory state of an application at a specific moment. It is not just a simple data copy, but delves into the memory structure and the runtime logic of program objects, accurately capturing the entire memory landscape of the application at a specific moment. By recording the memory structure and runtime logic occupied by program objects at a specific moment, the application can be restored to its state at that moment.

[0094] The aforementioned "first moment" can be any moment during the execution of the first application.

[0095] Determining the first moment to generate a memory snapshot during the initial application execution is crucial, and this first moment can be determined based on the specific application scenario requirements.

[0096] In the disconnection and reconnection scenario of frame-synchronized games, the first moment can be the game state checkpoint moment recorded periodically by the server, to ensure that the most recent and valid game state can be obtained when the client disconnects.

[0097] For full-state synchronization of small memory systems, the first moment may be when the system performs certain critical operations (such as after the initialization of the physical simulation module) or during periodic state recording.

[0098] In a single-player game's local save scenario, the first moment can be the point in time when the player completes an important level, achieves a specific accomplishment, or when the game's auto-save settings are set.

[0099] Taking a real-time snapshot as an example, a memory snapshot corresponding to the program object in the first application is generated in real time. The first moment is the current moment corresponding to the first application. This memory snapshot is used to indicate the latest state of the program object in the first application in real time.

[0100] To illustrate, taking a single-player game save as an example, in order to prevent the game from crashing or failing to quickly resume the game process when re-entering the game, the state of the program objects can be collected locally in real time, and a memory snapshot can be generated in real time. This allows the memory snapshot to always indicate the latest state of the program objects in the first application. Thus, when the game crashes or exits normally and is restarted, the latest state before the game crashes or exits normally can be restored by reading the memory snapshot.

[0101] The method provided in this application generates memory snapshots in real time, enabling the memory snapshots to indicate the latest state of program objects in the application. This allows for local saving when programs that perform logic calculations locally, such as single-player games, crash. The latest state before the crash can be quickly restored through memory snapshots, improving the efficiency of state restoration based on local memory snapshots.

[0102] Taking the continuous generation of snapshots as an example, memory snapshots corresponding to program objects in the first application are generated according to a preset time interval, and the first moment is the moment determined based on the preset time interval.

[0103] Optionally, multiple memory snapshots can be stored, or only the memory snapshot most recent to the current moment can be stored.

[0104] Taking the storage of multiple memory snapshots as an example, the memory snapshots can be associated with their corresponding generation times, so that the memory snapshot generated at the specified time can be read.

[0105] Specifically, at the i-th generation time, a memory snapshot is generated according to a preset time interval. The i-th generation time and the i-th memory snapshot are stored together. i is a positive integer. When it is necessary to read the memory snapshot at a specified time t, if the i-th generation time ≤ t < the (i+1)-th generation time, the i-th memory snapshot is read according to the i-th generation time.

[0106] Taking the example of storing only the memory snapshot closest to the current time, the i-th memory snapshot is generated and stored according to the preset time interval. If the (i+1)-th survival snapshot is generated, the i-th survival snapshot is replaced with the (i+1)-th survival snapshot when storing, where i is a positive integer.

[0107] The method provided in this application generates memory snapshots at preset time intervals. When storing multiple memory snapshots, it can enrich the corresponding time points that the program can recover, and reduce the repeated generation of memory snapshots corresponding to the same or similar states at close time points according to the preset time intervals, thereby reducing the computational load of memory snapshot generation. When storing only the memory snapshot closest to the current time, it can reduce the computational load of real-time generation and improve the performance of memory snapshot generation based on the latest memory snapshot to achieve state recovery.

[0108] Taking the generation of a memory snapshot at a specified time as an example, in response to receiving a snapshot generation request, a memory snapshot corresponding to the program object in the first application is generated, where the first time is the time specified based on the snapshot generation request.

[0109] Optionally, the snapshot generation request may be automatically triggered based on a specific event, generated based on the snapshot generation operation, or sent by other devices. This application embodiment does not limit this.

[0110] By generating memory snapshots at the time specified in the snapshot generation request, memory snapshots can be generated precisely according to the snapshot generation requirements. This ensures that the memory snapshots accurately match the program execution time indicated by the snapshot generation requirements, improving the accuracy and efficiency of application recovery based on memory snapshots.

[0111] In some embodiments, a snapshot object is predefined, the snapshot object is initialized, and a snapshot structure is obtained, which is used to indicate how the memory snapshot is generated.

[0112] Optionally, a memory snapshot can be generated by calling a snapshot generation function in the snapshot object. This generation function is used to instruct the acquisition of memory information and object information of the program object to obtain a memory snapshot.

[0113] In some embodiments, memory information is obtained based on the memory structure corresponding to the program object in the first application at a first moment; object information is obtained based on the state of the program object in the first application and the mapping relationship between the program object and the handle, where the handle is an index in memory used to uniquely identify the program object; and a memory snapshot is generated based on the memory information and the object information.

[0114] Schematic, the process of obtaining memory information includes: obtaining the memory allocation status from the memory manager corresponding to the program object in the first application at a first moment, the memory allocation status being used to indicate the free list, and at least one first memory block allocated for the program object in the first application at the first moment, the free list being used to indicate the memory blocks not used by the program object in the first application at the first moment; obtaining memory block information corresponding to the at least one first memory block based on the memory allocation status; and using the memory allocation status and memory block information as memory information.

[0115] In illustrative terms, the process of obtaining object information includes: traversing the program objects involved in the first application; obtaining the handle, type information, and status information corresponding to the program object, whereby the type information indicates the virtual table address and base address corresponding to the program object, the status information indicates the attributes and pointers of the program object, the virtual table address indicates the memory address of the program object relative to the base address, and the base address indicates the memory block corresponding to the program object; determining the mapping relationship between the program object and the handle; and using the mapping relationship, type information, and status information as object information.

[0116] Step 220: Receive the status recovery request.

[0117] A state recovery request is used to request that the state of a program object be restored to its state at the first moment.

[0118] Optionally, the state recovery request may be sent by other devices or generated locally by the server; this application embodiment does not limit this.

[0119] In some embodiments, receiving a state recovery request includes a request source identification process and a request parameter parsing process.

[0120] State restoration requests can originate from various sources. In frame-synchronized games with reconnection scenarios, the request typically originates from the client, which sends a state restoration request to the server when it detects a reconnection event. In single-player games with local save files, the request may originate from player actions (such as selecting to load a save file) or from the game's own error recovery mechanism.

[0121] The system needs to identify the source and type of the request in order to take appropriate processing strategies. For example, for a frame synchronization game disconnection reconnection request from a client, the server needs to verify the client's identity and the legitimacy of the request to prevent malicious requests from causing game data leakage or incorrect recovery.

[0122] State recovery requests typically contain key parameters, such as the identifier of the first point in time to which recovery is needed, the application identifier, and the object scope. The system needs to accurately parse these request parameters. For example, in a full-state synchronization scenario for a small-memory system, the request parameters might include the identifier of the small-memory system module to be synchronized and the corresponding first-point memory snapshot identifier.

[0123] When parsing request parameters, the completeness and validity of the parameters must be considered. If the parameters are incomplete or invalid, the system should return appropriate error messages to avoid performing incorrect recovery operations. For example, if the received request lacks an application identifier, the system cannot determine which application's state to restore and should indicate that the request parameters are incorrect.

[0124] In some embodiments, after receiving a state recovery request, it is also necessary to verify the state recovery request, including but not limited to permission verification and data consistency verification.

[0125] Before processing a state recovery request, the requester's permissions must be verified. For example, in enterprise applications, only users or system modules with specific permissions can initiate a state recovery request. For applications involving sensitive data, such as financial systems, permission verification is particularly important.

[0126] Authentication can be implemented in various ways, such as user-based authentication (username / password, digital certificate, etc.) and role-based access control (RBAC). For example, in an RBAC-based enterprise application system, only users with the roles of "system administrator" or "data recovery operator" can initiate valid state recovery requests.

[0127] To ensure the success of the recovery operation and the accuracy of the data, it is necessary to verify the consistency of the data related to the request. This includes verifying whether a valid memory snapshot exists at the first moment specified in the request, and whether the current state of the application allows for the recovery operation.

[0128] For example, in a multi-version concurrency control database system, when processing a state recovery request, it is necessary to check whether the version to which the request is to be restored is compatible with the current database version to prevent data loss or corruption due to version incompatibility.

[0129] Step 230: Obtain a memory snapshot based on the state recovery request.

[0130] A memory snapshot is used to indicate how to restore the object state of a program object to its state at a given moment, based on memory and object information.

[0131] In some embodiments, after a memory snapshot is generated, it can be stored in a specified storage space. When a state recovery request is received, the memory snapshot can be read from the storage space and sent to the device that sent the state recovery request to help the device recover the first application based on the memory snapshot, or the first application can be recovered locally based on the memory snapshot.

[0132] The process of restoring state based on memory snapshots includes restoring the memory structure and restoring the state of program objects.

[0133] The process of restoring the memory structure includes, but is not limited to, adjusting the memory manager based on memory snapshots and adjusting memory address mappings.

[0134] The memory manager is adjusted based on the memory structure information in the memory snapshot. First, the internal data structures of the memory manager are reinitialized according to the collected MemoryChunk size and allocated memory size information. For example, if the memory snapshot shows that multiple MemoryChunks of a specific size have been allocated at the first moment, then when restoring the state, the corresponding data structures of the memory manager need to be set to reflect these allocations.

[0135] For the FreeBlockList information, the memory manager's free block list is restored to its initial state. This may involve rebuilding the links in the free block list in memory to ensure the distribution of free blocks matches the records in the memory snapshot. In a multi-threaded environment, attention must be paid to the memory manager's concurrency safety; it may be necessary to pause other thread operations related to memory allocation until the memory structure is fully restored.

[0136] Because memory addresses may change in different process environments, it is necessary to adjust the memory address mapping based on the memory base address information in the memory snapshot and the current process's memory layout. This may involve relocating the memory addresses of program objects.

[0137] For example, in a scenario involving the loading of a Dynamic Link Library (DLL), when restoring a memory snapshot containing DLL-related objects, it's necessary to remap the memory addresses of the objects in the DLL based on the DLL's load address in the current process. This can be achieved by recording the relative addresses of the objects (relative to the memory base address) in the memory snapshot and combining them with the current process's base address during restoration.

[0138] The process of restoring the state of program objects includes, but is not limited to, restoring the state of objects based on object information and handling dependencies between objects.

[0139] By utilizing the object information data structure in the memory snapshot, the state of program objects is gradually restored. First, based on the method call order and interaction relationships in the object information, the operation flow of the objects at the first moment is reproduced. For example, if the object information shows that an order object called the payment method of a payment object at the first moment, then this operation process needs to be simulated when restoring the state.

[0140] To restore object attribute values, the object's attributes are set to their state at the time of the snapshot, based on the values ​​recorded in the memory snapshot. This may involve assigning values ​​to the object's private member variables and public properties. For example, restoring attributes such as the quantity of goods and the total price in an order object to their recorded values ​​at the time of the snapshot.

[0141] When restoring the state of program objects, it's crucial to handle dependencies between them. If one object depends on the state restoration of another, the operations must be performed in the correct order. For example, in a game scenario, a character object might depend on the state restoration of an item object (e.g., the character holds a specific item). In this case, the item object's state must be restored first, followed by the character object's state, to ensure the dependencies between objects are correctly established.

[0142] For complex object dependency graphs, algorithms such as topological sorting can be used to determine the order in which object states are restored, ensuring that errors caused by unmet dependencies do not occur during the restoration process. For example, in an Enterprise Resource Planning (ERP) system, the order processing module may depend on the inventory management module and the customer management module. When restoring the state of objects related to the order processing module, the restoration order of objects in the inventory management module and the customer management module needs to be determined first using topological sorting, and then the restoration operations are performed sequentially.

[0143] It is worth noting that the above-described state recovery process is merely an example and is not limited to any particular method in this application.

[0144] In summary, the method provided in this application, by using a memory snapshot corresponding to the program object to archive the memory structure occupied by the program object and the running logic of the program object, can completely restore the memory structure and the state of the program object when restoring the program object in the application. Since the memory structure can indicate the layout of the program object in memory and the reference relationship between them, restoring the memory structure can maintain data integrity, maintain object references, improve the accuracy of state restoration, and help the application continue execution from the point of interruption. Moreover, the state of the program objects involved in the application can be restored at once based on the memory snapshot, without having to restore the state of each object separately, thus improving the efficiency of state restoration.

[0145] This is illustrative; please refer to it. Figure 3 This document illustrates a flowchart of a memory snapshot generation method provided in an exemplary embodiment of this application. This method can be executed by a terminal, a server, or both. This embodiment uses server execution as an example for illustration. Figure 3 As shown, step 210 above includes the following steps:

[0146] Step 211: Obtain memory information based on the memory data of the program object in the first application at the first moment and the memory structure used by the memory manager.

[0147] The memory structure is used to indicate at least one type of memory information, such as the size of the memory manager, the memory allocation status corresponding to the memory manager, and memory block information.

[0148] In some embodiments, the process of obtaining memory information includes: obtaining a memory allocation status from the memory manager corresponding to the program object in the first application at a first moment, wherein the memory allocation status is used to indicate a free list, and at least one first memory block allocated for the program object in the first application at the first moment, wherein the free list is used to indicate memory blocks not used by the program object in the first application at the first moment; obtaining memory block information corresponding to the at least one first memory block based on the memory allocation status; and using the memory allocation status and memory block information as memory information.

[0149] Optionally, memory information collection includes memory data collection and memory structure collection.

[0150] Memory data is obtained by recording the original data of the entire memory block corresponding to the first application at the first moment; the memory structure in the memory manager at the first moment is obtained, including the memory block size, the base address of the memory block, the allocated memory size, the relative virtual address (RVA) of the header object of each unused blockchain table in the memory allocator, and the number of blocks.

[0151] Memory data collection includes, but is not limited to, memory manager memory size collection and memory base address collection.

[0152] To collect memory sizes from the memory manager, the system needs to call relevant memory management interfaces to obtain the size of each MemoryChunk allocated by the memory manager. This may involve low-level functions provided by the operating system or query methods within a custom memory management module. For example, in Linux-based applications, memory manager information can be obtained through system calls, or the size of a MemoryChunk can be obtained by recording the metadata of each allocated block within a custom memory management module.

[0153] The method for obtaining the MemoryChunk size may differ depending on the type of memory manager (such as the buddy system allocator, heap allocator, etc.). The buddy system allocator may determine it through its predefined allocation rules and block size hierarchy, while the heap allocator may obtain it through the heap's internal data structures (such as heap block header information).

[0154] A memory base address is the starting address of a memory allocation. To collect memory base addresses, the system needs to locate the starting point of the allocation. In some simple memory management models, there might be an explicit global variable or memory-mapped file to record the memory base address. However, in more complex operating system environments, it may be necessary to obtain it by querying the process's memory mapping information. For example, in the Windows operating system, the application's memory base address information can be obtained by calling the relevant process memory query application programming interface (API).

[0155] Furthermore, considering the dynamic allocation and release of memory, the memory base address may change over time and with operations. Therefore, when collecting the memory base address, it is necessary to ensure that the memory base address obtained is valid at the first moment.

[0156] Memory structure collection includes, but is not limited to, collection of allocated memory size and collection of memory block list (FreeBlockList) information.

[0157] To determine the size of allocated memory, the system needs to traverse the relevant data structures of the memory manager. This may involve scanning memory allocation lists, bitmaps, or other memory management data structures. For example, in a list-based memory manager, the total amount of allocated memory is obtained by traversing the linked list of allocated memory blocks and summing the size of each block.

[0158] In a multithreaded environment, the impact of concurrent access on allocated memory size statistics needs to be considered. Locking mechanisms or lock-free data structures may be necessary to ensure data accuracy. For example, read-write locks can be used to allow multiple threads to read allocated memory size information simultaneously, but locking is applied during update operations to prevent data inconsistency.

[0159] Memory block linked list information is crucial for memory snapshots, as it records the distribution of unallocated free blocks in memory. When collecting FreeBlockList information, the system needs to delve into the internal data structures of the memory manager. For a linked list-based free block management method, it's necessary to record the starting address, size, and link relationship of each free block within the linked list.

[0160] Different memory managers may employ different strategies when managing the free block list. For example, some allocators use a split linked list (storing free blocks in different linked lists according to their size), while others use a simple linear linked list. When collecting FreeBlockList information, it is necessary to accurately obtain relevant information based on the specific memory manager implementation.

[0161] The method provided in this application embodiment, by obtaining memory allocation status and memory block information as memory information, enables the memory information to fully indicate the memory structure occupied by the program object. This allows the first application to allocate memory according to the memory allocation method of the logical layer when restoring the state based on the memory snapshot. This avoids the memory structure being different due to the device performing the state restoration freely allocating memory, or errors in the memory call logic causing the inability to accurately restore the program state, thereby improving the efficiency of state restoration.

[0162] Step 212: Based on the state of the program object in the first application and the mapping relationship between the program object and the handle, obtain the object information.

[0163] A handle is an index in memory used to uniquely identify a program object.

[0164] The state of a program object includes its attributes and pointers, as well as its memory address relative to the base address.

[0165] In some embodiments, the process of obtaining object information includes: traversing the program objects involved in the first application; obtaining the handle, type information, and status information corresponding to the program object, wherein the type information is used to indicate the virtual table address and base address corresponding to the program object, the status information is used to indicate the attributes and pointers of the program object, the virtual table address is used to indicate the memory address of the program object relative to the base address, and the base address is used to indicate the memory block corresponding to the program object; determining the mapping relationship between the program object and the handle; and using the mapping relationship, type information, and status information as object information.

[0166] Pointers are used to indicate the reference relationships between program objects.

[0167] To illustrate, object information is collected by traversing the object data (HandleObjects) in the object manager, and all unused handle values ​​are collected by traversing the free handle value array (FreeHandleValues) in the object manager.

[0168] In some embodiments, the process for collecting and recording object information includes a collection and recording process.

[0169] The runtime logic of a program object includes the order of method calls, the interaction relationships between objects, and the behavior of objects under specific events. To record this information, the system needs to analyze the application's runtime environment in real-time. For example, this can be achieved by inserting detection code at the method entry and exit points to record method call behavior, such as through bytecode instrumentation or Aspect-Oriented Programming (AOP) techniques.

[0170] The interaction relationships between objects can be determined by analyzing their method call parameters and shared data structures. For example, in an e-commerce system, the interaction relationship between an order object and a user object can be recorded through the user ID attribute in the order object and the user object's query and operation methods on the order object.

[0171] In some embodiments, an object information data structure needs to be constructed after collecting object information.

[0172] After collecting information related to the runtime logic of program objects, this information needs to be organized into a suitable data structure and stored in a memory snapshot. A tree structure can be used to represent the method call hierarchy of objects, and a graph structure can be used to represent the interactions between objects. For example, an object's method call chain can be represented as the nodes and edges of a tree, and the interactions between objects can be represented as the nodes and connecting edges of a graph.

[0173] Meanwhile, to facilitate subsequent state recovery operations, the storage and query efficiency of the data needs to be considered when constructing the object information data structure. For example, for frequently queried object relationship information, data structures such as hash tables can be used to accelerate the query process.

[0174] The method provided in this application uses the handle, type information, and state information corresponding to the program object to map the handle to the program object, as well as the type information and state information, as object information. This ensures that the program object in the presentation layer can be restored based on the mapping relationship through the handle in the logic layer, the location of the program object in memory can be restored based on the type information, and the specific program object instance can be accurately restored based on the state information, thus ensuring the comprehensiveness of restoring the program object based on the object information.

[0175] Step 213: Generate a memory snapshot based on memory information and object information.

[0176] In some embodiments, a snapshot object is predefined, the snapshot object is initialized, and a snapshot structure is obtained, which is used to indicate how the memory snapshot is generated.

[0177] Optionally, a memory snapshot can be generated by calling a snapshot generation function in the snapshot object. This generation function is used to instruct the acquisition of memory information and object information of the program object to obtain a memory snapshot.

[0178] After obtaining the memory information and object information, a memory snapshot is generated and stored by following the data structure or storage method indicated by the snapshot structure.

[0179] In summary, the method provided in this application obtains memory information based on the memory structure and object information based on the program object state, thereby generating a memory snapshot based on the memory information and object information. This allows the memory snapshot to fully indicate the program state of the first application at a first moment, including memory usage and the running logic of the program object. As a result, the program state of the first application can be fully restored based on the memory snapshot, improving the completeness and efficiency of state restoration.

[0180] In some embodiments, after obtaining a memory snapshot, the state of the program object can also be restored based on the memory snapshot. Please refer to [reference needed]. Figure 4 This document illustrates a flowchart of a memory snapshot-based state restoration method provided in an exemplary embodiment of this application. This method can be executed by a terminal, a server, or both. This embodiment uses server execution as an example for illustration. Figure 4 As shown, the following steps are included after step 230 above:

[0181] Step 240: Restore the object state of the program object to the state it was in at the first moment according to the memory information and object information in the memory snapshot.

[0182] In some embodiments, the state recovery process includes allocating memory blocks in the memory manager according to the memory allocation state in the memory snapshot, reconstructing the memory structure occupied by the program object and restoring memory data; and restoring the program object corresponding to the handle according to the mapping relationship between the handle and the program object in the memory snapshot.

[0183] Reconstructing the memory structure occupied by the program object and restoring memory data includes parsing the memory allocation state information in the memory snapshot, initializing the relevant structures in the memory manager according to the memory allocation state, allocating memory blocks according to the memory allocation state, and reconstructing the memory structure of the program object.

[0184] This example illustrates the process of parsing memory allocation status information from memory snapshots, including extracting MemoryChunk specifications and distribution information, confirming the status of allocated and free memory blocks, and interpreting specific parameters and structure records of the memory manager.

[0185] This involves initializing relevant structures in the memory manager based on the memory allocation status, including setting MemoryChunk parameters, constructing a free block list (or other free memory management structure), and adjusting other internal structures and parameters of the memory manager.

[0186] This involves allocating memory blocks according to their allocation status, reconstructing the memory structure of program objects, including traversing the allocated memory block records, allocating corresponding memory blocks, updating the association information and attributes of memory blocks, and handling complex relationships and special cases in the memory structure.

[0187] The process begins by traversing the allocated memory block information recorded in the memory snapshot. For each allocated memory block and its corresponding program object, the appropriate memory block allocation operation is performed within the current memory manager. Based on the size and number of MemoryChunks occupied by the allocated memory blocks, the corresponding MemoryChunks are located and allocated to the corresponding program object from the initialized memory manager structure. For example, if a program object initially occupies three 4KB MemoryChunks, the memory manager will search the free block list (or other free memory management structure) to obtain three available 4KB MemoryChunks, mark them as allocated, and update the status records of these MemoryChunks in the memory manager, gradually reconstructing the memory structure occupied by the program object.

[0188] During the allocation of memory blocks to program objects, it is also necessary to update the association information between the memory blocks and the program objects, as well as some attributes of the memory blocks themselves. An association marker is set for each allocated memory block and its corresponding program object so that the program object to which the memory block belongs can be quickly identified later. Simultaneously, based on the records in the memory snapshot, access permissions (such as read, write, execute, etc.) and memory protection attributes (such as whether sharing is allowed, whether it is protected, etc.) of the memory blocks are set to ensure that the usage and characteristics of the memory blocks are consistent with the initial state. For example, for a memory block occupied by a program object storing critical configuration data, its access permission will be set to read-only to prevent accidental modification of important data during the recovery process, ensuring the security and correctness of memory usage.

[0189] When reconstructing the memory structure of a program object, some complex relationships and special cases may be encountered that need to be handled. For example, if a program object contains pointers pointing to other memory blocks (such as an object's member variable being a pointer type pointing to the memory block of another object), these pointer relationships need to be accurately reconstructed based on the pointer-related information recorded in the memory snapshot (such as the pointer value, i.e., the address of the memory block it points to), to ensure that the memory references between objects are correct. Additionally, for memory alignment requirements in the memory structure (some hardware platforms or operating systems require that the starting address of a memory block must be a multiple of a specific number of bytes), corresponding adjustments must be made when allocating memory blocks to ensure that the memory structure conforms to the relevant specifications. For example, if the memory structure of a program object requires 8-byte alignment, but the starting address of the allocated MemoryChunk does not meet the alignment requirements, address offset operations may be necessary to satisfy the alignment conditions.

[0190] In the state recovery method provided in this application embodiment, the memory management of the first application needs to meet the preset memory management requirements.

[0191] The default memory management requirements include separate memory management for all logical content, distinct from the general memory management of the first application's engine.

[0192] Since the original memory structure is based on the original process during the process of restoring the state based on the memory snapshot, it is necessary to restore the memory structure that is valid in the current process based on the memory snapshot.

[0193] This is illustrative; please refer to it. Figure 5 , Figure 5 This is a schematic diagram of a memory manager provided in an exemplary embodiment of this application, as shown below. Figure 5 As shown, memory can be managed using memory manager 500.

[0194] Among them, the MemoryManager, as the top-level memory manager, is responsible for the allocation and release of memory blocks, as well as the creation and restoration of snapshots.

[0195] The PoolAllocator maintains a free list (FreeList) and an allocated memory list, and manages memory allocation through the memory allocation function (Malloc()), memory reallocation function (Realloc()), and memory release function (Free()).

[0196] A memory chunk contains information such as a base pointer, block size, page size, number of pages, and number of pages used. It also provides the ApplySnapshot() function to apply snapshots.

[0197] The FreeBlockList maintains the order of free blocks using the PushToFront() and PopFromFront() functions.

[0198] A memory region block list (Bundle) represents a group of memory region blocks. The memory blocks in the memory region block list are managed by a head and a count.

[0199] A memory region block list node (BundleNode) is used to point to the next node in the current memory region block list.

[0200] It is worth noting that the memory manager described above is merely an example and is not intended to limit the scope of this application.

[0201] The method provided in this application allocates memory blocks in the memory manager according to the memory allocation state in the memory snapshot, and reconstructs the memory structure occupied by the program object. It can accurately restore the memory structure when the state is restored, avoid problems such as memory allocation errors that prevent the accurate restoration of the program state, and improve the accuracy of state restoration.

[0202] In some embodiments, restoring the program object corresponding to the handle includes: restoring the handles of the program object that are not used in the first application according to the memory snapshot; restoring the handles of the program object used in the first application according to the memory snapshot; obtaining the object information corresponding to the program object that conforms to the mapping relationship according to the handle used by the program object; restoring the memory address of the program object relative to the base address according to the type information in the object information; and restoring the attributes and pointers corresponding to the program object according to the state information in the object information.

[0203] The illustrative process for restoring unused handles includes extracting information about unused handles from a memory snapshot, creating an instance of the unused handle in the current application environment, and incorporating the unused handle into the current handle management system.

[0204] Extracting information related to unused handles from memory snapshots requires identifying unused handle identifiers and attributes, and clarifying the relationships between unused handles and other elements.

[0205] Creating an instance of an unused handle in the current application environment requires calling the corresponding creation mechanism based on the handle type and setting the initial properties of the unused handle.

[0206] Incorporating unused handles into the current handle management system requires updating the handle management data structure and associating unused handles with related resources.

[0207] This illustrative description illustrates the recovery process for a handle used by a program object, including parsing detailed information about the handle, restoring the instance and state of the handle, and reproducing the operational behavior on the program object using the handle.

[0208] The process of parsing the detailed information of the handle includes obtaining the identifier and status of the handle, and collecting the associated objects and operation records of the handle.

[0209] Restoring the instance and state of the handle includes rebuilding the handle instance and restoring the handle state.

[0210] Reproducing the operation behavior on a program object using a handle includes triggering the corresponding method call according to the operation record and restoring the handle's access relationship to the object resources.

[0211] To illustrate, obtaining object information corresponding to a program object that matches a mapping relationship based on the handle used by the program object includes finding the corresponding mapping relationship record through the handle and extracting the object information corresponding to the program object.

[0212] Among these steps, finding the corresponding mapping record through the handle requires traversing the handle-object mapping table and verifying the accuracy of the handle-object mapping; extracting the object information corresponding to the program object requires obtaining the object's basic information and collecting the object's detailed attributes and runtime logic information.

[0213] Optionally, the basic information of an object includes the object's type (used to indicate the object's basic attributes and methods), the object's name (used to identify and distinguish the object in the application), etc.; detailed information includes the object's specific attribute values, which are used to indicate the object's specific state at a given moment. For example, a program object representing user information may have attributes such as username, age, login status, etc.; the object's runtime logic information includes how the object interacts with other objects in the application, the methods and functions it executes, and the order in which the methods are called, etc.

[0214] The process of recovering the memory address of a program object relative to its base address based on the type information in the object information includes parsing the object's type-related details and calculating the relative memory address in conjunction with the base address.

[0215] Recovering the attributes and pointers corresponding to the program object based on the state information in the object information includes restoring the object attribute values ​​and rebuilding the object pointer relationships.

[0216] In the state recovery method provided in this application embodiment, the object management of the first application needs to meet the preset object management requirements.

[0217] Since the focus of memory snapshot recovery is to restore object instances so that they remain valid in the new process, it is necessary to restore the pointer attributes of these objects. Furthermore, it is necessary to prevent the presentation layer above the logic layer from directly depending on logical objects through pointers. Therefore, an object system needs to be implemented, where all object classes inherit from a unified base class.

[0218] The default object management requirements include managing objects according to the object system with the following characteristics:

[0219] (1) Handle system. Access from the presentation layer to the logic layer depends on handles. When memory is restored, the handle structure is also restored.

[0220] (2) Pointer collection. Pointers are inevitably used inside objects. These pointers need to be collected when a snapshot is generated, and their relative offset addresses are obtained by subtracting them from the memory allocation base address.

[0221] (3) Custom Containers. Containers involve significant memory allocation, requiring a dedicated memory manager. Furthermore, the logic within containers is performance-intensive, necessitating the use of raw pointers instead of handles. This necessitates handling the creation and restoration of container snapshots. These functionalities are beyond the capabilities of general-purpose containers like the Standard Template Library (STL), thus requiring the implementation of custom containers using dedicated memory managers instead of general-purpose ones.

[0222] (4) Type System. Since objects contain virtual table pointers, and these virtual tables are generated at compile time, their addresses are related to the type and process. The assignment of the virtual table pointer is done within the object's constructor. During object restoration, no additional object logic should be executed, so the virtual table pointer cannot be restored using the object class's constructor. Instead, the corresponding virtual table address can be obtained through the object's type information, and then that address can be restored to the object.

[0223] The type system in the object system registers the type information of object classes with the object manager when the process starts. This type information mainly includes the object's ID, name, and virtual table address.

[0224] This is illustrative; please refer to it. Figure 6 , Figure 6 This is a schematic diagram of the object system structure provided in an exemplary embodiment of this application, such as... Figure 6 As shown, Object System 600 can be used to manage objects.

[0225] The ObjectManager is responsible for managing all objects, including adding, removing, and obtaining handle objects, as well as registering and obtaining type information.

[0226] An object represents a logical object in the system, containing a handle and a type ID, as well as methods to retrieve handle and type information.

[0227] A handle represents a handle to an object, containing a value and a checksum.

[0228] Type information (TypeInfo) is used to store information about the object type, including ID, name, and virtual table address.

[0229] TypeRegister <t>This is used to register object type information.

[0230] An object snapshot is used to store object information (object snapshot) of a program object, including base address, object handle value array, RVA table, pointer RVA table, free handle value array, and checksum generator.

[0231] The snapshot table (ISnapshottable) is an interface that defines methods for creating snapshots and marking pointer addresses.

[0232] It is worth noting that the above-described object system is merely an exemplary example, and the embodiments of this application do not limit it.

[0233] The method provided in this application improves the fidelity of program objects by restoring all handles based on memory snapshots when restoring program objects, thereby accurately determining the program objects of the presentation layer according to the operation logic of the logic layer based on the mapping relationship corresponding to the handles, and accurately restoring the state of program objects from the memory and object instance states by restoring the memory address, attributes and pointers of the program objects.

[0234] Based on the memory manager and object system (object manager) described above, the process of generating memory snapshots in the state recovery method provided in this application embodiment will be introduced.

[0235] The following steps are included when generating a memory snapshot:

[0236] (1) Collect memory data:

[0237] The original data in the entire memory block is recorded to obtain the memory data.

[0238] (2) Collect memory structures:

[0239] The memory manager can record the following structure data:

[0240] i. Record the size of the memory block;

[0241] ii. Record the base address of the memory block;

[0242] iii. Record the size of the allocated memory;

[0243] iv. Record the header RVA and block count information for each unused blockchain table in the memory allocator.

[0244] (3) Collect object information:

[0245] By iterating through the array of objects (HandleObjects) in the object manager:

[0246] i. Record the handle value of each object and store it in the object handle value array (ObjHandleValues) of the memory snapshot;

[0247] ii. Record the RVA of each object and store it in the object-relative virtual address table (ObjRVATable) of the memory snapshot;

[0248] iii. Record the RVA of the pointers used in each object and store it in the pointer-relative virtual address table (PtrRVATable) in the memory snapshot;

[0249] (4) Collect all unused handle values:

[0250] Iterate through the FreeHandleValues ​​array in the object manager and store all unused handle values ​​in the FreeHandleValues ​​array in the snapshot.

[0251] This is illustrative; please refer to it. Figure 7 , Figure 7 This is a schematic diagram of a memory snapshot generation process provided in an exemplary embodiment of this application, such as... Figure 7 As shown, the memory snapshot generation process includes a memory information collection process 710 and an object information collection process 720.

[0252] The memory information collection process 710 includes: step 711, recording the original data in the entire memory block; step 712, recording the memory structure, wherein recording the memory structure includes recording the size of the memory block, recording the base address of the memory block, recording the size of the allocated memory, and recording the header RVA and block count information of each unused blockchain table in the memory manager.

[0253] The object information collection process 720 includes the following steps: step 721, recording the handle value of each object; step 722, recording the RVA of each object; step 723, recording the RVA of the pointers used in each object; and step 724, recording all unused handle values.

[0254] The above steps can be executed sequentially or in parallel. This application embodiment does not limit the execution order of the above steps.

[0255] Based on the memory manager and object system (object manager) described above, the recovery process of memory snapshots in the state recovery method provided in this application embodiment will be introduced.

[0256] When restoring the state, the size of the memory blocks in the new memory manager should be greater than or equal to the size of the memory blocks recorded in the snapshot, and the sizes of the two memory pages should also be equal; otherwise, the memory snapshot cannot be restored. Under this premise, restore the memory snapshot using the following steps:

[0257] (1) Restore memory data:

[0258] Copy the raw memory data from the memory snapshot to the memory block in the memory manager.

[0259] (2) Restore memory structure:

[0260] i. Set the size of the allocated memory recorded in the memory snapshot to the memory manager;

[0261] ii. Set the RVA and Count information of the unused memory blockchain table recorded in the memory snapshot to the unused memory blockchain table in the new memory allocator in sequence. And set the pointer to the next node in each node of the memory blockchain table from the old address to the new address.

[0262] (3) Restore unused handle values:

[0263] Set the values ​​from the FreeHandleValues ​​array in the memory snapshot record to the FreeHandleValues ​​array in the new object manager.

[0264] (4) Restore pointer address:

[0265] The pointer in the memory snapshot is transformed relative to the pointer in the virtual address table (PtrRVATable) to a new memory address, and the value at the memory address pointed to by the pointer is also restored to the new memory address.

[0266] (5) Restore all objects:

[0267] Iterate through the handle values ​​of each object in the snapshot:

[0268] i. Retrieve the object's RVA from the object's RVA table (ObjRVATable) based on the handle value, and then restore it to a new pointer to this object using a new base pointer (BasePtr). Record this new pointer to the object in the new object manager's object list.

[0269] ii. Obtain type information through the type identifier (TypeID) in the object data, and set the virtual table address in the type information to this object.

[0270] This is illustrative; please refer to it. Figure 8 , Figure 8 This is a schematic diagram of a memory snapshot recovery process provided in an exemplary embodiment of this application, as shown below. Figure 8 As shown, the memory snapshot recovery process 800 includes a memory information recovery process 810 and an object information recovery process 820.

[0271] The memory information recovery process 810 includes recovering memory data and memory structure. Recovering memory data includes step 811, copying the original memory data from the memory snapshot to the memory blocks in the memory manager. Recovering the memory structure includes step 812, setting the allocated memory size recorded in the memory snapshot to the memory manager; and step 813, recovering the unused memory blockchain table.

[0272] The object information recovery process 820 includes the following steps: step 821, recovering unused handle values; step 822, recovering pointer addresses; and step 823, recovering all objects, including recovering pointers to objects and recovering the virtual tables of objects.

[0273] The above steps can be executed sequentially or in parallel. This application embodiment does not limit the execution order of the above steps.

[0274] In some embodiments, a memory snapshot synchronization scheme is also included. For illustrative examples, please refer to [reference needed]. Figure 9 , Figure 9 This is a schematic diagram of a memory snapshot-based synchronization process provided in an exemplary embodiment of this application, such as... Figure 9 As shown, in the memory snapshot-based synchronization process 900, it is necessary to synchronize all unused handles, all used handles, the memory in the memory manager, and the offset addresses of objects and free pointers. Specifically, this includes steps such as handle generation, object mapping, snapshot creation, and base address relocation.

[0275] The free handle value stack is used to store unused handle values ​​(a, b, c); the handle generator allocates a handle value (Handle = index) from the free handle value stack and assigns it to the object.

[0276] The `HandleObjectArray` array, used for object mapping, stores the mapping relationship between handles and objects. For example, handle x is mapped to object X, and handle y is mapped to object Y.

[0277] The base address (BaseAddr) is a fixed starting point in memory used to calculate the actual memory address of an object.

[0278] A memory buffer contains the actual objects (object X, object Y, object Z). The location of these objects in memory is determined by adding a base address to a relative virtual address (RVA).

[0279] The RVA table stores the relative virtual addresses from the base address to the object, which are used to locate the specific object in the memory buffer.

[0280] The snapshot creation process involves saving the current memory state. This is typically done to preserve a consistent state before the memory state changes, so that it can be restored or compared later.

[0281] The Handle and Object structures are used to store handle and object information for snapshots. A handle contains an int32 value and a valid code, while an object contains a handle pointing to the snapshot creation function (MakeSnapshot()).

[0282] Regarding protocol synchronization, during memory management, it is necessary to ensure that all handle and object mappings are synchronized. This involves coordination between the handle generator and the array of handle objects.

[0283] For snapshot synchronization, after a snapshot is created, it is necessary to ensure that the information in the snapshot is consistent with the actual state in memory. This involves synchronization between the RVA table and the memory buffer.

[0284] Rebase relocation involves recalculating the object's address based on a new base address. In some cases, it may be necessary to change the base address, and all Relative Object Addresses (RVAs) need to be updated to ensure they still point to the correct object.

[0285] Deduplication checking addresses the issue of duplicate objects or data in memory management. The deduplication process identifies and eliminates these duplicates to save memory.

[0286] In summary, the method provided in this application embodiment restores the first application based on memory information and object information in the memory snapshot, which can help the application quickly and completely and accurately restore the program state based on the memory snapshot in scenarios such as disconnection and reconnection, full state synchronization, and local archiving, thereby improving the state restoration efficiency.

[0287] In some embodiments, the state recovery request can be sent by another device or generated locally; please refer to [reference needed]. Figure 10 This document illustrates a flowchart of a state recovery request acquisition method provided in an exemplary embodiment of this application. This method can be executed by a terminal, a server, or both. This embodiment uses the execution of this method by a first device as an example for illustration. Figure 10 As shown, step 220 above includes the following steps:

[0288] Step 221: Receive the disconnection and reconnection request from the second device.

[0289] The disconnection and reconnection request is used to request the restoration of the communication connection with the first device at the first moment. The disconnection and reconnection request includes a state restoration request, which the first device uses to provide the second device with the state of the program objects in the first application.

[0290] The first device is a device for running the first application logic layer, and the second device is a device for running the first application presentation layer.

[0291] In some embodiments, after the first device obtains a memory snapshot based on the state recovery request in the disconnection and reconnection request, it sends a memory snapshot to the second device based on the disconnection and reconnection request.

[0292] A memory snapshot is used to instruct a second device to restore the object state of a program object to its state at the first moment, based on memory information and object information.

[0293] This is illustrative; please refer to it. Figure 11 , Figure 11 This is a schematic diagram of a disconnection and reconnection scenario in a frame-synchronized game provided by an exemplary embodiment of this application, as shown below. Figure 11 As shown, the first device 1110, acting as the server for the frame-synchronized game, can restore the client memory by sending a memory snapshot to the second device 1120, which acts as the client. Based on the server memory, the game core objects are restored in the client memory, thus enabling reconnection after disconnection.

[0294] The method provided in this application embodiment obtains a state recovery request by receiving a disconnection reconnection request. When the client disconnects or restarts, the server sends a memory snapshot of the first moment to the client. The client logic layer restores to the first moment according to the memory snapshot and then follows the frame to the current frame. This reduces the amount of computation and improves the recovery efficiency compared to directly following the frame through frame synchronization.

[0295] Step 222: Automatically generate a status recovery request.

[0296] Optionally, the state recovery request may be generated periodically by the first device as a server based on synchronization requirements, or it may be generated by the first device as a client based on local archiving requirements. This application embodiment does not limit this.

[0297] Taking the state recovery request as an example, which is generated periodically by the first device as a server based on synchronization requirements, after the first device obtains a memory snapshot based on the state recovery request, it can send the memory snapshot to at least two second devices based on the state recovery request.

[0298] At least two second devices are used to synchronize the state of program objects in the first application based on memory snapshots sent by the first device.

[0299] This is illustrative; please refer to it. Figure 12 , Figure 12 This is a schematic diagram of a full-state synchronization scenario for a small memory system provided in an exemplary embodiment of this application, such as... Figure 12 As shown, the first device 1210 acts as a server and can broadcast memory snapshots to at least two second devices 1220 acting as clients, enabling the at least two second devices 1220 to achieve full state synchronization based on the memory snapshots. For example, the server memory can be synchronized to the memory of client 1 and client 2 respectively, and the game core objects in the server memory can be synchronized to the game core objects in the memory of client 1 and client 2 respectively, thus achieving full state synchronization.

[0300] The method provided in this application embodiment automatically generates a state recovery request based on synchronization requirements and broadcasts a memory snapshot to the client. In a full-state synchronization scenario, this enables each client to fully synchronize the entire memory status of the program based on the memory snapshot, thereby ensuring full-state synchronization and improving synchronization efficiency.

[0301] Taking the state recovery request generated by the first device as a client based on local archiving requirements as an example, after the first device obtains a memory snapshot based on the state recovery request, it can restore the state of the program object in the first application at the first moment based on the memory snapshot on the first device.

[0302] This is illustrative; please refer to it. Figure 13 , Figure 13 This application provides an exemplary embodiment of a local save scenario for a single-player game, as illustrated in the diagram. Figure 13 As shown, the first device 1310 can save local single-player games. For example, it can save the game by generating a memory snapshot based on the client's memory and the game's core objects at the first moment and storing it in a local file. When restoring the save, it can read the memory snapshot from the local file and restore the game's core objects in the client's memory.

[0303] The method provided in this application automatically generates a state recovery request based on local archiving requirements and obtains a memory snapshot from the local machine to restore the state. This simplifies the archiving and recovery logic and improves recovery efficiency by directly archiving the entire block of logical memory.

[0304] In summary, the method provided in this application, by receiving disconnection reconnection requests or automatically generating state recovery requests, can adapt to various state recovery application scenarios and improve the flexibility of restoring program state based on memory snapshots.

[0305] Figure 14 This is a structural block diagram of a state recovery device provided in an exemplary embodiment of this application, as shown below. Figure 14 As shown, the device includes the following parts:

[0306] The generation module 1410 is used to generate a memory snapshot of a program object in the first application at a first moment during the operation of the first application. The memory snapshot includes memory information and object information corresponding to the program object. The memory information is used to indicate the memory data occupied by the program object and the memory structure used by the memory manager. The object information is used to indicate the running logic of the program object.

[0307] The receiving module 1420 is used to receive a state recovery request, wherein the state recovery request is used to request the restoration of the object state of the program object to the state it was in at the first moment;

[0308] The acquisition module 1430 is used to acquire the memory snapshot based on the state recovery request. The memory snapshot is used to indicate that the object state of the program object is restored to the state it was in at the first moment according to the memory information and the object information.

[0309] Please refer to Figure 15 , Figure 15 This is a structural block diagram of a state recovery device module provided in an exemplary embodiment of this application, as shown below. Figure 15 As shown, in some embodiments, the generation module 1410 includes:

[0310] The first acquisition unit 1411 is used to obtain the memory information based on the memory data corresponding to the program object in the first application at the first moment and the memory structure used by the memory manager;

[0311] The second acquisition unit 1412 is used to obtain the object information based on the state of the program object in the first application and the mapping relationship between the program object and the handle, wherein the handle is an index in memory used to uniquely identify the program object;

[0312] The snapshot generation unit 1413 is used to generate the memory snapshot based on the memory information and the object information.

[0313] In some embodiments, the first acquisition unit 1411 is further configured to:

[0314] At the first moment, the memory allocation status is obtained from the memory manager corresponding to the program object in the first application. The memory allocation status is used to indicate the free list and at least one first memory block that has been allocated for the program object in the first application at the first moment. The free list is used to indicate the memory blocks that are not used by the program object in the first application at the first moment.

[0315] Based on the memory allocation status, obtain the memory block information corresponding to each of the at least one first memory block;

[0316] The memory allocation status and the memory block information are used as the memory information.

[0317] In some embodiments, the second acquisition unit 1412 is further configured to:

[0318] Iterate through the program objects involved in the first application;

[0319] Obtain the handle, type information, and status information corresponding to the program object. The type information is used to indicate the virtual table address and base address corresponding to the program object. The status information is used to indicate the attributes and pointers of the program object. The virtual table address is used to indicate the memory address of the program object relative to the base address. The base address is used to indicate the memory block corresponding to the program object.

[0320] Determine the mapping relationship between the program object and the handle;

[0321] The mapping relationship, the type information, and the status information are used as the object information.

[0322] In some embodiments, the generation module 1410 is further configured to:

[0323] A memory snapshot corresponding to the program object in the first application is generated in real time, where the first moment is the current moment corresponding to the first application; or...

[0324] Memory snapshots corresponding to the program objects in the first application are generated at preset time intervals, where the first moment is a moment determined based on the preset time interval; or...

[0325] In response to receiving a snapshot generation request, a memory snapshot corresponding to the program object in the first application is generated, wherein the first moment is the moment specified based on the snapshot generation request.

[0326] In some embodiments, the memory snapshot is generated by a first device; the apparatus further includes a processing module 1440.

[0327] The receiving module 1420 is further configured to receive a disconnection and reconnection request from the second device. The disconnection and reconnection request is used to request the restoration of the communication connection with the first device at the first moment. The disconnection and reconnection request includes the state restoration request. The first device is used to provide the second device with the state of the program object in the first application.

[0328] The processing module 1440 is used to send the memory snapshot to the second device based on the disconnection and reconnection request. The memory snapshot is used to instruct the second device to restore the object state of the program object to the state it was in at the first moment according to the memory information and the object information.

[0329] In some embodiments, the memory snapshot is generated by a first device;

[0330] The receiving module 1420 is also used to automatically generate the state recovery request;

[0331] The processing module 1440 is further configured to send the memory snapshot to at least two second devices based on the state recovery request, wherein the at least two second devices are configured to synchronize the state of program objects in the first application based on the memory snapshot sent by the first device; or,

[0332] Based on the state recovery request, the program object in the first application is restored locally on the first device based on the memory snapshot to the state it was in at the first moment.

[0333] In some embodiments, the processing module 1440 is further configured to restore the object state of the program object to the state it was in at the first moment according to the memory information and the object information in the memory snapshot.

[0334] In some embodiments, the processing module 1440 includes:

[0335] The memory recovery unit 1441 is used to allocate memory blocks in the memory manager according to the memory allocation status in the memory snapshot, rebuild the memory structure occupied by the program object, and restore the memory data.

[0336] The object recovery unit 1442 is used to recover the program object corresponding to the handle according to the mapping relationship between the handle and the program object in the memory snapshot.

[0337] In some embodiments, the object recovery unit 1442 is further configured to:

[0338] Restore the unused handles of the program objects in the first application according to the memory snapshot;

[0339] Restore the handle used by the program object in the first application according to the memory snapshot;

[0340] Obtain the object information corresponding to the program object that matches the mapping relationship based on the handle used by the program object;

[0341] The program object's memory address relative to its base address is recovered based on the type information in the object information, and the corresponding attributes and pointers of the program object are recovered based on the state information in the object information.

[0342] In summary, the apparatus provided in this application, by using a memory snapshot corresponding to the program object to archive the memory structure occupied by the program object and the running logic of the program object, can completely restore the memory structure and the state of the program object when restoring the program object in the application. Since the memory structure can indicate the layout of the program object in memory and the reference relationship between them, restoring the memory structure can maintain data integrity, maintain object references, improve the accuracy of state restoration, and help the application continue execution from the point of interruption. Moreover, the state of the program objects involved in the application can be restored at once based on the memory snapshot, without having to restore the state of each object separately, thus improving the state restoration efficiency.

[0343] It should be noted that the state recovery device provided in the above embodiments is only an example of the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0344] Figure 16 This illustration shows a structural block diagram of a terminal 1600 provided in an exemplary embodiment of this application. The terminal 1600 may be a smartphone, tablet computer, MP3 player, MP4 player, laptop computer, or desktop computer. The terminal 1600 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.

[0345] Typically, terminal 1600 includes a processor 1601 and a memory 1602.

[0346] Processor 1601 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1601 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). Processor 1601 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1601 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1601 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.

[0347] The memory 1602 may include one or more computer-readable storage media, which may be non-transitory. The memory 1602 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 some embodiments, the non-transitory computer-readable storage media in the memory 1602 is used to store at least one instruction, which is executed by the processor 1601 to implement the state recovery method provided in the method embodiments of this application.

[0348] In some embodiments, the terminal 1600 also includes other components 1603, the type and number of which can be selected based on the functional needs of the terminal 1600. Those skilled in the art will understand that... Figure 16 The structure shown does not constitute a limitation on terminal 1600 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0349] Embodiments of this application also provide a computer device that can be implemented as follows: Figure 1 The terminal or server shown. The computer device includes a processor and a memory, the memory storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor to implement the state recovery method provided in the above-described method embodiments.

[0350] Embodiments of this application also provide a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the state recovery method provided in the above-described method embodiments.

[0351] Embodiments of this application also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the state recovery method provided in the above-described method embodiments.

[0352] Optionally, the computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), solid-state drives (SSDs), or optical discs, etc. The random access memory may include resistive random access memory (ReRAM) and dynamic random access memory (DRAM). The sequence numbers of the embodiments in this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0353] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0354] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.< / t>

Claims

1. A state recovery method, characterized in that, The method includes: During the execution of the first application, a memory snapshot corresponding to the program object in the first application at a first moment is generated. The memory snapshot includes memory information and object information corresponding to the program object. The memory information is used to indicate the memory data occupied by the program object and the memory structure used by the memory manager. The object information is used to indicate the execution logic of the program object. Receive a state recovery request, the state recovery request being used to request the restoration of the object state of the program object to the state it was in at the first moment; The memory snapshot is obtained based on the state recovery request. The memory snapshot is used to indicate that the object state of the program object is restored to the state it was in at the first moment according to the memory information and the object information.

2. The method according to claim 1, characterized in that, During the execution of the first application, generating a memory snapshot of the program objects in the first application at a first moment includes: The memory information is obtained based on the memory data corresponding to the program object in the first application at the first moment and the memory structure used by the memory manager; Based on the state of the program object in the first application and the mapping relationship between the program object and the handle, the object information is obtained, and the handle is an index in memory used to uniquely identify the program object; The memory snapshot is generated based on the memory information and the object information.

3. The method according to claim 2, characterized in that, The memory information is obtained based on the memory data corresponding to the program object in the first application at the first moment and the memory structure used by the memory manager, including: At the first moment, a memory allocation status is obtained from the memory manager corresponding to the program object in the first application. The memory allocation status is used to indicate a free list and at least one first memory block that has been allocated for the program object in the first application at the first moment. The free list is used to indicate memory blocks that are not used by the program object in the first application at the first moment. Based on the memory allocation status, obtain the memory block information corresponding to each of the at least one first memory block; The memory allocation status and the memory block information are used as the memory information.

4. The method according to claim 2, characterized in that, The process of obtaining the object information based on the state of the program object in the first application and the mapping relationship between the program object and the handle includes: Iterate through the program objects involved in the first application; Obtain the handle, type information, and status information corresponding to the program object. The type information is used to indicate the virtual table address and base address corresponding to the program object. The status information is used to indicate the attributes and pointers of the program object. The virtual table address is used to indicate the memory address of the program object relative to the base address. The base address is used to indicate the memory block corresponding to the program object. Determine the mapping relationship between the program object and the handle; The mapping relationship, the type information, and the status information are used as the object information.

5. The method according to any one of claims 1 to 4, characterized in that, Generating a memory snapshot of the program object in the first application at a first moment includes: A memory snapshot corresponding to the program object in the first application is generated in real time, where the first moment is the current moment corresponding to the first application; or... Memory snapshots corresponding to the program objects in the first application are generated at preset time intervals, where the first moment is a moment determined based on the preset time interval; or... In response to receiving a snapshot generation request, a memory snapshot corresponding to the program object in the first application is generated, wherein the first moment is the moment specified based on the snapshot generation request.

6. The method according to any one of claims 1 to 4, characterized in that, The method is performed by the first device; The received state recovery request includes: The system receives a disconnection and reconnection request from a second device. The disconnection and reconnection request is used to request the restoration of the communication connection with the first device at the first moment. The disconnection and reconnection request includes the state restoration request. The first device is used to provide the second device with the state of the program object in the first application. The method further includes: Based on the disconnection and reconnection request, the memory snapshot is sent to the second device. The memory snapshot is used to instruct the second device to restore the object state of the program object to the state it was in at the first moment according to the memory information and the object information.

7. The method according to any one of claims 1 to 4, characterized in that, The method is performed by the first device; The received state recovery request includes: The state recovery request is generated automatically; The method further includes: Based on the state recovery request, the memory snapshot is sent to at least two second devices, wherein the at least two second devices are used to synchronize the state of program objects in the first application based on the memory snapshot sent by the first device; or... Based on the state recovery request, the program object in the first application is restored locally on the first device based on the memory snapshot to the state it was in at the first moment.

8. The method according to any one of claims 1 to 4, characterized in that, The method further includes: The object state of the program object is restored to the state it was in at the first moment according to the memory information and object information in the memory snapshot.

9. The method according to claim 8, characterized in that, The step of restoring the object state of the program object to its state at the first moment according to the memory information and object information in the memory snapshot includes: Based on the memory allocation status in the memory snapshot, memory blocks are allocated in the memory manager, the memory structure occupied by the program object is reconstructed, and the memory data is restored; Based on the mapping relationship between handles and program objects in the memory snapshot, restore the program object corresponding to the handle.

10. The method according to claim 9, characterized in that, The step of restoring the program object corresponding to the handle based on the mapping relationship between the handle and the program object in the memory snapshot includes: Restore the unused handles of the program objects in the first application according to the memory snapshot; Restore the handle used by the program object in the first application according to the memory snapshot; Obtain the object information corresponding to the program object that matches the mapping relationship based on the handle used by the program object; The program object's memory address relative to its base address is recovered based on the type information in the object information, and the corresponding attributes and pointers of the program object are recovered based on the state information in the object information.

11. A state recovery device, characterized in that, The device includes: The generation module is used to generate a memory snapshot of a program object in the first application at a first moment during the execution of the first application. The memory snapshot includes memory information and object information corresponding to the program object. The memory information is used to indicate the memory structure occupied by the program object, and the object information is used to indicate the execution logic of the program object. The receiving module is used to receive a state recovery request, wherein the state recovery request is used to request the restoration of the object state of the program object to the state it was in at the first moment; The acquisition module is used to acquire the memory snapshot based on the state recovery request. The memory snapshot is used to indicate that the object state of the program object is restored to the state it was in at the first moment according to the memory information and the object information.

12. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement the state recovery method as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The storage medium stores at least one computer program, which is loaded and executed by a processor to implement the state recovery method as described in any one of claims 1 to 10.

14. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the state recovery method as described in any one of claims 1 to 10.