An object processing method, apparatus, electronic device, and storage medium

By binding the pointer addresses of associated data objects during the interaction between the application layer and the native layer, the complexity of native data object release management and memory leak issues are resolved, achieving automated memory management and timely release.

CN122346338APending Publication Date: 2026-07-07TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2025-01-06
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

During the interaction between the application layer and the native layer, the release and management of native data objects is complex and poses a risk of memory leaks. Developers need to manually release the logic, which is inconvenient and may lead to potential leaks.

Method used

By creating an associated data object at the application layer and binding the pointer address of the native data object, and automatically releasing the native data object when the application data object is released, the release operation is detected by the bridging layer.

Benefits of technology

It simplifies the process of releasing native data objects, avoids memory leaks, and improves the automation and reliability of memory management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122346338A_ABST
    Figure CN122346338A_ABST
Patent Text Reader

Abstract

The application relates to the computer technical field, in particular to an object processing method and device, electronic equipment and storage medium. The method comprises the following steps: when a native layer processes a data processing request of an application layer, encapsulating a data processing result into a native data object, and transmitting the data processing result and a pointer address of the native data object to the application layer; the application layer encapsulates the data processing result through an application data object created by the application layer, encapsulates the pointer address of the native data object through an associated data object created by a bridge layer, and binds the life cycle of the associated data object with the life cycle of the application data object; when the bridge layer detects that the application data object is released, it is determined that the life cycle of the application data object and the associated data object ends, and the native data object is obtained based on the pointer address in the associated data object and is released. The application simplifies the release process of the native data object, timely releases the native data object, and avoids memory leakage.
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 more particularly to an object processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] In application development, compiled languages ​​such as C and C++ are typically used to write the business logic of the native layer (also known as the lower layer), while high-level programming languages ​​(such as Java and JavaScript) are used to write the business logic of the application layer (also known as the upper layer or user interface layer). The native layer is used to interact with the operating system kernel and hardware devices (such as processors, memory, disks, network interfaces, etc.), while the application layer is used to build the user interface and interact with the application's users.

[0003] In related technologies, the application layer can send data processing requests to the native layer through a specific data channel. When the native layer processes the data processing request from the application layer, it usually constructs a native data object to encapsulate the corresponding data processing result and transmits the data processing result to the application layer through the aforementioned specific data channel. The application layer also creates an application data object for the data processing result so that the data processing result can be presented in the user interface by calling the application data object.

[0004] Native data objects created by the native layer are held by the native layer itself, which manages their lifecycle. The lifecycle of a native data object typically depends on the lifecycle of the application data objects mentioned above; that is, when the application data objects' lifecycle ends, the native data objects' lifecycle should also end. Because the application layer is written in a high-level programming language, it has an automatic garbage collection mechanism, automatically identifying and releasing application data objects that are no longer in use. The native layer, however, does not have an automatic garbage collection mechanism, requiring developers to manually add the corresponding native data object release logic when the application layer releases application data objects.

[0005] However, the application layer and the native layer will have a lot of data interaction. Developers need to manually add the corresponding native data object release logic every time data interaction occurs. This obviously brings great inconvenience to developers, making the release process of native data objects more complicated and unable to guarantee that native data objects can be released in a timely manner every time, which poses a risk of memory leaks. Summary of the Invention

[0006] This application provides an object processing method, apparatus, electronic device, and storage medium to simplify the release process of native data objects and release them in a timely manner to avoid memory leaks.

[0007] On the one hand, an object processing method is provided in an embodiment of this application, the method comprising:

[0008] When the native layer receives a data processing request from the application layer, it processes the data processing request, encapsulates the obtained data processing result into a created native data object, and transmits the data processing result and the pointer address of the native data object to the application layer.

[0009] The application layer encapsulates the data processing results through the created application data object, executes corresponding business logic based on the data processing results, and encapsulates the pointer address of the native data object through the associated data object created by the bridging layer provided by the operating system, and binds the lifecycle of the associated data object to the lifecycle of the application data object;

[0010] During the execution of the business logic in the application layer, when the bridging layer detects that the application data object has been released, it determines that the lifecycle of the application data object and the associated data object has ended, obtains the native data object based on the pointer address of the native data object in the associated data object, and performs a release operation on the native data object.

[0011] In some optional implementations, the associated data object created through the bridging layer provided by the operating system encapsulates the pointer address of the native data object and binds the lifecycle of the associated data object to the lifecycle of the application data object, including:

[0012] The application layer sends an object creation request containing the pointer address of the native data object to the bridge layer;

[0013] The bridging layer creates the associated data object based on the object creation request, encapsulates the pointer address of the original data object into the pointer address of the original data object, and returns the associated data object to the application layer;

[0014] The application layer uses the associated data object as an application variable of the application data object and saves the application variable into the application data object to bind the lifecycle of the associated data object to the lifecycle of the application data object.

[0015] In some optional implementations, the bridging layer creates the associated data object based on the object creation request, including:

[0016] The bridging layer obtains the associated class for binding the native layer and the application layer based on the object creation request;

[0017] The bridging layer takes the pointer address of the native data object as a constructor parameter and passes the constructor parameter to the constructor method of the associated class to create the associated data object based on the constructor method.

[0018] In some optional implementations, the method further includes:

[0019] The bridging layer creates a destruction callback method, saves the created associated data object into the destruction callback method, and registers the destruction callback method with the operating system. The destruction callback method is invoked when the application data object is released.

[0020] During the execution of the business logic in the application layer, when the bridging layer detects that the application data object has been released, it determines that the lifecycle of the application data object and the associated data object has ended, including:

[0021] During the execution of the business logic in the application layer, when the destruction callback method is called by the operating system, the bridge layer determines that the application data object is released and that the lifecycle of the application data object and the associated data object has ended.

[0022] In some optional implementations, obtaining the native data object based on the pointer address of the native data object in the associated data object and performing a release operation on the native data object includes:

[0023] When the operating system calls the destructor callback method, the bridge layer obtains the associated data object from the destructor callback method, obtains the pointer address of the native data object from the associated data object, obtains the native data object based on the pointer address of the native data object, and performs a release operation on the native data object.

[0024] In some optional implementations, the method further includes:

[0025] The application layer sends the data processing request to the bridging layer through the first data interface. After receiving the data processing request, the bridging layer transmits the data processing request to the native layer through the second data interface.

[0026] The data processing result and the pointer address of the original data object are then transmitted to the application layer through the bridging layer provided by the operating system, including:

[0027] The native layer sends a data packet containing the data processing result and the pointer address of the native data object to the bridge layer through the second data interface;

[0028] After receiving the data packet, the bridging layer transmits the data packet to the application layer through the first data interface.

[0029] In some optional implementations, the method further includes:

