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

By recording the correspondence between the client and the memory subspace and the timestamp, abnormal clients can be accurately located and managed, solving the problem of memory anomalies in inter-process communication and improving the stability and performance of the application.

CN120743587BActive Publication Date: 2026-04-28HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-08-07
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

During inter-process communication, improper process settings can lead to abnormal server-side memory space, resulting in memory leaks or excessive memory usage by a single object, which can affect application performance and potentially cause crashes. Existing technologies make it difficult to accurately pinpoint the cause of these abnormalities.

Method used

By recording the correspondence between clients and memory subspaces and the allocation timestamps, the clients causing memory space anomalies can be identified, and then they can be managed or optimized, including disabling service calls and limiting memory usage.

Benefits of technology

It effectively avoids server-side memory anomalies, improves application stability and performance, and prevents memory leaks and crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743587B_ABST
    Figure CN120743587B_ABST
Patent Text Reader

Abstract

The application relates to the terminal technical field, in particular to a process exception detection method, a readable storage medium, a program product and an electronic device. The process exception detection method is applied to the electronic device. In the process of inter-process communication between the client and the server of the electronic device, the server can obtain a memory subspace occupied by the inter-process communication message corresponding to the client and the client in the server, and a first corresponding relationship between the memory subspace and an allocation time stamp. After the memory space of the server appears an exception, the electronic device can determine a first client corresponding to a first memory subspace causing the memory space exception of the server based on the first corresponding relationship, so as to control the first client, thereby avoiding the problem that the memory space exception of the server continues to occur.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal technology, and in particular to a method for detecting process anomalies, a readable storage medium, a program product, and an electronic device. Background Technology

[0002] Currently, data transmitted during inter-process communication (IPC) in electronic devices consumes a portion of the corresponding application's memory. If the process performing IPC is improperly configured, it can cause abnormal data consumption on the server side (hereinafter referred to as memory space anomaly). For example, continuously consuming application memory during IPC can lead to memory leaks (unrecoverable memory space), or a single piece of data (or object) transmitted during IPC might consume a large amount of server memory. However, the available memory space of an application is limited. If the application experiences memory space anomalies, the available memory will decrease, slowing down IPC and causing application lag. Furthermore, insufficient memory can also lead to app crashes. Summary of the Invention

[0003] This application provides a process anomaly detection method, a readable storage medium, a program product, and an electronic device, so as to identify the client that caused the memory space anomaly on the server side of the electronic device, so as to manage or optimize the corresponding client.

[0004] In a first aspect, embodiments of this application provide a process anomaly detection method applied to a first electronic device. The first electronic device includes at least one client and one server. The method includes: detecting an anomaly in the server's memory space; determining a first memory subspace that caused the anomaly in the server's memory space, wherein the server's memory space includes multiple memory subspaces, the multiple memory subspaces include the first memory subspace, and each memory subspace stores inter-process communication messages of the client corresponding to each memory subspace; determining a first client corresponding to the first memory subspace based on a pre-stored first correspondence relationship and a first timestamp for allocating the first memory subspace, wherein the first correspondence relationship includes a correspondence between the client and the memory subspace and the allocation timestamp for allocating the memory subspace.

[0005] For example, in some embodiments of this application, during inter-process communication between the client and server of the electronic device, the server can record a corresponding first correspondence. If the server's memory space becomes abnormal, the electronic device can determine the first client causing the abnormality based on the first correspondence, so as to manage and optimize the first client.

[0006] In one possible implementation of the first aspect above, the first correspondence includes a first sub-correspondence and a second sub-correspondence. The first sub-correspondence includes the correspondence between the client's client identifier, the interface identifier of the service interface in the server called by the client, the start and end timestamps of the service interface being called by the client, and the thread identifier of the server thread transmitting the client's inter-process communication messages. The second sub-correspondence is the correspondence between the memory subspace, the memory subspace allocation timestamp, and the thread identifier of the server thread corresponding to the memory subspace.

[0007] For example, in some embodiments of this application, since the same service interface of the server can be called by multiple clients, the first sub-correspondence of 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 times, 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 and end timestamps 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 thread identifier of the server thread can be used to map memory subspaces to multiple service interfaces. Based on the allocation timestamp of the memory subspace, and the start and end timestamps of the service interface being called by the client, the service interface corresponding to that memory subspace can be uniquely identified from among the multiple service interfaces, thus determining the server corresponding to the memory subspace. Therefore, the first and second sub-correspondences can uniquely identify the client corresponding to a memory subspace. Furthermore, after determining that a memory subspace is causing a memory space anomaly on the server, the client corresponding to that memory subspace can be identified.

[0009] In one possible implementation of the first aspect above, determining the first client corresponding to the first memory subspace based on the pre-stored first correspondence and the first timestamp of the allocated first memory subspace includes: obtaining the first thread identifier and the first timestamp corresponding to the first memory subspace from the second sub-correspondence; obtaining at least one first interface identifier corresponding to the first thread identifier from the first sub-correspondence based on the first thread identifier; and determining the client corresponding to the first client identifier of the service interface being called as the first interface identifier and the time period corresponding to the start and end timestamps of the service interface being called, including the first timestamp, as the first client based on the first sub-correspondence.

