Process exception detection method, readable storage medium, program product and electronic equipment

By recording the correspondence between the client and the memory subspace and assigning timestamps, the problem of memory anomalies in inter-process communication is solved, the identification and management of abnormal clients are realized, and the memory utilization efficiency of electronic devices and the stability of applications are improved.

CN120743587AActive Publication Date: 2025-10-03HONOR DEVICE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411081791.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2025-10-03
Estimated Expiration
2044-08-07

AI Technical Summary

Technical Problem

During inter-process communication in electronic devices, improper process settings can lead to memory space anomalies, causing memory leaks or a single object occupying a large amount of memory space, affecting application performance and possibly causing crashes.

Method used

By recording the correspondence between the client and the memory subspace and the allocation timestamp, the client causing the memory space anomaly is identified and managed or optimized, including prohibiting service calls and limiting memory usage.

Benefits of technology

Effectively identify and manage clients that cause memory space anomalies, avoid memory leaks and crashes, and improve application stability and performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743587A_ABST
    Figure CN120743587A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of terminals, in particular to a process anomaly detection method, a readable storage medium, a program product and electronic equipment. The process anomaly detection method is applied to the electronic equipment, and in the process of inter-process communication between a client side and a server side of the electronic equipment, the server side can obtain a first corresponding relation between a memory subspace occupied by the client side and an inter-process communication message corresponding to the client side in the server side and an allocation timestamp of the memory subspace. After the memory space of the server side is abnormal, the electronic equipment can determine the first client side corresponding to the first memory space causing the memory space abnormality of the server side based on the first corresponding relation, so that the first client side is controlled, and the problem that the memory space of the server side continues to be abnormal is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a process anomaly detection method, a readable storage medium, a program product, and an electronic device. Background Art

[0002] At present, the data transmitted during the inter-process communication of electronic devices will occupy part of the memory space of the corresponding application. If the process for inter-process communication is not set up properly, the data transmitted by the inter-process communication will occupy the memory space of the server abnormally (hereinafter referred to as memory space abnormality). For example, if the data of inter-process communication continues to occupy the memory space of the application, it may cause a memory leak of the application (the memory space occupied by the application cannot be recovered), or a single data (or object) transmitted by the inter-process communication will occupy a large amount of memory space on the server. However, the size of the available memory space of the application is limited. If the memory space of the application is abnormal, the available memory space will be reduced, the process of inter-process communication of the application will become slow, and the application will become stuck. In addition, if the memory space of the application is insufficient, it may also cause a crash. Summary of the Invention

[0003] The embodiments of the present application provide a process anomaly detection method, a readable storage medium, a program product, and an electronic device, so as to determine the client that causes the memory space anomaly of the server when an anomaly occurs in the memory space of the server of the electronic device, so as to manage or optimize the corresponding client.

[0004] In a first aspect, an embodiment of the present application provides a process anomaly detection method, which is applied to a first electronic device, the first electronic device including at least one client and a server, the method including: detecting a memory space anomaly of the server, and determining a first memory subspace from the memory space of the server that causes the memory space anomaly of the server, wherein the memory space of the server includes multiple memory subspaces, the multiple memory subspaces include the first memory subspace, and each memory subspace stores an inter-process communication message of a client corresponding to each memory subspace; based on a pre-stored first correspondence and a first timestamp for assigning the first memory subspace, determining the first client corresponding to the first memory subspace, wherein the first correspondence includes a correspondence between the client and the memory subspace and an allocation timestamp for assigning the memory subspace.

[0005] For example, in some embodiments of the present application, during inter-process communication between a client and a server of an electronic device, the server may record a corresponding first correspondence. If an abnormality occurs in the server's memory space, the electronic device may determine the first client that caused the abnormality based on the first correspondence, so as to manage and optimize the first client.

[0006] In a possible implementation of the first aspect above, the above-mentioned first correspondence relationship includes a first sub-correspondence relationship and a second sub-correspondence relationship, wherein the first sub-correspondence relationship includes the correspondence between the client identifier of the client, the interface identifier of the service interface in the server called by the client, the start timestamp and end timestamp of the service interface called by the client, and the thread identifier of the server thread that transmits the client's inter-process communication message; the second sub-correspondence relationship is the correspondence between the memory subspace and the allocation timestamp of the memory subspace, and the thread identifier of the server thread corresponding to the memory subspace.

[0007] For example, in some embodiments of the present application, since the same service interface of the server can be called by multiple clients, the first sub-correspondence included in the first correspondence includes the correspondence between the interface identifier of the service interface and the client identifier. Since the same server can call the same interface service at different time ends, the first sub-correspondence also includes the start timestamp and end timestamp of the service interface being called by the client. In this way, after determining the service interface and the start timestamp and end timestamp of the service interface being called, the client can be uniquely identified.

[0008] In the second sub-correspondence, since the same server thread can be received by multiple service interfaces, the memory subspace can be corresponded to multiple service interfaces through the thread identifier of the server thread. Based on the allocation timestamp of the memory subspace, as well as the start timestamp and end timestamp of the service interface called by the client, the service interface corresponding to the memory subspace can be uniquely determined from multiple service interfaces, and then the server corresponding to the memory subspace can be determined. Therefore, the client corresponding to a memory subspace can be uniquely determined through the first sub-correspondence and the second sub-correspondence. After determining that the memory subspace causes the memory space abnormality of the server, the client corresponding to the memory subspace can be determined.

[0009] In a possible implementation of the first aspect above, the above-mentioned first client corresponding to the first memory subspace is determined based on the pre-stored first correspondence and the first timestamp assigned to the first memory subspace, including: obtaining the first thread identifier and the first timestamp corresponding to the first memory space from the second sub-correspondence; based on the first thread identifier, obtaining at least one first interface identifier corresponding to the first thread identifier from the first sub-correspondence; based on the first sub-correspondence, the interface identifier of the corresponding called service interface is set as the first interface identifier, and the time period corresponding to the start timestamp and end timestamp of the called service interface is determined as the first client.

[0010] In a possible implementation of the first aspect, the method further includes managing and controlling the first client.

[0011] For example, in some embodiments of the present application, after determining that the first client has caused a memory space anomaly on the server, the electronic device may control the first client, for example, prohibiting the first client from calling the server's services, limiting the duration of the first client's calling the server's services, limiting the memory space on the server occupied by the first client's inter-process communication messages, etc., to prevent the server from having a memory anomaly again.