[0030] When the native layer determines that the data processing result has changed, it replaces the data processing result stored in the native data object with the changed data processing result and transmits the changed data processing result to the application layer.

[0031] The application layer executes corresponding business logic based on the updated data processing results.

[0032] On one hand, an object processing apparatus is provided in an embodiment of this application, the apparatus comprising:

[0033] The transmission module is used to process the data processing request when the native layer receives the data processing request from the application layer, encapsulate the obtained data processing result into a created native data object, and transmit the data processing result and the pointer address of the native data object to the application layer.

[0034] The processing module is used by the application layer to encapsulate the data processing result through the created application data object, execute the corresponding business logic according to the data processing result, and encapsulate the pointer address of the native data object through the associated data object created by the bridging layer provided by the operating system, and bind the life cycle of the associated data object to the life cycle of the application data object.

[0035] The release module is used to determine the end of the lifecycle of the application data object and the associated data object when the bridge layer detects that the application data object has been released during the execution of the business logic in the application layer. It then retrieves the native data object based on the pointer address of the native data object in the associated data object and performs a release operation on the native data object.

[0036] In some optional implementations, when the associated data object created through the bridging layer provided by the operating system encapsulates the pointer address of the native data object and binds the lifecycle of the associated data object to the lifecycle of the application data object, the processing module is specifically used for:

[0037] The application layer sends an object creation request containing the pointer address of the native data object to the bridge layer provided by the operating system.

[0038] The bridging layer creates the associated data object based on the object creation request, encapsulates the pointer address of the original data object into the pointer address of the original data object, and returns the associated data object to the application layer;

[0039] The application layer uses the associated data object as an application variable of the application data object and saves the application variable into the application data object to bind the lifecycle of the associated data object to the lifecycle of the application data object.

[0040] In some optional implementations, when the bridging layer creates the associated data object based on the object creation request, the processing module is specifically used for:

[0041] The bridging layer obtains the associated class for binding the native layer and the application layer based on the object creation request;

[0042] The bridging layer takes the pointer address of the native data object as a constructor parameter and passes the constructor parameter to the constructor method of the associated class to create the associated data object based on the constructor method.

[0043] In some alternative embodiments, the apparatus further includes:

[0044] The registration module is used by the bridging layer to create a destruction callback method, save the created associated data object to the destruction callback method, and register the destruction callback method with the operating system. The destruction callback method is called when the application data object is released.

[0045] During the execution of the business logic in the application layer, when the bridging layer detects that the application data object has been released, it determines that the lifecycle of the application data object and the associated data object has ended. The release module is specifically used for:

[0046] During the execution of the business logic in the application layer, when the destruction callback method is called by the operating system, the bridge layer determines that the application data object is released and that the lifecycle of the application data object and the associated data object has ended.

[0047] In some optional implementations, when the native data object is obtained based on the pointer address of the native data object in the associated data object, and a release operation is performed on the native data object, the release module is specifically used for:

[0048] When the operating system calls the destructor callback method, the bridge layer obtains the associated data object from the destructor callback method, obtains the pointer address of the native data object from the associated data object, obtains the native data object based on the pointer address of the native data object, and performs a release operation on the native data object.

[0049] In some optional implementations, the transmission module is further configured to:

[0050] The application layer sends the data processing request to the bridging layer through the first data interface. After receiving the data processing request, the bridging layer transmits the data processing request to the native layer through the second data interface.

[0051] When transmitting the data processing result and the pointer address of the original data object to the application layer, the transmission module is specifically used for:

[0052] The native layer sends a data packet containing the data processing result and the pointer address of the native data object to the bridge layer through the second data interface;

[0053] After receiving the data packet, the bridging layer transmits the data packet to the application layer through the first data interface.

[0054] In some alternative embodiments, the apparatus further includes:

[0055] The replacement module is used to replace the data processing result stored in the original data object with the changed data processing result when the original layer determines that the data processing result has changed, and to transmit the changed data processing result to the application layer.

[0056] The processing module is also used for: the application layer to execute corresponding business logic based on the updated data processing result.

[0057] On one hand, an electronic device provided in this application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the object processing method described in the first aspect, including:

[0058] When the processor receives a data processing request from the application layer at the native layer, it processes the data processing request, encapsulates the obtained data processing result into a created native data object, and transmits the data processing result and the pointer address of the native data object to the application layer.

[0059] At the application layer, the processor encapsulates the data processing result through an application data object and executes corresponding business logic based on the data processing result. It also creates an associated data object through a bridging layer provided by the operating system, encapsulates the pointer address of the native data object, and binds the lifecycle of the associated data object to the lifecycle of the application data object. During the execution of the business logic at the application layer, when the bridging layer detects that the application data object has been released, it determines that the lifecycles of the application data object and the associated data object have ended. Based on the pointer address of the native data object in the associated data object, it retrieves the native data object and performs a release operation on it.

[0060] On one hand, embodiments of this application provide a computer-readable storage medium including a computer program that, when run on an electronic device, causes the electronic device to perform the steps of the object processing method described in the first aspect.

[0061] On one hand, embodiments of this application provide a computer program product, the computer program product including a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of the object processing method described in the first aspect.

[0062] The solution proposed in this application has at least the following beneficial effects:

[0063] In this embodiment, when the native layer processes the data processing request from the application layer, it creates a native data object to encapsulate the data processing result. To facilitate the subsequent release of the native data object, the native layer transmits the pointer address of the native data object to the application layer while transmitting the data processing result. The application layer encapsulates the data processing result through the created application data object. At the same time, it encapsulates the pointer address of the native data object through the associated data object created by the bridging layer, and binds the lifecycle of the associated data object to the lifecycle of the application data object. That is, when the lifecycle of the application data object ends, the lifecycle of the associated data object also ends.

[0064] In this way, by binding the application data object created by the application layer with the associated data object that holds the pointer address of the native data object, it is equivalent to forming a weak association between the application data object and the native data object through the associated data object. When the bridging layer detects that the application data object has been released, it determines that the associated native data object can be released, and then obtains the pointer address of the native data object from the associated data object. Based on the pointer address, the native data object is retrieved, and the release operation of the native data object is automatically performed. Developers do not need to manually add the release logic of the native data object every time it is created, which simplifies the release process of the native data object. Furthermore, due to the timely release of the native data object, memory leaks are avoided.

[0065] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0066] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0067] Figure 1 This is a schematic diagram illustrating an application scenario of an object processing method in an embodiment of this application;

[0068] Figure 2 This is a flowchart of an object processing method in an embodiment of this application;

[0069] Figure 3 This is a schematic diagram illustrating the transmission process of a data processing request in an embodiment of this application;

[0070] Figure 4 This is a schematic diagram of a data packet transmission process in an embodiment of this application;