[0010] In one possible implementation of the first aspect described above, the method further includes managing the first client.

[0011] For example, in some embodiments of this application, after determining that the first client has caused a memory space anomaly on the server, the electronic device can manage the first client, for example, by prohibiting the first client from calling the server's services, limiting the duration of the first client's calls to the server's services, or limiting the memory space occupied by the first client's inter-process communication messages on the server, in order to prevent the server from experiencing memory anomalies again.

[0012] In one possible implementation of the first aspect above, determining the first memory subspace that causes the memory space anomaly in the server's memory space includes: taking the memory subspace with the largest storage space among multiple memory subspaces as the first memory subspace.

[0013] For example, in some embodiments of this 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 managed. Therefore, in the event of an anomaly in the server's memory space, the memory subspace occupying the largest amount of storage space can be determined as the first memory subspace, and then the client corresponding to the first memory subspace can be determined.

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

[0015] Secondly, this application provides a process anomaly detection method, comprising: a first electronic device acquiring a first correspondence between each client and a memory subspace, and the allocation timestamp of the memory subspace, pre-stored in the first electronic device, wherein the memory subspace is the memory space of the server of the first electronic device storing inter-process communication messages of the clients; the first electronic device sending the first correspondence and the memory space usage data of the server to a second electronic device; the second electronic device detecting an anomaly in the server's memory space based on the memory space usage data of the server; the second electronic device determining the first memory subspace that caused the anomaly in the server's memory space from the memory subspace; and the second electronic device determining the first client corresponding to the first memory subspace based on the first timestamp of the allocation of the first memory subspace and the first correspondence.

[0016] In some embodiments of this application, the first electronic device can send a first correspondence stored during inter-process communication between the client and the server, along with the server's memory space usage data, to a second electronic device. Based on the server's memory space usage data, the second electronic device can determine whether there is an anomaly in the server's memory space. The usage data can, for example, be the server's memory space usage status. If there is an anomaly in the server's memory space, the second electronic device can identify the first client causing the anomaly based on the first correspondence, and the second electronic device can optimize and adjust that first client.

[0017] Thirdly, this application provides a process anomaly detection method, comprising: a first electronic device detecting an anomaly in the server's memory space, determining a first memory subspace causing the anomaly from the server's memory space, wherein the server's memory space includes multiple memory subspaces, the multiple memory subspaces including the first memory subspace, and each memory subspace stores inter-process communication messages of the client corresponding to each memory subspace; the first electronic device sending the identifier of the first memory subspace and a pre-stored first correspondence relationship to a second electronic device, wherein the first correspondence relationship includes a correspondence relationship between the client and the memory subspace and the timestamp of the memory subspace allocation; the second electronic device determining the first client corresponding to the first memory subspace based on the first timestamp of the first memory subspace allocation and the first correspondence relationship.

[0018] It is understood that in some embodiments of this application, after the first electronic device detects an anomaly in the server's memory space, it can send the first correspondence and the identifier of the first memory subspace to the second electronic device. The second electronic device determines the first client that caused the anomaly in the server's memory space based on the first correspondence, and optimizes or manages the first client.

[0019] Fourthly, this 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 methods provided in the first aspect and any possible implementations of the first to third aspects. The beneficial effects achievable in the fourth aspect can be referenced to the beneficial effects of the methods provided in any embodiment of the first to third aspects, and will not be repeated here.

[0020] Fifthly, this application provides a computer-readable storage medium storing instructions that, when executed by a device, cause a computer to implement the methods provided in the first aspect and any possible implementations of the first to third aspects. The beneficial effects achievable in the fifth aspect can be found in the beneficial effects of the methods provided in any embodiment of the first to third aspects, and will not be repeated here.

[0021] Sixthly, this application provides a computer program product that, when run on a device, enables the device to implement the methods provided in the first to third aspects and any possible implementation of the first aspect. The beneficial effects achievable in the sixth aspect can be found in the beneficial effects of the methods provided in any embodiment of the first to third aspects, and will not be repeated here. Attached Figure Description

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

[0023] Figure 2 A schematic diagram of an electronic device running an application is shown;

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

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

[0026] Figure 5 According to some embodiments of this application, a schematic diagram of the reference relationship of objects to be garbage collected is shown;

[0027] Figure 6 According to some embodiments of this application, a schematic diagram is shown of the start and end timestamps of the binder interface being invoked;

[0028] Figure 7 A schematic block diagram of the system software architecture of an electronic device is shown according to an embodiment of this application;

[0029] Figure 8 A schematic diagram of the structure of an electronic device is shown according to an embodiment of this application. Detailed Implementation

[0030] The illustrative embodiments of this application include, but are not limited to, process anomaly detection methods, readable storage media, program products, and electronic devices.

[0031] For ease of understanding, some of the terms and related technologies used in this application are explained below.

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

[0033] IPC (Inter-Process Communication) refers to the process of data exchange between two or more processes. A process is an independent unit for system resource allocation and scheduling, and it is 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. These include sockets, pipes, shared memory, message queues, and binder communication.

[0035] 2. Binder mechanism.

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