[0012] In a possible implementation of the first aspect, the determining of the first memory subspace from the memory space of the server that causes the memory space abnormality of the server includes: taking the memory subspace that occupies the largest storage space among multiple memory subspaces as the first memory subspace.

[0013] For example, in some embodiments of the present application, the server's memory subspace stores inter-process communication messages. If the inter-process communication messages occupy a large amount of storage space, the client corresponding to the inter-process communication messages needs to be optimized or controlled. Therefore, if an abnormality occurs in the server's memory space, the memory subspace that occupies the largest storage space can be determined as the first memory space, and the client corresponding to the first memory space can be further determined.

[0014] In a possible implementation of the first aspect, the detection of a memory space abnormality on the server includes: the occupied memory space on the server exceeds a space threshold.

[0015] In the second aspect, the present application provides a process anomaly detection method, including: a first electronic device obtains a first correspondence between each client and memory subspace, and an allocation timestamp of the memory subspace, which are pre-stored in the first electronic device, wherein the memory subspace is a memory space for storing inter-process communication messages of the client on the server side of the first electronic device; the first electronic device sends the first correspondence and the usage data of the memory space of the server side to a second electronic device; the second electronic device detects an anomaly in the memory space of the server side of the first electronic device based on the usage data of the memory space of the server side; the second electronic device determines the first memory subspace from the memory subspace that causes the memory space anomaly of the server side; the second electronic device determines the first client corresponding to the first memory space based on the first timestamp of allocating the first memory space and the first correspondence.

[0016] In some embodiments of the present application, a first electronic device may send a first correspondence stored during inter-process communication between a client and a server and usage data of the server's memory space to a second electronic device. The second electronic device may determine whether there is an abnormality in the server's memory space based on the memory space usage data of the first electronic device. The usage data may be, for example, the usage of the server's memory space. In the event that there is an abnormality in the server's memory space of the first electronic device, the second electronic device may determine the first client causing the abnormality in the server's memory space based on the first correspondence, and the second electronic device may optimize and adjust the first client.

[0017] In a third aspect, the present application provides a process anomaly detection method, comprising: a first electronic device detects an anomaly in the memory space of a server in the first electronic device, and determines a first memory subspace in the memory space of the server that causes the anomaly in the memory space of the server, wherein the memory space of the server includes multiple memory subspaces, the multiple memory subspaces include a first memory subspace, and each memory subspace stores an inter-process communication message of a client corresponding to each memory subspace; the first electronic device sends an identifier of the first memory subspace and a pre-stored first correspondence to a second electronic device, wherein the first correspondence includes a correspondence between the client and the memory subspace and a timestamp for allocating the memory subspace; the second electronic device determines the first client corresponding to the first memory subspace based on the first timestamp for allocating the first memory subspace and the first correspondence.

[0018] It can be understood that in some embodiments of the present application, after detecting an abnormality in the memory space of the server, the first electronic device can send the first correspondence and the identifier of the first memory space to the second electronic device. The second electronic device determines the first client that causes the abnormality in the memory space of the server of the first electronic device based on the first correspondence, and optimizes or controls the first client.

[0019] In a fourth aspect, the present application provides an electronic device, comprising: a memory for storing instructions; and at least one processor for executing the instructions to cause the device to implement the method provided in the first aspect and any possible implementation of the method provided in any of the first to third aspects. The beneficial effects achievable in the fourth aspect can be referenced to the beneficial effects of the method provided in any of the embodiments of the first to third aspects and will not be further elaborated here.

[0020] In a fifth aspect, the present application provides a computer-readable storage medium having instructions stored therein. When executed by a device, the instructions cause a computer to implement the method provided in the first aspect and any possible implementation of the first through third aspects. The beneficial effects achievable in the fifth aspect can be referenced to the beneficial effects of the method provided in any of the embodiments of the first through third aspects and will not be further elaborated here.

[0021] In a sixth aspect, the present application provides a computer program product that, when executed on a device, causes the device to implement the method provided in any of the first through third aspects and any possible implementation of the first aspect. The beneficial effects achieved in the sixth aspect can be referenced to the beneficial effects of the method provided in any of the implementations of the first through third aspects and are not further elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A schematic diagram of binder communication is shown;

[0023] Figure 2 A schematic diagram showing an electronic device running an application;

[0024] Figure 3 According to an embodiment of the present application, a flowchart for locating a client causing a memory space anomaly on a server is shown;

[0025] Figure 4 According to some embodiments of the present application, a schematic diagram of a binder communication process is shown;

[0026] Figure 5 According to some embodiments of the present application, a schematic diagram of reference relationships of objects reclaimed by GC is shown;

[0027] Figure 6 According to some embodiments of the present application, a schematic diagram showing the start timestamp and end timestamp of a binder interface being called is shown;

[0028] Figure 7 According to an embodiment of the present application, a schematic block diagram of a system software architecture of an electronic device is shown;

[0029] Figure 8 According to an embodiment of the present application, a structural diagram of an electronic device is shown. DETAILED DESCRIPTION

[0030] The illustrative embodiments of the present application include, but are not limited to, a process anomaly detection method, a readable storage medium, a program product, and an electronic device.

[0031] To facilitate understanding, some of the terms and related technologies involved in this application are explained below.

[0032] 1. Inter-process communication (IPC) mechanism.

[0033] The IPC mechanism refers to the process of exchanging data between two or more processes. A process is an independent unit for resource allocation and scheduling in the system and serves as the carrier for application execution. Each process has its own independent memory space and system resources.

[0034] Different operating systems have their own IPC mechanisms, such as sockets, pipes, memory sharing, message queues, and binder communication.

[0035] 2. Binder mechanism.

[0036] The binder mechanism includes several system components, namely the client, server, service manager (SM), and binder driver.

[0037] The client refers to the client process, which is a relative term. Any party that initiates a process request can be called a client process. The server refers to the service process, which is also a relative term. Any process requested to perform a certain service can be called a server process. SM is used to manage service processes. Each service process must register its cross-process binder in SM and save a reference to the corresponding binder. The client can query the name of the desired service in SM by name, and then SM will return a reference to a binder for the server. The binder driver plays a transit role in the specific communication process. For example, it transfers the data that needs to be transmitted.

[0038] The core component of the binder mechanism is the binder driver, and SM provides auxiliary management functions. The client and server communicate with each other on the infrastructure provided by the binder driver and service manager.