[0071] Figure 5 This is a schematic diagram illustrating the creation process of an associated data object in an embodiment of this application;

[0072] Figure 6 This is a schematic diagram of a data object binding in an embodiment of this application;

[0073] Figure 7 This is a schematic diagram of the callback process of a destructor callback method in an embodiment of this application;

[0074] Figure 8 This is a schematic diagram of the overall process of an object processing method in an embodiment of this application;

[0075] Figure 9 This is a logical schematic diagram of an object processing method in an embodiment of this application;

[0076] Figure 10 This is a logical schematic diagram of another object processing method in the embodiments of this application;

[0077] Figure 11 This is a schematic diagram of the composition structure of an object processing device according to an embodiment of this application;

[0078] Figure 12 This is a schematic diagram of the composition structure of another object processing device in an embodiment of this application;

[0079] Figure 13 This is a schematic diagram of the composition structure of an electronic device according to an embodiment of this application;

[0080] Figure 14 This is a schematic diagram of the composition structure of another electronic device using an embodiment of this application. Detailed Implementation

[0081] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.

[0082] The following describes some of the concepts involved in the embodiments of this application.

[0083] Native layer: This is the bottom layer of the application, also known as the native layer. It is usually the low-level business logic layer written in low-level programming languages ​​such as C and C++. For example, the native layer can interact with the operating system's Application Programming Interface (API), including but not limited to file system access, network communication, and hardware device control. It can also perform tasks such as data verification, transformation, persistent storage, encryption, and decryption.

[0084] Application Layer: This is the layer above the application, also known as the user interface layer. It is typically written in high-level programming languages ​​such as Java and JavaScript, serving as the upper-level business logic layer. For example, the application layer presents information to users in an intuitive way, such as text, images, and charts, and captures user interactions, such as clicking buttons, entering text, and swiping the screen. It can also manage page navigation and transitions.

[0085] Bridge Layer: Provided by the operating system, this layer acts as an interface bridge between the application layer and the native layer. For example, in HarmonyOS, the bridge layer is the Native Ability Programming Interface (NAPI) layer, which defines the interaction methods between the application layer and the native layer.

[0086] A data object is a structured unit representing data stored and manipulated in a program. It typically encapsulates a set of related attributes (data fields) and operations (methods) that can be performed on these attributes. Specifically, in object-oriented programming languages ​​(such as C++ and Java), a data object is usually an instance of a class. Each data object contains not only data members (attributes) but also member functions (methods) used to manipulate this data. Dynamic programming languages ​​(such as JavaScript) support object-oriented programming, allowing for highly flexible creation and modification of data objects, and allowing the addition or deletion of attributes at runtime. In procedural programming languages ​​(such as C), a data object refers to an entity used to store data in a program. The data objects involved in the embodiments of this application include native data objects, application data objects, and associated data objects, etc.

[0087] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.

[0088] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0089] The design concept of the embodiments of this application will be introduced below.

[0090] In related technologies, during the data interaction between the application layer and the native layer of an application, the native layer usually constructs native data objects, and the application layer also creates corresponding application data objects. Since the application layer is written in a high-level programming language, it has an automatic garbage collection mechanism, that is, it automatically identifies and releases application data objects that are no longer in use. However, the native layer does not have an automatic garbage collection mechanism. Thus, there is a problem of lifecycle management of native data objects.

[0091] Because the native layer and the application layer can only exchange basic data types (such as integers, floating-point numbers, and characters), and cannot exchange custom data objects (such as the aforementioned native data objects and application data objects), native data objects created by the native layer can only be held by the native layer itself, which manages their lifecycle. It should be noted that the reason why the native layer and the application layer cannot exchange data objects is that the native layer and the application layer run in different environments and have different memory management mechanisms. This makes the memory layout of native data objects and application data objects potentially inconsistent. This layout refers to the way data objects are stored in memory, including the size of the data object, alignment, and the order of member variables. Directly exchanging data objects can lead to data corruption or unresolved data.

[0092] If the native layer fails to release native data objects when their lifecycle ends, it can lead to memory leaks. Releasing native data objects requires accurate awareness of their lifecycle and timely release. However, the native layer is unsure when to release native data objects; only the application layer knows the exact timeframe. For example, in a web application, user actions (such as clicking a button or closing a window) trigger a series of events that may create native data objects. The native layer typically lacks sufficient contextual information to determine when to release these objects. For instance, it might not know when a user closed a window or canceled an action, while only the application layer knows the specific action performed.

[0093] Currently, developers typically need to manually add the release logic for the corresponding native data objects when releasing application data objects at the application layer. This means developers must manually add the release logic for the native data objects every time there is data interaction between the application layer and the native layer. This obviously causes significant inconvenience for developers, making the release process of native data objects quite complex and unable to guarantee timely release every time, thus posing a risk of memory leaks.

[0094] In view of this, embodiments of this application provide an object processing method, apparatus, electronic device, and storage medium. When the native layer processes data processing requests from the application layer, it creates a native data object to encapsulate the data processing result and transmits the data processing result and the pointer address of the native data object together to the application layer. The application layer encapsulates the data processing result through the created application data object. At the same time, it encapsulates the pointer address of the native data object through an associated data object created by the bridging layer and binds the lifecycle of the associated data object to the lifecycle of the application data object. In this way, by binding the application data object created by the application layer with the associated data object holding the pointer address of the native data object, a weak association between the application data object and the native data object is achieved. Thus, when it is determined that the application data object is to be released, the native data object is obtained based on the pointer address of the native data object, and the release operation of the native data object is automatically performed. Developers do not need to manually supplement the release logic of the native data object every time it is created, simplifying the release process of the native data object and releasing the native data object in a timely manner, thus avoiding memory leaks.

[0095] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0096] like Figure 1 The diagram illustrates an application scenario of an embodiment of this application. The application scenario diagram includes a development device 110, a server 120, and a terminal device 130. The development device 110 and the server 120 can communicate directly or indirectly via a communication network, and the terminal device 130 and the server 120 can also communicate directly or indirectly via a communication network. The communication network can be a wired network or a wireless network; this embodiment of the application does not impose specific limitations.

[0097] In this embodiment, the development device 110 can be a device for developers to develop applications, including but not limited to laptops and desktop computers; the terminal device 130 can be a device used by users, including but not limited to mobile phones, tablets, laptops, desktop computers, e-book readers, smart voice interaction devices, smart home appliances, and in-vehicle terminals. The terminal device can have applications developed by developers installed, which can be various types of software (e.g., instant messaging software, browsers, video software, shopping software, music software, etc.); the server 120 can be a backend server corresponding to the application, specifically an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, 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.