[0037] A client refers to a client process; this is a relative term, meaning any process that initiates a process request can be considered a client process. A server refers to a service process; this is also a relative term, meaning any process requested to perform a service can be called a server process. The Service Manager (SM) is used to manage service processes. Each service process must register its cross-process binders in the SM and store references to the corresponding binders. A client can query the SM by name for the service it wants, and the SM will return a reference to a binder for that server. The binder driver acts as an intermediary in the actual communication process. For example, it may relay data that needs to be transmitted.

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

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

[0040] Service registration: 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) in the SM. The binder driver can create an entity node in the kernel and a reference to the entity in the SM for the binder service, and packages the service name and the newly created reference and sends it to the SM. After receiving it, the SM can fill the service name and the SM's reference to the entity into a lookup table.

[0042] Obtaining services: Before using a certain server, the client needs to obtain the corresponding server information from SM.

[0043] For example, a client can send a request to the binder driver to obtain a service. The client can query the name of the service it needs in the SM (Service Manager). Accordingly, the SM can return a reference to an entity of a binder service on the server side corresponding to that service. The client can then communicate with the server using this reference.

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

[0045] During IPC communication in an application, corresponding memory space needs to be allocated for the IPC data to process it. In some electronic devices, the Java Virtual Machine (JVM) can manage the application's memory space. For example, the JVM can automatically release unused memory resources through garbage collection (GC) to avoid problems such as memory leaks and memory overflows.

[0046] Taking the JVM allocating memory space for the server as an example, during server runtime, the JVM can allocate heap memory for the server to store object instances and arrays. In some embodiments, the JVM can also allocate other memory spaces for the server (such as a program counter, Java Virtual Machine stack, etc.) for corresponding business operations. This application does not limit the memory space allocated by the JVM for the server. During IPC communication using the binder mechanism in electronic devices, after the client receives information from the server, it can send an IPC message to the binder interface provided by the server. After receiving the IPC message, the server corresponding to the binder interface can package the data in the IPC message into an object (e.g., package the IPC data into a parcel object) and store it in the heap memory allocated by the Java Virtual Machine for the server. After processing the message, the server can return the message to the client through the binder interface. Afterwards, the Java Virtual Machine can reclaim the memory space occupied by the IPC message through garbage collection (GC) to avoid memory leaks on the server side.

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

[0048] As mentioned earlier, when an application experiences memory space anomalies, it is not easy to pinpoint the specific cause of the anomaly, making it difficult to handle such anomalies.

[0049] The following describes the communication process of the binder mechanism.

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

[0051] For example, refer to Figure 1 The client may include, for example, 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 serves as a bridge for communication between the client and the binder service, defining the communication operations that can occur between them. The binder service handles requests from the client and returns the corresponding results. These results are transmitted to the client via the binder interface, enabling the client to invoke its provided methods.