[0039] The binder mechanism can include three processes: registering services, obtaining services, and using services.

[0040] Registering the service: The server first registers the service with the service manager.

[0041] For example, the server initiates a service registration request through the binder driver. The binder driver forwards the registration request to the SM and registers the binder service (e.g., the service corresponding to the binder interface) with the SM. The binder driver can create an entity node in the kernel for the binder service and a reference to the entity from the SM, and then package the service name and the newly created reference and transmit it to the SM. After receiving the request, the SM can enter the service name and the reference to the entity into a lookup table.

[0042] Obtaining services: Before a client uses a server, it must first obtain the corresponding server information from the SM.

[0043] For example, a client can initiate a request to the binder driver for a service. The client can query the SM for the name of the service it wants to obtain. In response, the SM can return a reference to a binder service entity on the server side corresponding to the service. The client can then communicate with the server through this reference.

[0044] Using services: The client establishes communication with the server providing the service based on the server information obtained, and then can interact with the server.

[0045] During IPC communication between applications, memory space must be allocated to process the IPC data. In some electronic devices, the Java Virtual Machine (JVM) manages the application's memory space. For example, the JVM can automatically release unused memory resources through garbage collection (GC), preventing issues like memory leaks and memory overflows.

[0046] Taking the JVM allocating memory space to the server as an example, when the server is running, the JVM can allocate heap memory (heap memory) to the server so that the server can store object instances and arrays. In some embodiments, the JVM can also allocate other memory space (such as program counter, Java virtual machine stack, etc.) to the server to perform corresponding services. This application does not limit the memory space allocated by the JVM to the server. In the process of electronic equipment using the binder mechanism for IPC communication, after the client obtains the server information, it can send an IPC message to the binder interface provided by the server. After the server corresponding to the binder interface receives the IPC message, it can package the data in the IPC message into an object (for example, package the IPC data into a data packet (parcel) object) and store it in the heap memory allocated by the Java virtual machine for the server. After the server processes the message, it can return the message to the client through the binder interface. After that, the Java virtual machine can reclaim the memory space occupied by the IPC message through GC to avoid memory leaks on the server.

[0047] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described in detail below with reference to the accompanying drawings and specific implementation methods.

[0048] As mentioned above, when a memory space exception occurs in an application, it is difficult to locate the specific cause of the memory space exception in the application, and therefore, it is difficult to handle the memory space exception.

[0049] Next, we introduce the communication process of the binder mechanism.

[0050] For example, Figure 1 A schematic diagram of binder communication is shown.

[0051] For example, referring to Figure 1 For example, the client may include a business thread, which refers to a thread in the client process that executes specific business logic.

[0052] The server side may include, for example, a binder thread, a binder interface, and a binder service.

[0053] The binder interface bridges the communication gap between the client and the binder service, defining the communication operations that can be performed between the two parties. The binder service is responsible for processing client requests and returning corresponding results. These results are transmitted to the client via the binder interface, allowing the client to call the methods provided by the binder service.

[0054] The binder thread is responsible for receiving IPC messages from the client (or the client's business thread), distributing them to the corresponding binder service for processing, and returning the processing results to the client. For example, after the client's business thread sends an IPC message to the binder service, the server can create a binder thread to process the business thread's IPC message. For example, when the binder thread receives an IPC message, it can call the corresponding binder interface based on the information carried in the IPC message (such as interface descriptor, method code, etc.).

[0055] In some embodiments, the binder thread does not need to be destroyed when the service thread call ends, so that it can continue to process the IPC message sent by the next service thread. In other words, the binder thread can be reused to increase the speed of the service thread processing on the server side.

[0056] For example, refer to Figure 1 , the client's business thread 1 can send an IPC message 1 to the server. The IPC message 1 includes the binder interface information corresponding to the binder service called by the business thread 1 (for example, the information of the called binder interface 1). After receiving the IPC message 1, the server can create a binder thread 1 to transmit the IPC message 1. The binder thread 1 determines to transmit the IPC message 1 to the binder interface 1 based on the information of the binder interface 1 provided in the IPC message 1. After the binder service 1 receives the IPC message 1 through the binder interface 1, it can package the IPC message 1 into an object 1, and then apply for memory 1 from the server's heap memory to store the object 1, so that the server can process the data carried in the IPC message 1. After the client's business thread 1 calls the binder service 1, the Java virtual machine can reclaim the corresponding memory 1 through GC to ensure that the server's heap memory has enough memory space to store objects or instances.

[0057] It is understood that the server can provide a variety of services. For example, refer to Figure 1 The server can provide binder service 1 and binder service 2, and each binder service corresponds to a binder interface (for example, binder interface 1 and binder interface 2). After receiving an IPC message, each binder service can package the IPC message into an object, apply for memory space for the object on the server, and then store the object in the memory space.

[0058] I understand. Figure 1The IPC communication process of the binder mechanism shown in is only an example. In other embodiments, the server may include more or fewer binder interfaces and binder services, and may also create more or fewer binder threads. The embodiments of this application do not limit the communication process of the binder mechanism.

[0059] It should be noted that the memory space allocated by the Java Virtual Machine to the server is limited. If the client's business process is improperly configured or abnormal, objects in the client's threads will continue to occupy the server's memory space (for example, the lifecycle of some client threads or tasks is longer than expected, causing objects in the client's threads or tasks to continue to occupy memory space on the server. Or if the client's threads are not properly canceled or completed, the objects in these threads or tasks will continue to occupy the server's memory space). Because the objects in these client threads are always in a referenced state, the JVM cannot reclaim the heap memory occupied by these objects, causing a memory leak on the server and reducing the server's available memory space. Or if a single object in the client's thread or task occupies a large amount of memory space on the server (indicating that the process or object needs to be optimized to reduce the memory space occupied), this may reduce the server's processing efficiency (a single object occupies a large amount of memory space, resulting in the server being unable to process objects from multiple processes or tasks simultaneously).

[0060] For example, if the process corresponding to client A continuously calls services on server B due to improper configuration, this can cause a memory leak on server B and reduce its available memory space. If client C calls services on server B during this process, server B may not have enough memory to process client C's communication messages, causing client C to crash. Furthermore, if the memory occupied on server B exceeds the memory allocated by the Java virtual machine for server B, server B may experience an out of memory (OOM) error.