[0098] When developers use development device 110 to develop applications for a specific operating system (such as HarmonyOS, Android, etc.), they typically use low-level programming languages ​​(such as C, C++, etc.) to write the native layer business logic, and high-level programming languages ​​(such as Java, JavaScript, etc.) to write the application layer business logic. After completing the application development, developers can package the application into a specific format installation package and upload it to the server 120 of an app store or application distribution platform. The terminal device 130 can download the installation package from server 120 to install the application.

[0099] During the execution of the application, the terminal device 130 can perform the object processing methods of the various embodiments of this application. Specifically, when the native layer of the application processes the data processing request of the application layer, it creates a native data object to encapsulate the data processing result and transmits the data processing result and the pointer address of the native data object to the application layer. The application layer encapsulates the data processing result through the application data object created by the bridging layer, executes the corresponding business logic according to the data processing result, and encapsulates the pointer address of the native data object through the created associated data object. By binding the application data object with the associated data object, a weak association between the application data object and the native data object is realized. Thus, when the application data object is detected to be released, the native data object is obtained based on the pointer address of the native data object, and the release operation of the native data object is automatically performed.

[0100] It should be noted that, Figure 1The examples shown are merely illustrative; in reality, the number of development devices, terminal devices, and servers is unlimited and is not specifically limited in the embodiments of this application.

[0101] The object processing method provided by the exemplary embodiments of this application will be described below with reference to the accompanying drawings and the application scenarios described above. It should be noted that the application scenarios described above are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way in this respect.

[0102] See Figure 2 The diagram shown is an implementation flowchart of an object processing method provided in this application embodiment. Taking a terminal device as the execution subject, the specific implementation flow of this method includes the following S21-S23:

[0103] S21. When the native layer receives a data processing request from the application layer, it processes the data processing request, encapsulates the obtained data processing result into the created native data object, and transmits the data processing result and the pointer address of the native data object to the application layer.

[0104] In this embodiment, the native layer and the application layer are different logical layers of the application, each undertaking different functions and responsibilities. The native layer typically refers to a logical layer written in compiled languages ​​such as C or C++. It can directly interact with the operating system (e.g., HarmonyOS, Android OS), providing high-performance computing capabilities and system-level operations; for example, handling performance-critical tasks, including but not limited to data acquisition, data processing, image processing, audio / video encoding / decoding, complex algorithms, etc., and directly accessing hardware resources such as file systems, network interfaces, and sensors. The application layer typically refers to a logical layer written in interpreted languages ​​such as Java or JavaScript. It is mainly used to build the user interface (UI) and handle user interactions, such as handling user input events (e.g., clicks, swipes, etc.).

[0105] During application runtime, data communication is required between the native layer and the application layer to implement the application's functionalities. Specifically, the native and application layers typically use different programming languages ​​and cannot communicate directly; therefore, they need to be bridged by a layer provided by the operating system. For example, the HarmonyOS provides the NAPI layer for mutual calls between the native and application layers, which acts as a bridge. Similarly, the Android OS provides the Java Native Interface (JNI) layer for mutual calls between the native and application layers; the JNI layer also acts as a bridge, allowing interoperability between Java and code written in other programming languages ​​(such as C, C++, etc.).

[0106] In step S21 above, the application layer can initiate data processing requests to the native layer through the bridging layer. For example, the data processing request can be used to acquire, save, or process data. After receiving the data processing request through the bridging layer, the native layer performs the corresponding data processing, such as acquiring, saving, or performing some kind of processing on the data. For instance, in an instant messaging application, the data processing request sent by the application layer is used to acquire friend information, and the native layer acquires the corresponding friend information from the operating system's file system.

[0107] In some alternative implementations, such as Figure 3 As shown, the application layer can send data processing requests to the bridging layer provided by the operating system through the first data interface. After receiving the data processing request, the bridging layer will pass the data processing request to the native layer through the second data interface.

[0108] The bridging layer provides a first data interface to the application layer, allowing the application layer to initiate data processing requests. The native layer provides a second data interface to the bridging layer, which in turn transmits data processing requests to the native layer. In other words, the bridging layer does not process the data processing requests but transmits them directly to the native layer. It's important to note that the first data interface, in the software architecture design, is a specific interface connecting the application layer and the bridging layer, specifying how to pass request parameters and return the required response. Similarly, the second data interface, also in the software architecture design, connects the native layer and the bridging layer, specifying how to pass request parameters and return the required response.

[0109] Furthermore, the native layer processes the data processing request, obtains the data processing result, and encapsulates the data processing result through the created native data object. Taking the native layer as an example of using an object-oriented coding language (such as C++), the native data object usually includes attributes (or member variables) and methods. Encapsulation means assigning the data processing result to the attributes of the native data object, and the data processing result can be manipulated through the methods that operate on the data.

[0110] Specifically, encapsulating data processing results within native data objects makes manipulating those results much easier. For example, if the data processing result includes a set of user information (such as name, age, address, etc.), this user information can be encapsulated in a `person` object. A native data object is an instance of its native class. The native layer can call the native class to create the corresponding native data object. Specifically, the properties of the created native data object are initialized through the constructor of the native class, using the data processing result as a constructor parameter to assign initial values ​​to the properties. The properties of a native data object are data items associated with the object; they can be of various data types, including numbers, strings, and other objects.

[0111] For example, assuming the native class is Person, its constructor parameters include: name parameter, age parameter, and address parameter. When a person object (i.e., the native data object) is created, the person's name, age, and address (i.e., the data processing result) are passed to the constructor. The constructor assigns the person's name, age, and address to the person object's name, age, and address properties.

[0112] After creating a native data object, the native layer can obtain the pointer address of the native data object. This pointer address is the address of the native data object in the memory block. Then, the data processing result and the pointer address of the native data object are transmitted to the application layer through the bridging layer provided by the operating system. Specifically, such as... Figure 4 As shown, the native layer can send a data packet containing the data processing result and the pointer address of the native data object to the bridging layer through the second data interface mentioned above. After receiving the data packet, the bridging layer will pass the data packet to the application layer through the first data interface. In other words, the bridging layer will not parse the data packet and will not obtain the data processing result and the pointer address of the native data object.

[0113] In this embodiment, the first data interface is the entry point for the application layer to initiate data processing requests to the bridging layer, and also the exit point for the bridging layer to return the aforementioned data packets; the second data interface is the entry point for the bridging layer to initiate data processing requests to the native layer, and also the exit point for the native layer to return the aforementioned data packets. Data communication between the application layer and the native layer is achieved through the bridging layer.

[0114] S22. The application layer encapsulates the data processing results through the application data objects it creates, executes the corresponding business logic based on the data processing results, and encapsulates the pointer address of the native data object through the associated data object created by the bridging layer provided by the operating system, and binds the lifecycle of the associated data object to the lifecycle of the application data object.