[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 result 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 handle the business thread's IPC messages. For instance, 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 descriptors, method codes, etc.).

[0055] In some embodiments, the binder thread may not be destroyed when the business thread finishes its call, thus continuing to process IPC messages sent by the next business thread. In other words, the binder thread can be reused to improve the speed at which the server processes business threads.

[0056] For example, refer to Figure 1 Client-side business thread 1 can send IPC message 1 to the server. IPC message 1 includes information about the binder interface corresponding to the binder service called by business thread 1 (e.g., information about the called binder interface 1). Upon receiving IPC message 1, the server can create binder thread 1 to transmit it. Binder thread 1 determines which binder interface 1 to send IPC message 1 to based on the binder interface 1 information provided in IPC message 1. After receiving IPC message 1 through binder interface 1, binder service 1 can package it into object 1 and then request memory 1 from the server's heap memory to store object 1, allowing the server to process the data carried in IPC message 1. After client-side business thread 1 finishes calling binder service 1, the Java Virtual Machine can reclaim the corresponding memory 1 through garbage collection to ensure that the server's heap memory has sufficient space to store objects or instances.

[0057] It's understandable that the server can provide multiple 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 (e.g., binder interface 1 and binder interface 2). After receiving an IPC message, each binder service can package the IPC message into an object, allocate memory space for the object on the server, and then store the object in that memory space.

[0058] Understandable. Figure 1The IPC communication process of the binder mechanism shown 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's important to note that the Java Virtual Machine (JVM) has a limited amount of memory allocated to the server. If the client's business processes are improperly configured or malfunction, objects within client threads may continuously occupy server memory (for example, some client threads or tasks may have longer lifecycles than expected, causing objects within these threads or tasks to continuously occupy server memory; or client threads may not be properly canceled or completed, resulting in these objects continuously occupying server memory). Because these client thread objects are constantly referenced, the JVM cannot reclaim the heap memory occupied by these objects, causing a memory leak on the server and reducing the available memory. Alternatively, if a single object from a client thread or task occupies a large amount of server memory (indicating that the process or object needs optimization to reduce memory usage), it may reduce server processing efficiency (a large memory footprint for a single object prevents the server from processing multiple processes or tasks simultaneously).

[0060] For example, if the process corresponding to client A continuously calls the service of server B due to improper configuration, it can cause a memory leak on server B, reducing its available memory. If client C calls server B's service during this process, server B may not have enough memory to process client C's communication messages, leading to client C crashing. Furthermore, if the memory occupied by server B exceeds the memory allocated to server B by the Java Virtual Machine, it may also cause server B to experience an out-of-memory (OOM) error.

[0061] For example, Figure 2 A schematic diagram of an electronic device running an application 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, laptop computer, tablet, large-screen device, wearable device (e.g., watch, smart glasses, helmet), desktop computer, augmented reality (AR) / virtual reality (VR) device, personal digital assistant (PDA), etc. The following uses a mobile phone as an example of electronic device 100.

[0063] Reference Figure 2 In some cases, while playing games on electronic device 100, users can also display a chat window to chat with other users. For example, electronic device 100 may currently display game interface 10, which includes a chat window 11. In some embodiments of this application, other user programs are running in the background of electronic device 100; therefore, there are multiple threads of user programs interacting with system applications in the user space of electronic device 100.

[0064] For example, the application corresponding to game interface 10 (hereinafter referred to as the game application) and the application corresponding to chat window 11 (hereinafter referred to as the chat application) run simultaneously in the foreground. These two applications have their own user interface thread and rendering thread.

[0065] It is understandable that both game and chat applications require frame drawing to display their interfaces (e.g., game interface 10 and chat window 11) on the screen of electronic device 100. These two applications generate frame data and need to transmit this data via a binder thread to the corresponding process within the system application (e.g., surfaceflinger) so that surfaceflinger can composite and display images based on the frame data from these two applications. In other words, both applications need to request a binder thread from surfaceflinger. Furthermore, in this case, there may also be some dynamically identified frame-dependent threads within the operating system of electronic device 100.

[0066] Therefore, when multiple applications run in the operating system of electronic device 100 in the foreground, multitasking concurrency and high load often occur. In this situation, inter-process communication is busy. When inter-process communication is busy, if a process continuously occupies the memory space of the system application, causing a memory leak in the system application, or if a single object of a process occupies a large amount of memory space, it may lead to a reduction in the available memory space for the system application. During binder communication, memory space needs to be allocated and managed, and insufficient memory space will cause these operations to become slow or unable to complete, easily resulting in application lag or crashes.

[0067] For example, refer to Figure 2 If the chat application continuously occupies the surface synthesis memory space due to improper settings, resulting in insufficient available memory space for surface synthesis, the game application's surface synthesis process will be slow, and the game interface 10 of the electronic device 100 will display a "Loading..." message 12. In other words, the game application is lagging. If the game application continues to be unable to retrieve data from surface synthesis, the game application may crash; for example, the electronic device 100 may crash from the game interface 10 and display the desktop interface 20.

[0068] Therefore, in some cases, if the server of electronic device 100 experiences a memory space anomaly, it is necessary to locate the client application causing the anomaly. This allows for the management of the corresponding application and the prevention of memory space anomalies on the server side of electronic device 100.

[0069] In some embodiments, call information for the binder interface can be traced by capturing the call stack. A call stack trace records a list of all active function calls (including their parameters and local variables) at a given point in a program's execution. Tracing the binder interface typically involves tracking the call history of these interface methods, such as how that part of the interface is called and by which methods or functions. For example, in the case of a memory leak on the server side, the leak point (the memory space occupied by an unreleased object) can be located, and the call stack of that memory space can be examined. Then, the call stack can be analyzed to identify which code paths created the object, thus tracing the corresponding binder interface. However, while capturing the call stack can pinpoint the binder interface corresponding to the application experiencing the memory leak, because the binder interface is shared, it may be called by multiple applications simultaneously. Therefore, if multiple clients are calling the binder service through the server-side binder interface during a server-side memory leak, capturing the call stack cannot pinpoint which specific application caused the binder server-side memory leak. Furthermore, capturing the call stack involves recording the method call sequence of the current thread, a process that consumes processor and memory resources and can potentially increase application response time. Therefore, capturing the call stack can impact the performance of memory allocation in system applications. For example, for Figure 2As shown, both the game application and the chat application are calling Surface Composites to composite and display images within the same timeframe. Therefore, both applications will call the binder interface provided by Surface Composites. If there is a memory leak in Surface Composites, capturing the call stack will reveal that both the game application and the chat application are calling the binder interface. However, it's still impossible to determine which application caused the memory leak, thus making it impossible to pinpoint the specific cause.

[0070] In summary, when an anomaly occurs in the client's memory space of an electronic device, it is not easy to locate the application causing the anomaly, and therefore it is not easy to manage that application.

[0071] In some embodiments of this application, a binder interface corresponding to a binder service can receive IPC messages from multiple clients simultaneously, 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 simultaneously.

[0072] For example, during IPC communication via the binder mechanism in an electronic device, the client can send a communication message (e.g., an IPC message) to the server. The server then establishes a thread (e.g., a binder thread) to transmit the communication message to the corresponding interface (e.g., the binder interface) of the relevant service (e.g., the 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 allocated memory space for processing.

[0073] To address the aforementioned issues, this application proposes a process anomaly detection method. During IPC communication between the server and client of an electronic device, the server can record a first correspondence between different clients and the memory space allocated to the client (as an example of a memory subspace), as well as the timestamp of the memory space allocation (as an example of an allocation timestamp).

[0074] When an electronic device detects an anomaly in the server's memory space, it can determine the first memory subspace corresponding to the IPC object that occupies the most memory space among the non-reclaimable IPC objects (as an example of inter-process communication messages) stored in the server's memory space (the IPC object that occupies the most memory space is usually the IPC object that caused the server's memory space anomaly; 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 GC collection). Based on the lifecycle of the first memory subspace (e.g., the timestamp of the allocation of the first memory subspace (as an example of the first timestamp)) and the first correspondence, it can determine the first client corresponding to the first memory subspace (that is, the anomaly of the first memory subspace was caused by the first client).

[0075] In this way, electronic devices can release the first memory subspace by controlling or adjusting the thread calls of the first client. Alternatively, electronic devices can store the correspondence between the first memory subspace exception and the first client, so that developers can determine that the cause of the first memory subspace exception is improper thread calls of the first client, and thus adjust or optimize the corresponding code of the first client.

[0076] Specifically, after receiving the inter-process communication message, the server of the electronic device can determine a first correspondence during the process of allocating the inter-process communication message to the corresponding service and processing the inter-process communication message. The first correspondence may include, for example, the client information, the server information (the client information and the server information can be used as examples of the first sub-correspondence), and the correspondence of memory space allocation information (as an example of the second sub-correspondence).

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

[0078] Table 1

[0079]

[0080] It is understandable that the contents of the client information, server information, and memory space allocation information can be as shown in Table 1. For example, the client identifier may include the client thread name or 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 messages (such as the thread identifier).

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

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

[0083] The allocation timestamp is the timestamp when the server allocates memory space to store the IPC object.

[0084] The memory space for storing IPC objects (as an example of a memory subspace) is the memory space that the server requests from the heap memory to store IPC objects.

[0085] It's understandable that in Table 1, the thread information (e.g., the binder thread) in the server-side information and the thread information in the memory allocation information refer to the same thread—the thread used to transmit client IPC messages to the corresponding service interface on the server. However, since the same thread can interact with multiple service interfaces on the server at different times, it's impossible to determine which service corresponds to the first memory subspace based solely on the thread information. Therefore, the first service corresponding to the first memory subspace can be determined by using the timestamp of memory allocation and the start and end timestamps of the calls to the interfaces corresponding to each service.

[0086] For example, when an electronic device detects an anomaly in the first memory subspace, it can determine the first thread information corresponding to the first memory subspace 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 in the server can be determined through the first thread information corresponding to the first memory subspace. Then, based on the start and end timestamps of the calls to the interfaces of each service, the interface of the first service including the timetamp of the allocation of the first memory subspace is determined. Then, the information of the first client corresponding to the interface of the first service is obtained. After determining that the first client caused the memory space anomaly on the server, the electronic device can manage the first client, for example, by prohibiting the first client from calling the server's services, limiting the duration of the first client's calls to the server's services, and limiting the memory space occupied by the first client's inter-process communication messages on the server, etc., to prevent the server from experiencing memory anomalies again.

[0087] With the above scheme, when an electronic device detects an abnormal memory space, the client that caused the abnormal memory space can be specifically identified based on the first correspondence and the allocation timestamp of the first memory subspace. This allows for the management of the corresponding client and prevents abnormal memory space occurrences in the electronic device.

[0088] In some embodiments, the information of the first thread may be, for example, an identifier for 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 identified by the identifier of the first thread. In this case, the first service can be identified by the relationship between the timestamp of allocating the first memory subspace and the start and end timestamps of the corresponding service's interface being called. For example, if the timestamp of allocating the first memory subspace falls between the start and end timestamps of a service's interface being called, then that service can be identified as the first service. The client calling the first service can be identified and its information can be obtained through the port data of the first service.

[0089] In some embodiments, when the server's memory space becomes abnormal, multiple clients may simultaneously call the server. Therefore, the client that occupies the most server memory space can be identified as the client that caused the server's memory space abnormality.

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

[0091] Figure 3 According to an embodiment of this application, an implementation flowchart for locating a client that causes a memory space anomaly on the server is shown.

[0092] For example, in the embodiments of this application, the executing entity of each of the following processes can be an electronic device, and the executing entity of each process is not limited in its description. 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, laptop computer, tablet, large-screen device, wearable device (e.g., watch, smart glasses, helmet), desktop computer, augmented reality (AR) / virtual reality (VR) device, personal digital assistant (PDA), etc. The following uses a mobile phone as an example of electronic device 100.

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

[0094] S301 records the first correspondence between different clients and the memory space allocated to the client, as well as the timestamp of the memory space allocation, during the IPC communication process.

[0095] For example, in some embodiments of this application, during the process of IPC communication via the binder mechanism, the electronic device can record a first correspondence between different clients and the memory space allocated to the client, as well as the timestamp of the memory space allocation.

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

[0097] Referring to Table 1, client information may include, for example, the client's thread name or thread identifier.

[0098] The information on the server side may include, for example, information about the thread through which the server transmits IPC messages to the client (such as the thread identifier), the identifier of the interface corresponding to the corresponding service on the server side, and the start and end timestamps of the corresponding service being called on the server side.

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

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

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

[0102] After the binder thread transmits the IPC messages of the business thread to the binder interface, the server can record the client information corresponding to the IPC messages received by the binder interface, as well as the server information corresponding to the binder interface.

[0103] For example, refer to Figure 4After the IPC message sent by business thread 3 is transmitted to binder interface 1 by binder thread 1, the server can record the client information, including the identifier of business thread 3. The server-side information recorded includes the identifier of binder thread 1, the identifier of binder interface 1, and the start and end timestamps of the binder interface 1 call (the end timestamp can be understood as being recorded after business thread 3 finishes calling binder interface 1). After binder service 1 corresponding to binder interface 1 receives the IPC message, it can package the IPC message into an object and request memory space from the server to store the object. The server can record the memory allocation information. For example, this allocation information includes the timestamp of the memory allocation and the binder thread 1 that transmitted the IPC message.

[0104] S302, An abnormality in the server's memory space was detected. The first memory subspace corresponding to the IPC object that occupies the most memory space among the non-reclaimable IPC objects stored in the server's memory space was determined.

[0105] For example, in some embodiments of this application, the server of the electronic device can detect its memory space usage 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 server's memory space is abnormal.

[0106] For example, in Binder communication, the server packages IPC messages into objects and stores them in heap memory. Electronic devices can use a profiler to view the server's heap memory usage. If the memory space being used by the server exceeds the heap memory space threshold, the memory space occupying the largest heap memory space can be selected as the first memory subspace, and it can be determined that there is an anomaly in that memory space.

[0107] For example, when the server's heap memory is full of data, the JVM can perform garbage collection (GC) to reclaim the memory space occupied by objects in threads that have finished executing, thus preventing server-side heap memory overflow. For instance, in some embodiments of this application, the JVM uses reachability analysis algorithms to analyze which memory space can be reclaimed.

[0108] The reachability analysis algorithm is a standard algorithm in the JVM used to determine whether an object is alive. Its basic idea is to start from a series of objects called garbage collection roots and search downwards from these nodes. The path traversed during the search is called a reference chain. When an object has no reference chain connecting it to any GC root (i.e., the object is unreachable from the GC roots), it is considered unusable and can be garbage collected.

[0109] For example, Figure 5 According to some embodiments of this application, a schematic diagram of reference relationships of objects subject to GC reclamation is shown.

[0110] It's understandable that when an object is created on the server side, the JVM can allocate a block of memory for that object in the heap and return a reference to that memory space (usually a pointer to a memory address). When a field or method of an object (e.g., object A) is set to reference another object (e.g., object B), a reference relationship from object A to object B is established. Analysis chains can be created through these reference relationships between objects.

[0111] like Figure 5 As shown, a GC root can be a collection of referenced objects accessible to running threads. Objects directly referenced by GC roots are called child nodes of the GC roots, such as object 1. Similarly, 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 indirect references to GC roots (i.e., object 2 or object 3 has a reference chain to the GC roots). Objects referenced by object 3 are child nodes of object 3, such as object 4. If an object is not directly or indirectly referenced by GC roots (e.g., the object has no reference chain to GC roots), the memory space occupied by that object can be reclaimed by the JVM. For example, objects 5, 6, and 7 are not directly or indirectly referenced by GC roots, therefore the memory space corresponding to objects 5, 6, and 7 can be reclaimed by the JVM. It can be understood that in some embodiments of this application, if an object of a client's business thread continuously occupies the server's memory space, the object directly or indirectly referenced by that business thread remains in an applied state. In other words, the object always exists in the reference chain to GC roots, so the JVM cannot reclaim the memory space occupied by the object, which may lead to memory leaks on the server side.

[0112] In some embodiments of this application, after the electronic device detects an anomaly in the server's memory space, it can determine which objects are currently occupying memory space in the server's heap memory through the reference relationships between various objects, 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 garbage collection mechanism). Then, the electronic device can select the largest occupied memory space as the first memory subspace. It can be understood that the object corresponding to the largest occupied memory space is an object that needs to be optimized, and this object may also be the cause of memory leaks; therefore, the largest occupied memory space can be used as the first memory subspace.

[0113] S303, based on the lifecycle of the first memory subspace and the first correspondence, determine the first client corresponding to the first memory subspace.

[0114] For example, in some embodiments of this application, after determining that there is an abnormal first memory subspace, the client that caused the abnormality of the first memory subspace can be determined according to the life cycle of the first memory subspace (e.g., the timestamp of the allocation of the first memory) and the first correspondence.

[0115] For example, refer to Figure 5 Within the reference relationships between objects, each object also includes its corresponding memory allocation information. This memory allocation information includes the timestamp when memory space was allocated to each object, as well as information about the thread that transmitted the corresponding object's IPC messages.

[0116] It is understandable that after determining the thread information, the interfaces of each service connected to the server can be determined based on the first correspondence. For example, the thread corresponding to the first memory subspace 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 subspace = the identifier of the binder thread transmitted by the binder interface.

[0117] For example, binder interface 1, binder interface 2, and binder interface 3 on the server side have all received IPC messages transmitted by binder thread 1. Therefore, it is possible to determine which binder interface received the IPC message based on the timestamp of the allocation of the first memory subspace.

[0118] For example, Figure 6 According to some embodiments of this application, a schematic diagram is shown of the start and end timestamps of the binder interface being invoked.

[0119] After confirming that binder interface 1, binder interface 2, and binder interface 3 have all received IPC messages transmitted by binder thread 1, it is possible to determine which binder interface processed the IPC message for the object corresponding to the first memory subspace based on the start and end timestamps of each binder interface call.

[0120] Reference Figure 6 The start timestamp of the call to binder interface 1 is T10, and the end timestamp is T11. The start timestamp of the call to binder interface 2 is T20, and the end timestamp is T21. The start timestamp of the call to binder interface 3 is T30, and the end timestamp is T31. The timestamp for allocating the first memory subspace is Tm. The timestamps T10, T11, T20, T21, T30, and T31 are arranged sequentially. Tm is between T10 and T11, i.e., T10 ≤ Tm ≤ T11. In other words, the first memory subspace is allocated between the start and end of the call to binder interface 1. Therefore, the first memory subspace can be understood as the memory space allocated during the call to binder interface 1. Then, based on the information of the client corresponding to binder interface 1, the first client corresponding to the first memory subspace can be determined.

[0121] Using the above scheme, when the server-side memory space of an electronic device experiences an anomaly, the device can identify the client causing the anomaly based on client information, server information, and memory allocation information recorded during IPC communication. The electronic device can then manage the corresponding client or adjust client threads to prevent memory leaks on the server side.

[0122] In other embodiments, the electronic device may also directly send the recorded first correspondence to the server or debugging device. The debugging device or server determines the client causing the memory space anomaly on the server side of the electronic device based on the data recorded by the electronic device; that is, other devices complete processes S302 and / or S301. During the debugging process of the electronic device, the server or debugging device detects whether the memory space of the corresponding application on the electronic device is abnormal. If the memory space of the corresponding application on the electronic device is abnormal, the aforementioned first correspondence can be obtained from the electronic device. The server or debugging device can determine the client causing the memory space anomaly in the corresponding application based on the first correspondence. Then, developers can adjust or optimize the code corresponding to the client to avoid memory leaks on the server side of the electronic device.

[0123] The following section introduces a software system for IPC communication in electronic devices based on the binder mechanism.

[0124] Figure 7 A schematic block diagram of the system software architecture of an electronic device is shown according to an embodiment of this application.

[0125] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses a layered architecture as an example to illustrate the software structure of an electronic device.

[0126] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the software system of an electronic device is divided into four layers, from top to bottom: the application layer, the framework layer, the native layer, and the kernel layer.

[0127] like Figure 7 As shown, the application layer is the direct interface between the user and the mobile phone system. It is responsible for providing the user interface, including icons, menus, dialog boxes, etc. of various applications, so that users can easily interact with the mobile phone system.

[0128] In some embodiments of this application, the application layer may include applications such as client and server applications, which may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, desktop, and messaging.

[0129] In some embodiments of this application, the client process and the server process run in their respective application spaces, and the runtime spaces of each application are independent, making direct message transmission impossible. However, the client and server can perform IPC communication.

[0130] For example, a client proxy can handle requests from the client and convert them into Binder IPC format. The requested data can be encapsulated into objects (such as parcel objects). The client proxy can then send IPC messages to the kernel-level Binder driver through the interfaces provided by the framework layer and the local layer's Binder IPC implementation.

[0131] A server-side stub can parse requests and data and invoke the actual processing logic provided by the server.

[0132] 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.

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

[0134] For example, in some embodiments of this application, the framework layer may include interfaces defined by the Android Interface Definition Language (AIDL). AIDL interfaces can transmit IPC messages, such as transmitting data sent by a client proxy or server stub to the ontology layer (native).

[0135] 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 the binder library and the service manager (SM).

[0136] The binder library encapsulates all operations related to the binder driver, acting as a bridge for interaction between upper-layer applications and the binder driver. This includes low-level operations such as sending and receiving IPC messages. After receiving an IPC message, the binder library 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 described above, the binder library can also record, for example... Figure 4 In this embodiment, information such as client information and server information are included during the binder communication process. This information is used to determine the initial correspondence between the client and the allocated memory space.

[0137] The Service Manager (SM) is used to manage service processes. Each service process must register its cross-process binders in the SM and store references to the corresponding binders. Clients can query the SM by name to find the desired service, and the SM will return a reference to a binder for that server. The SM is also a process, but every process that needs to communicate with the SM knows about the SM's references.

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

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

[0140] 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 process management and memory management mechanisms.

[0141] After the server-side stub receives the transaction object from the client provided by the binder driver (e.g., processing the transaction object through the binder thread), it can call the relevant server-side logic to process the transaction object. In some embodiments of this application, the server-side process requires the JVM to allocate corresponding memory space during its execution. During the process of the server allocating memory space for the transaction object, the JVM can record the timestamp of the memory space allocation and transmit the identifier of the binder thread for the transaction object in the server-side process, so as to establish a first correspondence between the client and the allocated memory space based on the timestamp of memory space allocation and the corresponding binder thread identifier.

[0142] 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).

[0143] 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 process management and memory management mechanisms.

[0144] The client agent 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.

[0145] The following section uses a mobile phone as an example to provide a detailed description of the electronic devices involved in some embodiments of the present invention.

[0146] Figure 8 A schematic diagram of the structure of an electronic device is shown according to an embodiment of this application.

[0147] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity 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.

[0148] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0149] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.