[0061] For example, Figure 2 A schematic diagram showing an electronic device running an application program is shown.

[0062] It should be noted that this application does not limit the specific form of the electronic device. The electronic device can be a mobile phone, a laptop computer, a tablet computer, a large-screen device, a wearable device (e.g., a watch, smart glasses, a helmet), a desktop computer, an augmented reality (AR) / virtual reality (VR) device, a personal digital assistant (PDA), etc. Below, a mobile phone is used as an example of the electronic device 100.

[0063] Reference Figure 2 In some cases, a user may chat with other users while playing a game on the electronic device 100 and a small chat window may be displayed. For example, the electronic device 100 currently displays a game interface 10, which includes a chat window 11. In some embodiments of the present application, other user programs are also running in the background of the electronic device 100. Therefore, there are many threads in the user space of the electronic device 100 that interact with system applications.

[0064] For example, the application corresponding to the game interface 10 (hereinafter referred to as the game application) and the application corresponding to the chat window 11 (hereinafter referred to as the chat application) are running in the foreground at the same time. These two applications have their own user interface threads and rendering threads.

[0065] It can be understood that both the game application and the chat application need to draw frames so that their interfaces (such as the game interface 10 and the chat window 11) can be displayed on the display screen of the electronic device 100. These two applications can generate frame data, and need to transfer the frame data to the corresponding process in the system application (for example, surface synthesis (surfaceflinger)) through the binder thread, so that the surface synthesis can synthesize and display the image based on the frame data of these two applications. In other words, both applications need to request a binder thread from the surface synthesis. In addition, in this case, there may be some dynamically identified frame-dependent threads in the operating system of the electronic device 100.

[0066] Therefore, when multiple applications in the operating system of the electronic device 100 are running in the foreground, multitasking and high load situations often occur. In this case, inter-process communication is busy. When inter-process communication is busy, if a process continues to occupy the memory space of the system application, resulting in a memory leak of the system application, or a single object of a process occupies a large amount of memory space, it may cause the memory space available to the system application to become smaller. Memory space needs to be allocated and managed during the binder communication process, and insufficient memory space will cause these operations to become slow or unable to complete, which may easily cause the corresponding application to freeze or flash back.

[0067] For example, reference Figure 2 If the chat application continues to occupy the memory space of the surface synthesis due to improper settings, resulting in insufficient available memory space for the surface synthesis, the game application will be slow to call the surface synthesis, and the game interface 10 of the electronic device 100 will display a prompt message 12 saying "Loading..." In other words, the game application has become stuck. If the game application continues to be unable to call data from the surface synthesis, the game application may crash. For example, the electronic device 100 crashes from the game interface 10 and displays the desktop interface 20.

[0068] Therefore, in some cases, if a memory space anomaly occurs on the server side of the electronic device 100, it is necessary to locate the client application that caused the memory space anomaly on the server side, thereby managing the corresponding application and avoiding the memory space anomaly on the server side of the electronic device 100.

[0069] In some embodiments, the call information of the binder interface can be tracked by capturing the call stack. A call stack trace is a list of all active function calls (including their parameters and local variables) when a program is executed to a certain point. Tracking the binder interface generally includes tracking the calling of these interface methods, such as how this part of the interface is called and which methods or functions are called. For example, in the case of a memory leak on the server, the memory leak point (the memory space occupied by the unreleased object) can be found and the call stack of the memory space can be checked. The call stack is then analyzed to find out which code path creates the object, thereby tracing the corresponding binder interface. However, although the binder interface corresponding to the application with memory abnormality can be located by capturing the call stack, since the binder interface is public, it may be called by multiple applications at the same time. Therefore, if there is a memory leak on the server, there are multiple clients calling the binder service through the binder interface on the server, and it is impossible to locate which specific application caused the memory abnormality on the binder server by capturing the stack. In addition, capturing the call stack involves recording the method call sequence of the current thread, which consumes processor and memory resources and may cause the application's response time to become longer. Therefore, the process of capturing the call stack will affect the performance of the system application's memory allocation. For example, for Figure 2In the scenario shown, the game app and the chat app both call surface composition to synthesize and display images during the same time period. Therefore, both the game app and the chat app call the binder interface provided by surface composition. If a surface composition memory leak occurs, capturing the call stack reveals that the applications calling the surface composition binder interface include the game app and the chat app. However, it is still impossible to determine which of the two apps caused the surface composition memory leak, and therefore it is impossible to specifically locate the cause of the surface composition memory leak.

[0070] In summary, when an abnormality occurs in the memory space of a client of an electronic device, it is difficult to locate the application causing the abnormality in the memory space of the client, and thus it is difficult to manage and control the application.

[0071] In some embodiments of the present application, a binder interface corresponding to a binder service can receive IPC messages from multiple clients at the same time, but a binder thread can only transmit IPC messages from one client. In the binder mechanism, multiple binder threads can be created to achieve the effect of processing IPC messages from multiple clients at the same time.

[0072] For example, when an electronic device performs IPC communication through the binder mechanism, the client can send a communication message (e.g., an IPC message) to the server, and the server establishes a thread (e.g., a binder thread) to transmit the communication message to the interface (e.g., a binder interface) corresponding to the corresponding service (e.g., a binder service). After receiving the communication message through the interface, the service packages the communication message into an object (hereinafter referred to as an IPC object) and stores the IPC object in the memory space requested for processing.

[0073] In order to solve the above problems, the present application proposes a process anomaly detection method. During the IPC communication between the server of the electronic device and the client, the server can record the first correspondence between different clients and the memory space allocated to the client (as an example of a memory subspace), and the timestamp of allocating the memory space (as an example of an allocation timestamp).

[0074] When the electronic device detects an abnormality in the memory space of the server, it can determine the first memory space corresponding to the IPC object that occupies the largest memory space among the non-recyclable IPC objects (as an example of inter-process communication messages) stored in the memory space of the server (the IPC object that occupies the largest memory space is usually the IPC object that causes the memory space abnormality of the server, where the size of the memory space occupied by the IPC object can be viewed by the corresponding tools in the virtual machine, for example, the JVM can view the size of the memory space occupied by each IPC object during the GC recovery process), and determine the first client corresponding to the first memory space based on the life cycle of the first memory space (for example, the timestamp of allocating the first memory space (as an example of the first timestamp)) and the first corresponding relationship (that is, the first memory space abnormality is caused by the first client).