[0115] Taking JavaScript as an example, the application data object created can be a JS object. When the application layer receives the data processing result and the pointer address of the native data object returned by the bridge layer, it can create an application data object to encapsulate the data processing result. The application layer can then manipulate the data processing result through methods within the application data object to execute corresponding business logic, such as displaying the data processing result in the user interface—this is not limited. Similarly, the application layer can call the application class to create the corresponding application data object. Specifically, the properties of the created application data object are initialized through the application class's constructor, using the data processing result as a constructor parameter to assign initial values ​​to the application data object's properties.

[0116] In this embodiment, the native data object needs to be released promptly when the application data object is released. Therefore, the native layer returns the pointer address of the native data object while returning the data processing result, and encapsulates the pointer address by creating an associated data object through the bridging layer. Furthermore, in order to associate the application data object with the native data object, the lifecycle of the associated data object is bound to the lifecycle of the application data object in the application layer.

[0117] In some embodiments, when the application layer encapsulates the pointer address of the native data object in the associated data object created by the bridging layer in S22 above, such as Figure 5 As shown, the application layer can send an object creation request containing the pointer address of the native data object to the bridge layer through the first data interface mentioned above; the bridge layer creates an associated data object based on the object creation request, holds the pointer address of the native data object, and returns the associated data object to the application layer through the first data interface mentioned above. Then, as... Figure 6 As shown, when the application layer binds the lifecycle of an associated data object to the lifecycle of an application data object, it can specifically allow the application data object to hold the associated data object, treat the associated data object as an application variable of the application data object, and save the application variable within the application data object, thereby binding the lifecycle of the associated data object to the lifecycle of the application data object. Here, the application variable can be understood as an attribute of the application data object.

[0118] In some optional implementations, when the bridging layer creates an associated data object based on an object creation request, it can specifically obtain the associated class used to bind the native layer and the application layer; the bridging layer takes the pointer address of the native data object as a constructor parameter and passes the constructor parameter to the constructor of the associated class, and creates the associated data object based on the constructor.

[0119] In this context, constructor parameters refer to the parameters passed to the constructor of the associated class when creating an instance of the associated class (i.e., the associated data object). The constructor initializes the properties of the created associated data object and assigns the constructor parameters to those properties. For example, taking the NAPI layer of the HarmonyOS operating system as the bridging layer, the associated class used to bind the native layer and the application layer is the JSNativeBindObejct class. The NAPI layer can export the JSNativeBindObejct class and set the constructor (such as JsConstructor) to be executed when creating a JSNativeBindObejct object (i.e., the associated data object). The pointer address of the native data object is passed as a constructor parameter to the constructor, which then assigns the pointer address of the native data object to the properties of the associated data object.

[0120] In this embodiment, the application layer sends an object creation request containing a pointer address of the native data object to the bridging layer, causing the bridging layer to create an associated data object and return it to the application layer. The application layer then binds the lifecycle of the associated data object to the lifecycle of the application data object, thereby achieving a weak association between the application data object and the native data object.

[0121] S23. During the execution of business logic in the application layer, when the bridging layer detects that the application data object has been released, it determines that the lifecycle of the application data object and the associated data object has ended. Based on the pointer address of the native data object in the associated data object, it obtains the native data object and performs a release operation on the native data object.

[0122] In the process of executing business logic at the application layer, the application layer can employ an automatic garbage collection mechanism to manage the lifecycle of application data objects. This means automatically identifying and releasing application data objects that are no longer in use. When an application data object is released, the associated data objects bound to it are also released simultaneously. Since the application layer does not provide a release callback for application data objects, it is difficult to detect the release operation. Therefore, this embodiment of the application uses a bridging layer to detect the release operation of application data objects.

[0123] In some embodiments, such as Figure 7As shown, to detect whether an application data object has been released, the bridging layer, after creating the associated data object, retrieves the application data object bound to it from the application layer, creates a destruction callback method, and saves the created associated data object into the destruction callback method. The destruction callback method is set to be called when the application data object is released. Then, the destruction callback method is registered with the operating system. The destruction callback method typically refers to a method or function called when an object is destroyed or its resources are released. Thus, during the execution of business logic in the application layer, when the destruction callback method is called by the operating system, the bridging layer can determine that the application data object has been released, thereby determining the end of the lifecycle of the application data object and its associated data object.

[0124] For example, taking the NAPI layer of the HarmonyOS operating system as the bridging layer, the NAPI layer can set the FinalizeCallback method to be called when the application data object is released in the napi_wrap method provided by the HarmonyOS operating system. The napi_wrap method is used to associate the application data object with the native data object.

[0125] In this embodiment, the bridging layer creates a destruction callback method and registers the destruction callback method with the operating system so that the operating system calls the destruction callback method when releasing the application data object, thereby enabling the bridging layer to detect that the application data object has been released, so as to release the native data object associated with the application data object in a timely manner.

[0126] In some alternative implementations, when the operating system calls the destructor callback method, the bridging layer obtains the associated data object from the destructor callback method, then obtains the pointer address of the native data object from the associated data object, and obtains the native data object based on the pointer address of the native data object, and performs a release operation on the native data object.

[0127] Specifically, performing a delete operation on the native data object releases the memory it occupies. This ensures that the native data object's local resources are not leaked when the application layer no longer needs it. In other words, the destructor callback method can automatically clean up the local resources of the native data object associated with the application data object when the application data object is released, thereby avoiding memory leaks.

[0128] By binding the application data object created at the application layer to the associated data object that holds the pointer address of the native data object, a weak association is formed between the application data object and the native data object through the associated data object. When the bridging layer detects that the application data object has been released, it determines that the associated native data object can be released. Then, it obtains the pointer address of the native data object from the associated data object, retrieves the native data object based on the pointer address, and automatically performs the release operation on the native data object. Developers do not need to manually add the release logic of the native data object every time it is created, which simplifies the release process of the native data object. Furthermore, due to the timely release of the native data object, memory leaks are avoided.

[0129] In some embodiments, considering that the data processing result may change after the native layer obtains it, for example, when the application layer requests data from the native layer, the data processing result obtained by the native layer is the specific data obtained, which may change; in this case, after the native layer transmits the data processing result and the pointer address of the native data object to the application layer, if it is determined that the data processing result has changed, the data processing result stored in the native data object can be replaced with the changed data processing result, and the changed data processing result can be transmitted to the application layer; in this way, the application layer can continue to execute the corresponding business logic based on the updated data processing result.

[0130] For example, the application layer can build a user interface where the user can request locally saved file information. In this case, the application layer can initiate a data processing request (i.e., a file retrieval request) to the native layer through a bridge layer. After retrieving the file information, the native layer creates a native data object to store the file information and returns the file information and the pointer address of the native data object to the application layer through the bridge layer. Later, while the application layer is displaying the file information in the user interface, if the native layer detects that the locally saved file information has changed, it can replace the file information stored in the native data object with the changed file information and transmit the changed file information to the application layer. In this way, the application layer can redisplay the updated file information in the user interface.