[0150] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0151] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0152] In some embodiments, the processor 110 may include one or more interfaces. 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, etc.

[0153] The charging management module 140 is used to receive charging input from the charger.

[0154] The power management module 141 connects 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, providing power to the processor 110, internal memory 121, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.

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

[0156] 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 one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization.

[0157] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.

[0158] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates 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 processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.

[0159] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. 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 antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0160] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a glass cover 10 and a display panel 20. The display panel 20 can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), 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, the electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.

[0161] Camera 193 is used to capture still images or videos.

[0162] The external storage 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 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0163] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 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, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory located in the processor.

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

[0165] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the electronic device 100. The electronic device 100 can support one 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, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. 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.

[0166] This application also provides a program product that, when executed on an electronic device, enables the electronic device to implement the methods provided in the foregoing embodiments.

[0167] This application also provides a readable storage medium storing one or more programs, which, when executed by an electronic device, enable the electronic device to implement the methods provided in the foregoing embodiments.

[0168] Various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or combinations of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including 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.

[0169] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the 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.

[0170] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0171] 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 on or stored thereon by one or more transient or non-transitory 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 via a network or through other computer-readable media. Therefore, machine-readable media can include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, CD-ROMs, 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 cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other forms of propagation signals. Therefore, machine-readable media includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.