[0075] In this way, the electronic device can release the first memory space by controlling the first client or adjusting the thread call of the first client. Alternatively, the electronic device can store the corresponding relationship between the first memory space anomaly and the first client, so that the developer can determine that the cause of the first memory space anomaly is an improper thread call of the first client based on this relationship, and thus adjust or optimize the corresponding code of the first client.

[0076] Specifically, after the server of the electronic device receives the communication message of the inter-process communication, it can determine the first correspondence in the process of allocating the inter-process communication message to the corresponding service and processing the inter-process communication message, where the first correspondence may include, for example: the client information, the server information (the client information and the server information can serve as examples of the first sub-correspondence), and the correspondence of the memory space allocation information (as an example of the second sub-correspondence).

[0077] For example, Table 1 shows a table of a first correspondence relationship in an embodiment of the present application.

[0078] Table 1

[0079]

[0080]

[0081] It can be understood that the contents of the client information, the server information, and the memory space allocation information can be, for example, as shown in Table 1, wherein the client identifier can, for example, include the client thread name or the client thread identifier, and the thread information (as an example of a server thread) is the information of the thread that transmits the client's IPC message on the server (for example, the thread identifier).

[0082] The interface identifier is the identifier of the service interface corresponding to the corresponding service on the server side.

[0083] The start timestamp and the end timestamp are the start timestamp and the end timestamp of the corresponding service (or service interface) being called on the server side.

[0084] The allocation timestamp is the timestamp when the server applies for memory space to store the IPC object.

[0085] The memory space for storing IPC objects (as an example of a memory subspace) is the memory space that the server applies for in the heap memory in order to store the IPC objects.

[0086] It can be understood that in Table 1, the thread information in the server information (such as the binder thread) and the thread information in the memory space allocation information are the same thread, that is, the thread used to transmit the client's IPC message to the interface corresponding to the corresponding service on the server. However, since the same thread can interact with interfaces corresponding to multiple services on the server in different time periods. Therefore, after determining the first memory space, based on the thread information, it is impossible to determine which service the first memory space corresponds to. Therefore, the first service corresponding to the first memory space can be determined by the timestamp of the allocated memory space and the start timestamp and end timestamp of the call of the interface corresponding to each service.

[0087] For example, when an electronic device detects an anomaly in a first memory space, it can determine the first thread information corresponding to the first memory space based on a first correspondence. Since the thread information in the memory space allocation information corresponds to the thread information in the server-side information, the start and end timestamps of the calls to the interfaces of each service corresponding to the first thread information on the server-side can be determined using the first thread information corresponding to the first memory space. Then, based on the start and end timestamps of the calls to the interfaces of each service, the interface of the first service whose start and end timestamps include the timestamp of the allocation of the first memory space is determined. The electronic device then obtains information about the first client corresponding to the interface of the first service. After determining that the first client caused the server-side memory space anomaly, the electronic device can control the first client, for example, by prohibiting the first client from calling the server-side service, limiting the duration of the first client's calls to the server-side service, or limiting the memory space occupied by the first client's inter-process communication messages on the server-side. This can prevent the server-side memory anomaly from occurring again.

[0088] Through the above scheme, when the electronic device detects a memory space abnormality, the client that caused the memory space abnormality can be specifically determined based on the first corresponding relationship and the allocation timestamp of the first memory space, so as to manage the corresponding client and avoid abnormalities in the memory space of the electronic device.

[0089] In some embodiments, the information of the first thread may be, for example, the identifier of the first thread. Since the first thread can be reused, multiple services (binder services) on the server side may call the same first thread at different times. Therefore, multiple services may be determined by the identifier of the first thread. At this time, the first service can be determined by the relationship between the timestamp of the allocated first memory space and the start timestamp and end timestamp of the interface corresponding to the corresponding service being called. For example, if the first timestamp of the allocated first memory space is between the start timestamp and end timestamp of the interface of a service being called, the service can be determined to be the first service, and the client calling the first service can be determined through the port data of the first service, and the information of the client can be obtained.

[0090] In some embodiments, when an exception occurs in the server's memory space, there may be multiple clients calling the server at the same time. Therefore, the client that occupies the largest amount of server's memory space can be regarded as the client that caused the server's memory space exception.

[0091] The following describes the process of identifying the client that caused the server's memory space exception.

[0092] Figure 3 According to an embodiment of the present application, a flowchart for implementing the method of locating a client that causes a memory space abnormality on a server is shown.

[0093] For example, in the embodiments of the present application, the execution subjects of the following processes can all be electronic devices. When introducing each process, the execution subjects of each process are not limited. It should be noted that the present application does not limit the specific form of the electronic device. The electronic device can be a mobile phone, a laptop computer, a tablet, a large-screen device, a wearable device (for example, a watch, smart glasses, a helmet), a desktop computer, an augmented reality (AR) / virtual reality (VR) device, a personal digital assistant (PDA), and other devices. In the following, a mobile phone is used as an example of the electronic device 100.

[0094] like Figure 3 As shown, the process includes:

[0095] S301 : During IPC communication, record a first correspondence between different clients, memory spaces allocated to the clients, and a timestamp of allocating the memory spaces.

[0096] For example, in some embodiments of the present application, during IPC communication via a binder mechanism, the electronic device may record a first correspondence between different clients, memory spaces allocated to the clients, and a timestamp of allocating the memory spaces.

[0097] For example, the first correspondence may include: client information, server information, and memory space allocation information.

[0098] Referring to Table 1, the client information may include, for example: a thread name or a thread identifier of the client.

[0099] The server information may include, for example: information about the thread that transmits the client's IPC message (such as the thread identifier), the identifier of the interface corresponding to the server's service, and the start and end timestamps of the call of the server's service.

[0100] The memory space allocation information may include, for example, the timestamp of the memory space allocated by the server for the data carried in the IPC message of the client, and information about the thread that transmits the IPC message.

[0101] For example, Figure 4 According to some embodiments of the present application, a schematic diagram of a binder communication process is shown.

[0102] like Figure 4 As shown, the client's business threads include business threads 1 to 4. After receiving the business threads, the server can establish a binder thread to transmit the business threads to the corresponding binder interface. For example, in some embodiments of the present application, the server can create up to 15 binder threads, and the binder threads 1 to binder 15 can simultaneously process the data sent by the client's business threads, thereby improving the processing efficiency of the business threads.