[0131] The following is combined with Figure 8 The overall flow of the object processing method according to the embodiments of this application will be described.

[0132] like Figure 8 As shown, taking an application layer using JS (JavaScript), a native layer using C++, and a bridging layer using NAPI from the HarmonyOS operating system as an example, the overall flow of the object processing method in this application embodiment includes the following:

[0133] The S81 and JS layers send data processing requests to the NAPI layer.

[0134] The S82 and NAPI layers send data processing requests to the native layer.

[0135] S83. The native layer processes data based on the data processing request and creates a NativeObjectA object to encapsulate the data processing result.

[0136] Among them, the NativeObjectA object is the native data object.

[0137] S84. The native layer returns a data packet containing the data processing result and the pointer address of the NativeObjectA object to the NAPI layer.

[0138] S85 and NAPI layers pass data packets to the JS layer.

[0139] The S86 and JS layers create JS data objects to encapsulate the data processing results and execute corresponding business logic based on the data processing results.

[0140] S87. The JS layer sends an object creation request containing the pointer address of the NativeObjectA object to the NAPI layer.

[0141] The S88 and NAPI layers create a JSNativeBindObejct object based on the object creation request to encapsulate the pointer address of the NativeObjectA object, and register the destructor callback method with the operating system.

[0142] The JSNativeBindObejct object is the associated data object. JSNativeBindObejct is an associated class provided by the NAPI layer, which can be exported by the NAPI layer and used in the JS layer.

[0143] S89. The NAPI layer returns a JSNativeBindObejct object to the JS layer.

[0144] S90, the JS layer binds the JSNativeBindObejct object to the lifecycle of the JS data object.

[0145] In this process, the JS layer stores the JSNativeBindObejct object into the JS variable of the JS data object. At the same time, the JSNativeBindObejct object records the pointer address of the NativeObjectA object, thus creating a weak association between the JS data object and the NativeObjectA object.

[0146] S91, NAPI layer: When the operating system calls the destructor callback method, it determines that the JS data object has been released, the lifecycle of the JSNativeBindObject object has ended, the NativeObjectA object is addressed through the pointer address of the NativeObjectA object, and the NativeObjectA object is released.

[0147] In practical applications, the JSBinNativeOBject class is exported at the NAPI layer, and the `napi_wrap` method provided by the HarmonyOS operating system is used to associate data objects from two different language stacks (native layer and JS layer). The JS layer calls the JSBinNativeOBject class in the NAPI layer as needed to create a JSBinNativeOBject object, passing the pointer address of the NativeObjectA object to the JSBinNativeOBject object. When the JS data object is released by the operating system, the `finalize callback` method is triggered. In the `finalize callback`, the NAPI layer obtains the pointer address of the NativeObjectA object, locates the NativeObjectA object, and performs the release operation.

[0148] The object processing method of this application embodiment can be applied to various applications. The following are examples of practical application scenarios of the object processing method.

[0149] In some application scenarios, such as Figure 9 As shown, users can take photos in the user interface built in the application layer. This user interface provides a shutter button. When the user triggers the shutter button in the user interface, the application layer can initiate a shooting request (i.e., a data processing request) to the native layer through the bridge layer. The native layer calls the camera's shooting function, obtains the captured photo, and creates a native data object to save the photo information (i.e., the data processing result). Then, through the bridge layer, it returns a data packet containing the photo information and the pointer address of the native data object to the application layer. Further, as... Figure 10 As shown, the application layer encapsulates photo information through the application data object it creates, and encapsulates the pointer address of the native data object through the associated data object created by the bridging layer, and binds the lifecycle of the associated data object to that of the application data object; when the bridging layer detects that the application data object is released, it determines that the lifecycle of the application data object and the associated data object has ended, and releases the native data object based on the pointer address in the associated data object.

[0150] In other application scenarios, when the user interface built by the application layer is a chat interface, users can obtain friend information in the chat interface. The application layer can send a friend information retrieval request (i.e., data processing result) to the native layer through the bridging layer. The native layer can call the network interface to obtain friend information from the server, create a native data object to store the friend information, and then return the friend information and the pointer address of the native data object to the application layer through the bridging layer. The subsequent processing is similar to the aforementioned application scenarios and will not be described in detail here.

[0151] In other application scenarios, when the user interface built by the application layer is a meeting creation interface, users can create a new meeting on the meeting creation interface. The application layer can send a meeting creation request (i.e., data processing result) to the native layer through the bridging layer. The native layer can call the network interface to request the server to create the meeting and obtain the meeting identification information returned by the server (i.e., data processing result). It can then create a native data object to store the meeting identification information and return the meeting identification information and the pointer address of the native data object to the application layer through the bridging layer. The subsequent processing is similar to the aforementioned application scenarios and will not be described in detail here.

[0152] In other application scenarios, after the application layer builds the user interface, users can obtain weather information for a specified city through the user interface. In this case, the application layer can initiate a weather acquisition request (i.e., a data processing request) to the native layer through the bridging layer. The native layer can call the network interface to obtain the weather information (i.e., the data processing result) of the specified city from the network, and create a native data object to store the weather information of the specified city. Then, the bridging layer returns the weather information of the specified city and the pointer address of the native data object to the application layer. The subsequent processing is similar to the aforementioned application scenarios and will not be described in detail here.

[0153] Based on the same inventive concept, this application also provides an object processing device. The principle of the device in solving the problem is similar to the method in the above embodiments. Therefore, the implementation of the device can refer to the implementation of the above method, and the repeated parts will not be described again.

[0154] like Figure 11 As shown, this is a schematic diagram of the structure of the object processing device 1100, which may include:

[0155] The transmission module 1101 is used to process the data processing request when the native layer obtains the data processing request from the application layer, encapsulate the obtained data processing result into the created native data object, and transmit the data processing result and the pointer address of the native data object to the application layer.

[0156] The processing module 1102 is used by the application layer to encapsulate the data processing results through the application data object it creates, and to execute the corresponding business logic according to the data processing results. It also encapsulates the pointer address of the native data object through the associated data object created by the bridging layer provided by the operating system, and binds the life cycle of the associated data object to the life cycle of the application data object.

[0157] The release module 1103 is used to determine the end of the lifecycle of the application data object and the associated data object when the bridge layer detects that the application data object has been released during the execution of business logic in the application layer. It then obtains the native data object based on the pointer address of the native data object in the associated data object and performs a release operation on the native data object.