[0172] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.

[0173] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.

[0174] It should be noted that in the examples and description of this patent, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0175] Although this application has been illustrated and described with reference to certain preferred embodiments thereof, those skilled in the art should understand that various changes in form and detail may be made thereto without departing from the spirit and scope of this 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 one server, and the method includes: An anomaly in the server's memory space is detected. A first memory subspace that caused the anomaly is determined from the server's memory space. The server's memory space includes multiple memory subspaces, each of which includes the first memory subspace. Each memory subspace stores the inter-process communication messages of the client corresponding to that memory subspace. Based on the pre-stored first correspondence and the first timestamp for allocating the first memory subspace, the first client corresponding to the first memory subspace is determined, wherein the first correspondence includes the correspondence between the client and the memory subspace and the 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. The first sub-correspondence 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 and end timestamps of the service interface being called by the client, and the thread identifier of the server thread that transmits the inter-process communication messages of the client. The second sub-correspondence is the 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 step of determining the first client corresponding to the first memory subspace based on the pre-stored first correspondence and the first timestamp of the allocation of the first memory subspace includes: Obtain the first thread identifier and first timestamp corresponding to the first memory subspace from the second sub-correspondence relationship; Based on the first thread identifier, at least one first interface identifier corresponding to the first thread identifier is obtained from the first sub-correspondence; Based on the first sub-correspondence, the client corresponding to the first client identifier of the service interface being called is determined as the first client, and the time period corresponding to the start and end timestamps of the service interface being called, including the first client identifier of the first timestamp.