[0103] After the binder thread transmits the IPC message of the business thread to the binder interface, the server can record the client information corresponding to the IPC message received by the binder interface and the server information corresponding to the binder interface.

[0104] For example, refer to Figure 4, after the IPC message sent by business thread 3 is transmitted to binder interface 1 by binder thread 1. The client information that the server can record includes the identifier of business thread 3. The server information recorded by the server includes the identifier of binder thread 1, the identifier of binder interface 1, and the start timestamp and end timestamp of the call of binder interface 1, etc. (it can be understood that the end timestamp can be recorded after the business thread 3 calls binder interface 1). After the binder service 1 corresponding to binder interface 1 receives the IPC message, it can package the IPC message into an object and apply to the server for memory space to store the object. The server can record the allocation information of the memory space. For example, the allocation information includes the timestamp of allocating the memory space and the binder thread 1 that transmits the IPC message.

[0105] S302: Detecting an abnormality in the memory space of the server, determining a first memory space corresponding to the IPC object occupying the largest memory space among the non-recyclable IPC objects stored in the memory space of the server.

[0106] For example, in some embodiments of the present application, the server of the electronic device can detect the usage of its memory space in real time. If the memory space used by the server exceeds a space threshold (e.g., 80% to 100% of the corresponding memory space), the electronic device can determine that the memory space of the server is abnormal.

[0107] For example, in binder communication, the server packages IPC messages into objects and stores them in the heap memory. The electronic device can view the heap memory usage of the server through a profiler. If the memory space being used by the server exceeds the space threshold of the heap memory, the memory space that occupies the largest heap memory space can be selected as the first memory space, and it can be determined that there is an abnormality in the memory space.

[0108] For example, when the server's heap memory is full, the JVM can perform GC to reclaim the memory space occupied by objects in completed threads, thereby avoiding server-side heap memory overflow. For example, in some embodiments of the present application, the JVM uses a reachability analysis algorithm to analyze reclaimable memory space.

[0109] The reachability analysis algorithm is a standard algorithm used in the JVM to determine whether an object is alive. Its basic idea is to use a series of objects called garbage collection roots (GC roots) as a starting point and then search downward from these nodes. The path traversed by the search is called a reference chain. If an object has no reference chain connecting it to the GC roots (i.e., the object is unreachable from the GC roots), the object is considered unavailable and can be recycled.

[0110] For example, Figure 5 According to some embodiments of the present application, a schematic diagram of reference relationships of objects reclaimed by GC is shown.

[0111] As you can understand, when an object is created on the server, the JVM allocates memory for it in the heap and returns a reference to that memory (usually a pointer to a memory address). When a field or method of an object (such as Object A) is set to reference another object (such as Object B), a reference relationship is established between Object A and Object B. This reference relationship between objects allows for the creation of analysis chains.

[0112] like Figure 5 As shown, in the GC root, it can be a collection of reference objects that can be accessed by the running thread. Then, the objects directly referenced by the GC roots are called child nodes of the GC roots, such as object 1. Similarly, the objects directly referenced by object 1 are child nodes of object 1, such as object 2 and object 3, where object 2 and object 3 have an indirect reference relationship with GC roots (that is, object 2 or object 3 has a reference chain to GC roots). The objects referenced by object 3 are child nodes of object 3, such as object 4. If there is an object that is not directly or indirectly referenced by GC roots (for example, the object does not have any reference chain to GCroots), the memory space occupied by the object can be reclaimed by the JVM. For example, object 5, object 6 and object 7 are not directly or indirectly referenced by GC root, so the memory space corresponding to object 5, object 6 and object 7 can be reclaimed by the JVM. It can be understood that in some embodiments of the present application, if the objects of a client's business thread continue to occupy the memory space of the server, the objects directly or indirectly referenced by the business thread are always in the applied state. In other words, the object always has a reference chain to GC roots, so the JVM cannot reclaim the memory space occupied by the object, which may cause memory leaks on the server side.

[0113] In some embodiments of the present application, after the electronic device detects an abnormality in the memory space of the server, it can determine which objects in the heap memory of the server are occupying the memory space through the reference relationship between each object, and determine the size of the memory space occupied by each object (the size of the memory space occupied by each object can be determined in the GC recovery mechanism). Then, the electronic device can select the largest occupied memory space as the first memory space. It can be understood that the object corresponding to the largest occupied memory space belongs to the object that needs to be optimized, and the object may also be the cause of the memory leak. Therefore, the largest occupied memory space can be used as the first memory space.

[0114] S303: Determine a first client corresponding to the first memory space based on the life cycle of the first memory space and the first corresponding relationship.

[0115] For example, in some embodiments of the present application, after determining that there is an abnormal first memory space, the client that caused the abnormality of the first memory space can be determined based on the life cycle of the first memory space (for example, the timestamp of allocating the first memory) and the first correspondence.

[0116] For example, refer to Figure 5 In the reference relationship of each object, each object also includes the allocation information of the corresponding memory space. The allocation information of the memory space includes the timestamp when the memory space is allocated to each object and the information of the thread that transmits the IPC message of the corresponding object.

[0117] It is understood that after determining the thread information, the interfaces of each service on the server connected to the thread information can be determined based on the first correspondence. For example, the thread corresponding to the first memory space is binder thread 1. Then, in the first correspondence, it is determined which binder interfaces have received IPC messages transmitted by binder thread 1, that is, the identifier of the binder thread corresponding to the first memory space = the identifier of the binder thread transmitted to the binder interface.

[0118] For example, the binder interface 1, binder interface 2, and binder interface 3 of the server all receive the IPC message transmitted by the binder thread 1. Therefore, it can be determined which binder interface receives the IPC message according to the timestamp of allocating the first memory space.

[0119] For example, Figure 6 According to some embodiments of the present application, a schematic diagram of a start timestamp and an end timestamp of a binder interface being called is shown.

[0120] After determining that binder interface 1, binder interface 2 and binder interface 3 have all received the IPC message transmitted by binder thread 1, it can be determined based on the start timestamp and end timestamp of each binder interface being called to determine which binder interface processes the IPC message of the object corresponding to the first memory space.