[0158] By binding the application data object created at the application layer to the associated data object that holds the pointer address of the native data object, a weak association is formed between the application data object and the native data object through the associated data object. When the bridging layer detects that the application data object has been released, it determines that the associated native data object can be released. Then, it obtains the pointer address of the native data object from the associated data object, retrieves the native data object based on the pointer address, and automatically performs the release operation on the native data object. Developers do not need to manually add the release logic of the native data object every time it is created, which simplifies the release process of the native data object. Furthermore, due to the timely release of the native data object, memory leaks are avoided.

[0159] In some optional implementations, when the associated data object created through the bridging layer provided by the operating system encapsulates the pointer address of the native data object and binds the lifecycle of the associated data object to the lifecycle of the application data object, the processing module 1102 is specifically used for:

[0160] The application layer sends an object creation request containing pointer addresses to native data objects to the bridge layer provided by the operating system;

[0161] The bridging layer creates an associated data object based on the object creation request, and encapsulates the pointer address of the original data object into the pointer address of the original data object, and returns the associated data object to the application layer;

[0162] The application layer uses the associated data object as an application variable of the application data object and saves the application variable into the application data object to bind the lifecycle of the associated data object to the lifecycle of the application data object.

[0163] In some optional implementations, when the bridging layer creates an associated data object based on an object creation request, the processing module 1102 is specifically used for:

[0164] The bridging layer obtains the associated class used to bind the native layer and the application layer based on the object creation request;

[0165] The bridging layer takes the pointer address of the native data object as the constructor parameter and passes the constructor parameter to the constructor of the associated class, and creates the associated data object based on the constructor.

[0166] In some alternative implementations, such as Figure 12 As shown, the device also includes:

[0167] Registration module 1104 is used by the bridging layer to create a destructor callback method, save the created associated data object to the destructor callback method, and register the destructor callback method with the operating system. The destructor callback method is called when the application data object is released.

[0168] During the execution of business logic at the application layer, when the bridging layer detects that an application data object has been released, it determines that the lifecycle of the application data object and its associated data objects has ended. Specifically, the release module 1103 is used for:

[0169] During the execution of business logic at the application layer, when the destructor callback method is called by the operating system, the bridge layer determines that the application data object has been released and that the lifecycle of the associated data object has ended.

[0170] In some optional implementations, when the native data object is obtained based on the pointer address of the native data object in the associated data object, and a release operation is performed on the native data object, the release module 1103 is specifically used for:

[0171] When the operating system calls the destructor callback method, the bridge layer obtains the associated data object from the destructor callback method, obtains the pointer address of the native data object from the associated data object, obtains the native data object based on the pointer address of the native data object, and performs a release operation on the native data object.

[0172] In some alternative implementations, the transmission module 1101 is further configured to:

[0173] The application layer sends a data processing request to the bridging layer provided by the operating system through the first data interface. After receiving the data processing request, the bridging layer transmits the data processing request to the native layer through the second data interface.

[0174] When transmitting the data processing results and the pointer address of the original data object to the application layer, the transmission module is specifically used for:

[0175] The native layer sends a data packet containing the data processing result and the pointer address of the native data object to the bridging layer through the second data interface;

[0176] After receiving the data packet, the bridging layer transmits the data packet to the application layer through the first data interface.

[0177] In some alternative embodiments, the apparatus further includes:

[0178] The replacement module 1105 is used to replace the data processing result stored in the original data object with the changed data processing result when the original layer determines that the data processing result has changed, and transmit the changed data processing result to the application layer.

[0179] The processing module 1102 is also used for: the application layer to execute corresponding business logic based on the updated data processing results.

[0180] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.

[0181] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0182] Having introduced the object processing method and apparatus according to exemplary embodiments of this application, we will now introduce an electronic device according to another exemplary embodiment of this application.

[0183] Based on the same inventive concept as the above-described method embodiments, this application also provides an electronic device. In one embodiment, the electronic device may be a terminal device, such as... Figure 1 The terminal device 130 is shown. In this embodiment, the electronic device can be structured as follows: Figure 13 As shown, it includes a memory 1301, a communication module 1303, and one or more processors 1302.

[0184] The memory 1301 is used to store computer programs executed by the processor 1302. The memory 1301 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0185] Memory 1301 may be volatile memory, such as random-access memory (RAM); memory 1301 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1301 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1301 may be a combination of the above-described memories.

[0186] Processor 1302 may include one or more central processing units (CPUs) or digital processing units, etc. Processor 1302 is used to implement the above-described object processing method when calling computer programs stored in memory 1301.

[0187] The communication module 1303 is used to communicate with terminal devices and other devices.

[0188] This application embodiment does not limit the specific connection medium between the memory 1301, communication module 1303, and processor 1302. This application embodiment... Figure 13 The memory 1301 and the processor 1302 are connected via a bus 1304, and the bus 1304 is in Figure 13 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1304 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 13 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.

[0189] The memory 1301 stores a computer storage medium, which stores computer-executable instructions for implementing the object processing method of this application embodiment. The processor 1302 is used to execute the above-described object processing method, such as... Figure 2 As shown.

[0190] In another embodiment, the electronic device can be structured as follows: Figure 14 As shown, it includes components such as: communication component 1410, memory 1420, display unit 1430, camera 1440, sensor 1450, audio circuit 1460, Bluetooth module 1470, processor 1480, etc.

[0191] The communication component 1410 is used to communicate with the server. In some embodiments, it may include a Circuit-Based Wireless Fidelity (WiFi) module, which is a short-range wireless transmission technology. Electronic devices can use the WiFi module to help users send and receive information.

[0192] The memory 1420 can be used to store software programs and data. The processor 1480 executes various functions of the terminal device 130 and performs data processing by running the software programs or data stored in the memory 1420. The memory 1420 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The memory 1420 stores an operating system that enables the terminal device 130 to run. In this application, the memory 1420 may store the operating system and various application programs, and may also store computer programs that execute the object processing methods of the embodiments of this application.

[0193] The display unit 1430 can also be used to display information input by the user or information provided to the user, as well as various menus of the terminal device 130, in a graphical user interface (GUI). Specifically, the display unit 1430 may include a display screen 1432 disposed on the front of the terminal device 130. The display screen 1432 may be configured as a liquid crystal display, a light-emitting diode, or the like.

[0194] The display unit 1430 can also be used to receive input digital or character information and generate signal inputs related to user settings and function control of the terminal device 130. Specifically, the display unit 1430 may include a touch screen 1431 disposed on the front of the terminal device 130, which can collect touch operations of the user on or near it, such as clicking buttons, dragging scroll boxes, etc.

[0195] The touchscreen 1431 can be placed on top of the display screen 1432, or the touchscreen 1431 and the display screen 1432 can be integrated to realize the input and output functions of the terminal device 130. After integration, it can be referred to as a touch display screen. In this application, the display unit 1430 can display the application and the corresponding operation steps.