4. The method according to claim 1, characterized in that, The method also includes managing the first client.

5. The method according to claim 1, characterized in that, Determining the first memory subspace from the server's memory space that caused the server's memory space anomaly includes: The memory subspace with the largest storage space among the plurality of memory subspaces is designated as the first memory subspace.

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

7. A method for detecting process anomalies, characterized in that, include: The first electronic device obtains a first correspondence between each client and a memory subspace, and the allocation timestamp of the memory subspace, which is pre-stored in the first electronic device. The memory subspace is the memory space where the server of the first electronic device stores the inter-process communication messages of the client. The first electronic device sends the first correspondence and the memory space usage data of the server to the second electronic device; The second electronic device detects an anomaly in the memory space of the server of the first electronic device based on the memory space usage data of the server. The second electronic device identifies from the memory subspace the first memory subspace that caused the memory space anomaly on the server. The second electronic device determines the first client corresponding to the first memory subspace based on the first timestamp of the allocation of the first memory subspace and the first correspondence.

8. A method for detecting process anomalies, characterized in that, include: The first electronic device detects an anomaly in the server's memory space and determines a first memory subspace that caused the anomaly from the server's memory space. The server's memory space includes multiple memory subspaces, each of which includes the first memory subspace. Each memory subspace stores inter-process communication messages of the client corresponding to that 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 the correspondence between the client and the memory subspace and the timestamp of the memory subspace allocation; The second electronic device determines the first client corresponding to the first memory subspace based on the first timestamp of the allocation of the first memory subspace and the first correspondence.

9. An electronic device, characterized in that, include: Memory, used to store instructions; At least one processor is configured to execute the instructions to cause the electronic device to implement the method of any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, The readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the method of any one of claims 1 to 6.

11. A computer program product, characterized in that, When the computer program product is run on the device, it causes the device to perform the method of 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