[0121] Reference Figure 6 , the start timestamp of binder interface 1 being called is T10, and the end timestamp is T11. The start timestamp of binder interface 2 being called is T20, and the end timestamp is T21. The start timestamp of binder interface 3 being called is T30, and the end timestamp is T31. The timestamp of allocating the first memory space is Tm. Among them, the timestamps of T10, T11, T20, T21, T30, and T31 are arranged in sequence. Tm is between T10 and T11, that is, T10≤Tm≤T11. In other words, the first memory space is applied for between the start and end of binder interface 1 being called. Therefore, it can be understood that the first memory space is the memory space applied for during the process of binder interface 1 being called. Then, based on the information of the client corresponding to binder interface 1, the first client corresponding to the first memory space can be determined.

[0122] With the above solution, when the memory space on the server side of an electronic device is abnormal, the electronic device can determine the client causing the abnormal server side memory space based on the client information, server information, and memory space allocation information recorded during IPC communication. The electronic device can then manage and control the corresponding client or adjust the client's threads to prevent memory leaks on the server side.

[0123] In other embodiments, the electronic device can also directly send the recorded first correspondence to the server or the debugging device. The debugging device or the server determines the client that causes the abnormality in the memory space of the server side of the electronic device based on the data recorded by the electronic device, that is, the process of S302 and / or S301 is completed by other devices. During the debugging process of the electronic device, the server or the debugging device detects whether the memory space of the corresponding application of the electronic device is abnormal. When the memory space of the corresponding application of the electronic device is abnormal, the above-mentioned first correspondence can be obtained from the electronic device. The server or the debugging device can determine the client that causes the abnormality in the memory space of the corresponding application based on the first correspondence. The developer can then adjust or optimize the code corresponding to the corresponding client to avoid the problem of memory leakage on the server side of the electronic device.

[0124] Next, we introduce the software system for electronic devices to perform IPC communication based on the binder mechanism.

[0125] Figure 7 According to an embodiment of the present application, a schematic block diagram of a system software architecture of an electronic device is shown.

[0126] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present invention takes the layered architecture as an example to illustrate the software structure of the electronic device.

[0127] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other via software interfaces. In some embodiments, the software system of an electronic device is divided into four layers: application layer, framework layer, native layer, and kernel layer, from top to bottom.

[0128] like Figure 7 As shown in Figure 1, the application layer is the direct interface for users to interact with the mobile phone system. It is responsible for providing the user interface, including icons, menus, dialog boxes, etc. of various application programs, so that users can interact with the mobile phone system conveniently.

[0129] In some embodiments of the present application, the application layer may include, for example, client and server applications, which may include, for example, camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, desktop, information and other applications.

[0130] In some embodiments of the present application, the client process and the server process run in their own application space. The running space of each application is independent and cannot directly transmit messages. However, the client and server can perform IPC communication.

[0131] For example, the client's client proxy can process requests from the client and convert them into the format of binder IPC. The requested data can be encapsulated into objects (such as parcel objects). Then the client proxy can send IPC messages to the binder driver of the kernel layer through the interface provided by the framework layer and the binder IPC implementation of the local layer.

[0132] The server stub can parse the request and data and call the actual processing logic provided by the server.

[0133] After the server processes the request data, the server stub can encapsulate the processing result into an object (such as a parcel object) and return it to the binder driver through the local layer binder IPC implementation.

[0134] The framework layer provides an application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0135] For example, in some embodiments of the present application, the framework layer may include an interface defined in the Android Interface Definition Language (AIDL), and the AIDL interface may transmit IPC messages, for example, data sent by the client agent or server stub may be transmitted to the native layer.

[0136] The native layer can act as a bridge for binder communication, transmitting IPC messages (or client requests) from the framework layer to the binder driver through the binder interface. For example, the native layer can include a binder library and a service manager (SM).

[0137] Among them, the binder library encapsulates all operations on the binder driver and serves as a bridge for the interaction between the upper-layer application and the binder driver. This includes low-level operations such as sending and receiving IPC messages. After the binder library receives the IPC message, it can encapsulate the IPC message into a transaction object and send the transaction object to the binder driver through the driver interface. In some embodiments of the present invention, the binder library can also record Figure 4 In the embodiment, the client information and the server information in the binder communication process are used to determine the first correspondence between the client and the allocated memory space through the client information and the server information.

[0138] The Service Manager (SM) manages service processes. Each service process registers its cross-process binder with the SM and stores a reference to the corresponding binder. Clients can query the SM by name for the desired service, and the SM returns a reference to the binder for the server. The SM is also a process, but each process that needs to communicate with the SM knows the SM's reference.

[0139] The kernel layer is the layer between hardware and software. The kernel layer includes at least CPU driver, GPU driver, display driver, sensor driver, camera driver, etc.

[0140] For example, in some embodiments of the present application, the kernel layer includes a binder driver and a driver interface provided by the binder driver.

[0141] After receiving the client's transaction object (or the transaction object encapsulated by the binder library based on the client's IPC message), the binder driver can find the server process requested by the client based on the transaction object and route the transaction object to the server process through the process management and memory management mechanisms.

[0142] After the server-side stub of the server process receives the client's transaction object provided by the binder driver (for example, by processing the transaction object through the binder thread), it can call the server's pre-processing logic to process the transaction object. In some embodiments of the present application, the server process requires the JVM virtual machine to allocate corresponding memory space during its operation. In the process of applying for memory space for the transaction object on the server side, the JVM can record the timestamp of the allocation of the corresponding memory space and, in the server process, the identifier of the binder thread that transmits the transaction object, so as to establish a first correspondence between the client and the allocated memory space based on the timestamp of the memory space allocation and the identifier of the corresponding binder thread.

[0143] After the server processes the transaction object, if it needs to return the result to the client, the server stub can encapsulate the processing result into an object (such as a parcel object) and return it to the binder driver through the local layer binder IPC implementation (such as the binder library, etc.).

[0144] After the binder driver receives the processing result returned by the server, the binder driver can route the processing result to the client process through the process management and memory management mechanism.

[0145] The client proxy receives the processing results and parses them into a format that the client application can understand. Finally, the client receives the processing results and performs subsequent operations as needed.

[0146] The following takes a mobile phone as an example to describe in detail the electronic devices involved in some embodiments of the present invention.

[0147] Figure 8 According to an embodiment of the present application, a structural diagram of an electronic device is shown.

[0148] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0149] It should be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0150] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0151] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0152] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0153] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.

[0154] The charging management module 140 is configured to receive charging input from a charger.

[0155] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the display 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0156] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0157] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.