[0196] Camera 1440 can be used to capture still images, which users can then share via an application. There can be one or multiple cameras 1440. An object is projected onto a photosensitive element through a lens, generating an optical image. This photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to the processor 1480 for conversion into a digital image signal.

[0197] The terminal device may also include at least one sensor 1450, such as an accelerometer 1451, a proximity sensor 1452, a fingerprint sensor 1453, and a temperature sensor 1454. The terminal device may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, thermometer, infrared sensor, light sensor, and motion sensor.

[0198] Audio circuitry 1460, speaker 1461, and microphone 1462 provide an audio interface between the user and terminal device 130. Audio circuitry 1460 converts received audio data into electrical signals, which are then transmitted to speaker 1461, where they are converted into sound signals for output. Terminal device 130 may also be equipped with volume buttons for adjusting the volume of the sound signal. Conversely, microphone 1462 converts collected sound signals into electrical signals, which are then received by audio circuitry 1460, converted back into audio data, and output to communication component 1410 for transmission to, for example, another terminal device 130, or to memory 1420 for further processing.

[0199] The Bluetooth module 1470 is used to interact with other Bluetooth devices that also have a Bluetooth module via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smartwatch) that also has a Bluetooth module through the Bluetooth module 1470, thereby exchanging data.

[0200] The processor 1480 is the control center of the terminal device, connecting various parts of the terminal through various interfaces and lines. It executes various functions and processes data by running or executing software programs stored in the memory 1420 and calling data stored in the memory 1420. In some embodiments, the processor 1480 may include one or more processing units; the processor 1480 may also integrate an application processor and a baseband processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 1480. In this application, the processor 1480 can run the operating system, applications, user interface display and touch response, and the object processing method of the embodiments of this application. Furthermore, the processor 1480 is coupled to the display unit 1430.

[0201] In some possible implementations, various aspects of the object processing method provided in this application can also be implemented in the form of a computer program product, which includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of the object processing method according to the various exemplary embodiments of this application described above. For example, the electronic device can perform actions such as... Figure 2 The steps are shown in the figure.

[0202] Computer program products may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0203] The computer program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0204] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

[0205] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0206] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The computer program can execute entirely on the user's electronic device, partially on the user's electronic device, as a standalone software package, partially on the user's electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the user's electronic device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external electronic device (e.g., via the Internet using an Internet service provider).

[0207] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0208] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0209] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing a computer-usable computer program.

[0210] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0211] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. An object processing method characterized by comprising: The method includes: When the native layer receives a data processing request from the application layer, it processes the data processing request, encapsulates the obtained data processing result into a created native data object, and transmits the data processing result and the pointer address of the native data object to the application layer. The application layer encapsulates the data processing results through the created application data object, executes corresponding business logic based on the data processing results, and encapsulates the pointer address of the native data object through the associated data object created by the bridging layer provided by the operating system, and binds the lifecycle of the associated data object to the lifecycle of the application data object; During the execution of the business logic in the application layer, when the bridging layer detects that the application data object has been released, it determines that the lifecycle of the application data object and the associated data object has ended, obtains the native data object based on the pointer address of the native data object in the associated data object, and performs a release operation on the native data object.

2. The method of claim 1, wherein, The associated data object created through the bridging layer provided by the operating system encapsulates the pointer address of the native data object and binds the lifecycle of the associated data object to the lifecycle of the application data object, including: The application layer sends an object creation request containing the pointer address of the native data object to the bridge layer; The bridging layer creates the associated data object based on the object creation request, encapsulates the pointer address of the original data object into the pointer address of the original data object, and returns the associated data object to the application layer; The application layer uses the associated data object as an application variable of the application data object and saves the application variable into the application data object to bind the lifecycle of the associated data object to the lifecycle of the application data object.

3. The method according to claim 2, characterized in that, The bridging layer creates the associated data object based on the object creation request, including: The bridging layer obtains the associated class for binding the native layer and the application layer based on the object creation request; The bridging layer takes the pointer address of the native data object as a constructor parameter and passes the constructor parameter to the constructor method of the associated class to create the associated data object based on the constructor method.

4. The method according to claim 2, characterized in that, The method further includes: The bridging layer creates a destruction callback method, saves the created associated data object into the destruction callback method, and registers the destruction callback method with the operating system. The destruction callback method is invoked when the application data object is released. During the execution of the business logic in the application layer, when the bridging layer detects that the application data object has been released, it determines that the lifecycle of the application data object and the associated data object has ended, including: During the execution of the business logic in the application layer, when the destruction callback method is called by the operating system, the bridge layer determines that the application data object is released and that the lifecycle of the application data object and the associated data object has ended.

5. The method according to claim 4, characterized in that, The step of obtaining the native data object based on the pointer address of the native data object in the associated data object and performing a release operation on the native data object includes: When the operating system calls the destructor callback method, the bridge layer obtains the associated data object from the destructor callback method, obtains the pointer address of the native data object from the associated data object, obtains the native data object based on the pointer address of the native data object, and performs a release operation on the native data object.

6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: The application layer sends the data processing request to the bridging layer through the first data interface. After receiving the data processing request, the bridging layer transmits the data processing request to the native layer through the second data interface. The data processing result and the pointer address of the original data object are then transmitted to the application layer through the bridging layer provided by the operating system, including: The native layer sends a data packet containing the data processing result and the pointer address of the native data object to the bridge layer through the second data interface; After receiving the data packet, the bridging layer transmits the data packet to the application layer through the first data interface.

7. The method according to any one of claims 1 to 5, characterized in that, The method further includes: When the native layer determines that the data processing result has changed, it replaces the data processing result stored in the native data object with the changed data processing result and transmits the changed data processing result to the application layer. The application layer executes corresponding business logic based on the updated data processing results.

8. An object processing apparatus, characterized in that, The device includes: The transmission module is used to process the data processing request when the native layer receives the data processing request from the application layer, encapsulate the obtained data processing result into a created native data object, and transmit the data processing result and the pointer address of the native data object to the application layer. The processing module is used by the application layer to encapsulate the data processing result through the created application data object, execute corresponding business logic according to the data processing result, and encapsulate the pointer address of the native data object through the created associated data object, and bind the life cycle of the associated data object to the life cycle of the application data object; The release module is used to determine the end of the lifecycle of the application data object and the associated data object when the bridge layer detects that the application data object has been released during the execution of the business logic in the application layer. It then retrieves the native data object based on the pointer address of the native data object in the associated data object and performs a release operation on the native data object.

9. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of any one of the methods described in claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of any of the methods described in claims 1 to 7.

11. A computer program product, characterized in that, The method includes a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any one of claims 1 to 7.