[0158] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0159] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.) or displays an image or video through the display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0160] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0161] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a glass cover 10 and a display panel 20. Display panel 20 can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini-LED, a Micro-LED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 can include one or N display screens 194, where N is a positive integer greater than 1.

[0162] The camera 193 is used to capture still images or videos.

[0163] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0164] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.

[0165] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0166] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting it into or removing it from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0167] An embodiment of the present application further provides a program product, which, when executed on an electronic device, can enable the electronic device to implement the methods provided in the aforementioned embodiments.

[0168] An embodiment of the present application further provides a readable storage medium, in which one or more programs are stored. When the one or more programs are executed by an electronic device, the electronic device implements the methods provided in the aforementioned embodiments.

[0169] The various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.

[0170] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor, a microcontroller, an application specific integrated circuit, or a microprocessor.

[0171] Program code can be implemented with a high-level programming language or an object-oriented programming language to communicate with the processing system. Where necessary, program code can also be implemented in assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0172] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried by or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed over a network or via other computer-readable media. Thus, a machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), including but not limited to floppy disks, optical disks, optical discs, compact disc-read only memory (CD-ROMs), magneto-optical disks, read-only memory (ROM), random-access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic or optical cards, flash memory, or tangible machine-readable storage for transmitting information via the Internet in the form of electrical, optical, acoustical, or other propagated signals (e.g., carrier waves, infrared signals, digital signals, etc.). Thus, a machine-readable medium includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a form readable by a machine (e.g., a computer).

[0173] In the accompanying drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or order may not be required. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of a structural or method feature in a particular figure does not imply that such feature is required in all embodiments, and in some embodiments, such features may not be included or may be combined with other features.

[0174] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems raised by this application. In addition, in order to highlight the innovative part of this application, the above-mentioned device embodiments of this application do not introduce units / modules that are not closely related to solving the technical problems raised by this application. This does not mean that other units / modules do not exist in the above-mentioned device embodiments.

[0175] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "including a" does not exclude the presence of other identical elements in the process, method, article or device that includes the element.

[0176] Although the present application has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the application.

Claims

1. A process anomaly detection method, applied to a first electronic device, characterized in that: The first electronic device includes at least one client and server, and the method includes: Detecting an abnormality in the memory space of the server, and determining a first memory subspace in the memory space of the server that causes the abnormality in the memory space of the server, wherein the memory space of the server includes multiple memory subspaces, the multiple memory subspaces include the first memory subspace, and each of the memory subspaces stores an inter-process communication message of the client corresponding to each memory subspace; Based on a pre-stored first correspondence and a first timestamp for allocating the first memory subspace, a first client corresponding to the first memory subspace is determined, wherein the first correspondence includes a correspondence between the client and the memory subspace and an allocation timestamp for allocating the memory subspace.

2. The method according to claim 1, characterized in that The first correspondence includes a first sub-correspondence and a second sub-correspondence, wherein the first sub-correspondence includes a correspondence between a client identifier of the client, an interface identifier of a service interface in the server called by the client, a start timestamp and an end timestamp of the service interface being called by the client, and a thread identifier of a server thread that transmits an inter-process communication message of the client; The second sub-correspondence is a correspondence between the memory subspace, the allocation timestamp of the memory subspace, and the thread identifier of the server thread corresponding to the memory subspace.

3. The method according to claim 2, characterized in that The determining, based on the pre-stored first correspondence and the first timestamp of allocating the first memory subspace, the first client corresponding to the first memory subspace includes: Obtaining a first thread identifier and a first timestamp corresponding to the first memory space from the second sub-correspondence; Based on the first thread identifier, acquiring at least one first interface identifier corresponding to the first thread identifier from the first sub-correspondence; Based on the first sub-correspondence, the interface identifier of the corresponding called service interface is the first interface identifier, and the client corresponding to the first client identifier whose time period corresponds to the start timestamp and end timestamp of the called service interface and includes the first timestamp is determined as the first client.

4. The method according to claim 1, wherein The method also includes managing and controlling the first client.

5. The method according to claim 1, wherein Determining a first memory subspace in the memory space of the server that causes an abnormality in the memory space of the server includes: The memory subspace that occupies the largest storage space among the multiple memory subspaces is used as the first memory subspace.

6. The method according to claim 1, characterized in that The detecting that the memory space of the server is abnormal includes: The memory space occupied by the server exceeds the space threshold.

7. A process anomaly detection method, characterized in that: include: The first electronic device obtains a first correspondence between each client and a memory subspace, and an allocation timestamp of the memory subspace, which is pre-stored in the first electronic device, wherein the memory subspace is a memory space in which a server of the first electronic device stores inter-process communication messages of the client; The first electronic device sends the first correspondence and the usage data of the memory space of the server to the second electronic device; The second electronic device detects, based on usage data of the memory space of the server, that the memory space of the first electronic device is abnormal; The second electronic device determines, from the memory subspaces, a first memory subspace that causes the abnormality in the memory space of the server; The second electronic device determines the first client corresponding to the first memory space based on the first timestamp of allocating the first memory space and the first corresponding relationship.

8. A process anomaly detection method, characterized in that: include: The first electronic device detects an abnormality in a memory space of a server in the first electronic device, and determines a first memory subspace in the memory space of the server that causes the abnormality in the memory space of the server, wherein the memory space of the server includes a plurality of memory subspaces, the plurality of memory subspaces including the first memory subspace, and each of the memory subspaces stores an inter-process communication message of a client corresponding to each memory subspace; The first electronic device sends the identifier of the first memory subspace and a pre-stored first correspondence to the second electronic device, wherein the first correspondence includes a correspondence between the client and the memory subspace and a timestamp for allocating the memory subspace; The second electronic device determines the first client corresponding to the first memory subspace based on the first timestamp of allocating the first memory subspace and the first corresponding relationship.

9. An electronic device, characterized in that: include: a memory for storing instructions; At least one processor is configured to execute the instructions so that the electronic device implements the method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that The readable storage medium stores instructions, and when the instructions are executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 6.

11. A computer program product, characterized in that When the computer program product is run on a device, the device is caused to perform the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • A relatively reliable inter-process communication method based on Boost

    CN109086146A

  • Shared multi-channel process communication memory structure and method

    CN110532109A

  • Communication method and device

    CN116361026A

  • Process communication method, apparatus and device, and readable storage medium

    CN117170900A

  • Method for inter-process communication, related computing device and storage medium

    US20220300356A1