Abnormality processing method and device, electronic equipment and computer readable medium

The method addresses the inefficiencies in handling Java memory overflow exceptions by identifying and serializing target objects, storing them in a container, and deserializing when conditions permit, thus reducing downtime and improving stability.

CN119166394APending Publication Date: 2024-12-20BEIJING JINGDONG QIANSHITECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310731977.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-20
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

The existing process for handling Java memory overflow exceptions is lengthy, resource-intensive, and has a wide negative impact, leading to system unavailability.

Method used

An exception handling method that identifies the type of exception, determines the target memory object based on space and access frequency, serializes it, and stores the data in a preset container, and then clears the data, with optional deserialization based on thresholds and insertion methods.

Benefits of technology

Improves exception handling efficiency and reduces system downtime due to memory overflow exceptions, enhancing system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166394A_ABST
    Figure CN119166394A_ABST
Patent Text Reader

Abstract

The invention discloses an exception handling method and device, electronic equipment and a computer readable medium, and relates to the technical field of computers.The specific implementation mode comprises the steps that in response to an exception handling request, a corresponding exception type identifier is obtained; calling a statistical information table to obtain the occupied space of the memory object and the corresponding access frequency in response to the memory overflow exception corresponding to the exception type identifier; determining a target memory object based on the occupied space and the access frequency; and serializing the target memory object to obtain serialized data, storing the serialized data to a preset container, and further emptying data corresponding to the target memory object. Therefore, the exception handling efficiency can be improved, the time that the system is in an unavailable state due to memory overflow exception is shortened, and the system stability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an exception handling method, device, electronic device and computer-readable medium. Background Art

[0002] At present, the Java system is prone to memory overflow (OOM) exceptions during operation, which manifests itself as the system throwing a java.lang.OutOfMemoryError exception, causing the system to crash or become unavailable. When encountering this problem, programmers usually export and analyze the heap dump file to determine the object that caused the memory overflow, optimize the code or optimize the jvm virtual machine parameters, and repackage and deploy it, and republish it. The entire repair process for the memory overflow exception consumes manpower and material resources, and the repair process is lengthy. Before the repair, the system is unavailable for a long time, and the negative impact is wide. Summary of the invention

[0003] In view of this, the embodiments of the present application provide an exception handling method, device, electronic device and computer-readable medium, which can solve the problems that the entire existing repair process for memory overflow exceptions consumes manpower and material resources, the repair process is lengthy, the negative impact range is large, and the exception handling efficiency is low.

[0004] To achieve the above object, according to one aspect of an embodiment of the present application, a method for handling an exception is provided, including:

[0005] In response to the exception handling request, obtain a corresponding exception type identifier;

[0006] In response to the exception type identifier corresponding to the memory overflow exception, calling the statistical information table to obtain the occupied space of the memory object and the corresponding access frequency;

[0007] Determine the target memory object based on the occupied space and access frequency;

[0008] Serialize the target memory object to obtain serialized data, store the serialized data in a preset container, and then clear the data corresponding to the target memory object.

[0009] Optionally, after clearing the data corresponding to the target memory object, the method further includes:

[0010] In response to the current time reaching the execution time corresponding to the cyclic task, the corresponding cyclic task is executed to call the statistical information table to obtain the field access frequency corresponding to the serialized data from the connected exchange table;

[0011] Call the memory management class to obtain memory usage;

[0012] In response to the field access frequency being greater than a first preset threshold or the memory usage being less than a second preset threshold, a deserialization process is performed based on the serialized data.

[0013] Optionally, a deserialization process is performed based on the serialized data, including:

[0014] Obtaining a sequence identifier corresponding to the serialized data, and in response to the sequence identifier corresponding to an existing sequence, deserializing the serialized data to generate a deserialized object;

[0015] Insert the deserialized object into the corresponding field in memory according to the front insertion method.

[0016] Optionally, a deserialization process is performed based on the serialized data, including:

[0017] In response to the sequence identifier corresponding to a non-existent sequence, deserializing the serialized data to generate a deserialized object;

[0018] Directly insert the deserialized object into an arbitrary location in memory.

[0019] Optionally, determine the target memory object, including:

[0020] The access frequencies are arranged in ascending order and the occupied spaces are arranged in descending order, and then a preset number of memory objects are obtained in sequence and used as target memory objects.

[0021] Optionally, before calling the statistical information table to obtain the field access frequency corresponding to the serialized data from the connected exchange table, the method further includes:

[0022] Perform inner joins on the exchange table and the information statistics table based on the class name and class package name.

[0023] Optionally, before calling the statistical information table to obtain the occupied space and the corresponding access frequency of the memory object, the method further includes:

[0024] Method annotations for intercepting global fields corresponding to memory objects;

[0025] Based on the method annotations, the occupied space and corresponding access frequency of the memory object are obtained and recorded in the statistical information table.

[0026] In addition, the present application also provides an exception handling device, including:

[0027] A first acquisition unit is configured to acquire a corresponding exception type identifier in response to an exception handling request;

[0028] A second acquisition unit is configured to call the statistical information table to acquire the occupied space of the memory object and the corresponding access frequency in response to the exception type identifier corresponding to the memory overflow exception;

[0029] A target memory object determination unit is configured to determine a target memory object based on occupied space and access frequency;

[0030] The serialization unit is configured to serialize the target memory object to obtain serialized data, store the serialized data in a preset container, and then clear the data corresponding to the target memory object.

[0031] Optionally, the exception handling device further includes a deserialization unit configured to:

[0032] In response to the current time reaching the execution time corresponding to the cyclic task, the corresponding cyclic task is executed to call the statistical information table to obtain the field access frequency corresponding to the serialized data from the connected exchange table;

[0033] Call the memory management class to obtain memory usage;

[0034] In response to the field access frequency being greater than a first preset threshold or the memory usage being less than a second preset threshold, a deserialization process is performed based on the serialized data.

[0035] Optionally, the deserialization unit is further configured to:

[0036] Obtaining a sequence identifier corresponding to the serialized data, and in response to the sequence identifier corresponding to an existing sequence, deserializing the serialized data to generate a deserialized object;

[0037] Insert the deserialized object into the corresponding field in memory according to the front insertion method.

[0038] Optionally, the deserialization unit is further configured to:

[0039] In response to the sequence identifier corresponding to a non-existent sequence, deserializing the serialized data to generate a deserialized object;

[0040] Directly insert the deserialized object into an arbitrary location in memory.

[0041] Optionally, the target memory object determination unit is further configured to:

[0042] The access frequencies are arranged in ascending order and the occupied spaces are arranged in descending order, and then a preset number of memory objects are obtained in sequence and used as target memory objects.

[0043] Optionally, the exception handling device further includes an internal connection unit configured to:

[0044] Perform inner joins on the exchange table and the information statistics table based on the class name and class package name.

[0045] Optionally, the second acquisition unit is further configured to:

[0046] Method annotations for intercepting global fields corresponding to memory objects;

[0047] Based on the method annotations, the occupied space and corresponding access frequency of the memory object are obtained and recorded in the statistical information table.

[0048] In addition, the present application also provides an exception handling electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the exception handling method as described above.

[0049] In addition, the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned exception handling method is implemented.

[0050] One embodiment of the above invention has the following advantages or beneficial effects: the application obtains the corresponding exception type identification by responding to the exception handling request; in response to the exception type identification corresponding to the memory overflow exception, calls the statistical information table to obtain the occupied space and corresponding access frequency of the memory object; determines the target memory object based on the occupied space and access frequency; serializes the target memory object to obtain serialized data, stores the serialized data in a preset container, and then clears the data corresponding to the target memory object. This can improve the efficiency of exception handling, reduce the time the system is in an unavailable state due to the memory overflow exception, and improve system stability.

[0051] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application.

[0053] Figure 1 It is a schematic diagram of the main process of the exception handling method provided according to an embodiment of the present application;

[0054] Figure 2 It is a schematic diagram of the main process of the exception handling method provided according to an embodiment of the present application;

[0055] Figure 3 It is a schematic diagram of the module architecture of an exception handling method provided according to an embodiment of the present application;

[0056] Figure 4 It is a schematic diagram of an abnormality discovery process of an abnormality handling method provided according to an embodiment of the present application;

[0057] Figure 5It is a statistical flow chart of an exception handling method provided according to an embodiment of the present application;

[0058] Figure 6 This is a schematic diagram of the process of serializing memory objects to disk according to an exception handling method provided in one embodiment of the present application;

[0059] Figure 7 This is a schematic diagram of the process of deserializing from disk to memory according to an exception handling method provided in one embodiment of the present application;

[0060] Figure 8 is a schematic diagram of main units of an exception handling device according to an embodiment of the present application;

[0061] Fig. 9 is an exemplary system architecture diagram to which the embodiments of the present application can be applied;

[0062] Fig.10 It is a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION

[0063] The following is an explanation of the exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the technical solution of the present disclosure, the collection, collection, update, analysis, processing, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Take necessary measures for user personal information to prevent illegal access to user personal information data and maintain user personal information security, network security and national security.

[0064] Figure 1 is a schematic diagram of the main process of the exception handling method provided according to an embodiment of the present application, such as Figure 1 As shown, the exception handling method includes:

[0065] Step S101, in response to an exception handling request, obtain a corresponding exception type identifier.

[0066] In this embodiment, the execution subject of the exception handling method (for example, it can be a server) can receive an exception handling request through a wired connection or a wireless connection. The exception handling request can be, for example, a request to handle an Out Of Memory (OOM) exception. When the execution subject receives the exception handling request, the corresponding exception type identifier can be obtained, for example, OOM, which represents a memory overflow exception. The exception type identifier can also be CVYC, which represents a program execution error. The embodiment of the present application does not specifically limit the exception type identifier.

[0067] Step S102: In response to the exception type identifier corresponding to the memory overflow exception, the statistical information table is called to obtain the occupied space of the memory object and the corresponding access frequency.

[0068] A statistics table can be a table that stores statistics of an array or a container.

[0069] Specifically, before calling the statistical information table to obtain the occupied space and corresponding access frequency of the memory object, the method also includes: intercepting the method annotation of the global field corresponding to the memory object; based on the method annotation, obtaining the occupied space and corresponding access frequency of the memory object and recording them in the statistical information table.

[0070] In the embodiment of the present application, OOM: out of memory, i.e., memory overflow; Runtime class: used to obtain real-time status information of the virtual machine such as maximum memory, available memory, free memory, etc., and the memory usage rate can be calculated based on this information. For example, Figure 5 As shown, the execution subject can call the statistics module to intercept the array or container get, set method annotation @Stastics to extract the array or container size, and accumulate the number of accesses, record it in the table, and end the process. Specifically, the execution subject can call the statistics module to count the memory usage and the frequency of use of the global field of the array or container. The Runtime class provided by JDK (JDK provides real-time status information of the virtual machine such as maximum memory, available memory, free memory, etc., and the memory usage can be calculated based on this information) API is used for statistics of memory usage, and the frequency of use of the global field of the array or container is counted by adding a custom annotation @Stastics to the get and set methods of the global field of the array or container. The @Stastics annotation is intercepted during runtime to count the access frequency of the global field of the array or container, and recorded in the statistical information table for the memory and disk exchange module to call.

[0071] Step S103, determining the target memory object based on the occupied space and the access frequency.

[0072] Specifically, determine the target memory object, including:

[0073] The access frequencies are arranged in ascending order and the occupied spaces are arranged in descending order, and then a preset number of memory objects are obtained in sequence and used as target memory objects.

[0074] That is, the memory object with low access frequency and large space occupation is determined as the target memory object. For example, Figure 6 As shown, after receiving the exception handling request, the execution subject can query and access the statistical information table according to the access frequency count in ascending order and the container size size in descending order, and take the TopN records as the target memory object.

[0075] Step S104, serialize the target memory object to obtain serialized data, store the serialized data in a preset container, and then clear the data corresponding to the target memory object.

[0076] The default container, for example, can be a disk. Figure 6 As shown in the figure, after taking the TopN records as the target memory object, the execution subject can obtain the bean instance of the spring container according to the bean_name field value in the statistical information table, obtain the array or container field value through field name field_name reflection and serialize it. The class name, field name, field type, and serialized file disk address are saved in order to the memory and disk exchange table. The memory and disk exchange table is locked, and all data corresponding to the target memory object in the array or container is cleared.

[0077] Among them, the memory and disk exchange table: the core is a two-dimensional table, which records the class name and array or container global field name and the address serialized to the memory, and provides external query services for querying the disk path based on the class name and field name, so as to restore the memory usage for deserialization.

[0078] This embodiment obtains the corresponding exception type identification in response to the exception handling request; in response to the exception type identification corresponding to the memory overflow exception, calls the statistical information table to obtain the occupied space and corresponding access frequency of the memory object; determines the target memory object based on the occupied space and access frequency; serializes the target memory object to obtain serialized data, stores the serialized data in a preset container, and then clears the data corresponding to the target memory object. This can improve the efficiency of exception handling, reduce the time the system is in an unavailable state due to the memory overflow exception, and improve system stability.

[0079] Figure 2 is a main flow chart of an exception handling method provided according to an embodiment of the present application, such as Figure 2 As shown, the exception handling method includes:

[0080] Step S201, in response to an exception handling request, obtain a corresponding exception type identifier.

[0081] The exception type identifier, for example, can be 1, representing a memory overflow exception, or can be 0, representing a memory overflow exception. The embodiment of the present application does not specifically limit the exception type identifier.

[0082] Step S202: In response to the exception type identifier corresponding to the memory overflow exception, the statistical information table is called to obtain the occupied space of the memory object and the corresponding access frequency.

[0083] For example, when the exception type is 1, it indicates a memory overflow exception. Memory overflow (OOM) refers to the situation where there is unreclaimable memory or too much memory is used in the application system, which eventually causes the memory required for program operation to be greater than the maximum memory that can be provided.

[0084] Step S203, determining the target memory object based on the occupied space and the access frequency.

[0085] That is, a memory object with low access frequency and large occupied space is determined as a target memory object.

[0086] Step S204, serialize the target memory object to obtain serialized data, store the serialized data in a preset container, and then clear the data corresponding to the target memory object.

[0087] The preset container can be, for example, a disk. Serialization is the conversion of an object into data, which is equivalent to taking a snapshot of the object, transmitting or storing it, and then deserializing it when it is used, and it becomes an object again. Since the reason for the OOM exception is that a large number of reachable objects cannot be recovered by the garbage collector and occupy the memory for a long time, and some objects are not frequently accessed by the program, these objects are often placed in arrays or containers in the global scope. The embodiment of the present application captures the OOM exception. When the OOM exception occurs, some containers or arrays with low access frequency are serialized to the disk, and the data corresponding to the target object is cleared to release this part of the memory space, thereby achieving the purpose of repairing the OOM exception. When it is necessary to access this part of the object exchanged to the disk or there is a large amount of free space in the memory, this part of the object is deserialized to the memory. In this way, the hard disk space is used as a temporary storage medium, and the memory space is infinitely expanded to avoid system unavailability caused by the OOM exception.

[0088] The process of deserializing from disk to memory is a loop task. Every once in a while, it scans the statistical information table to obtain the access frequency count of the fields, and obtains the memory usage rate through the Runtime class. When count > K or rate < M (K and M are user input parameters, K is the first preset threshold, and M is the second preset threshold), it deserializes data from disk to memory. If it is in order, it uses the front-insertion method and inserts it into the array or container field. Otherwise, a general insertion is fine. Finally, this record is deleted from the memory and disk exchange table. Specifically, as shown in steps S205 - S207:

[0089] Step S205, in response to the current time reaching the execution time corresponding to the loop task, execute the corresponding loop task to call the statistical information table to obtain the field access frequency corresponding to the serialized data from the connected exchange table.

[0090] The loop task, for example, is a task of deserializing disk data to memory. Executing the loop task means executing the task of deserializing disk data to memory. Specifically, it can be to obtain the field access frequency corresponding to the serialized data from the exchange table that is inner-joined with the statistical information table.

[0091] Specifically, before calling the statistical information table to obtain the field access frequency corresponding to the serialized data from the connected exchange table, the method further includes:

[0092] Perform an inner join on the exchange table and the information statistical table based on the class name and the class packaging name.

[0093] As Figure 7 shown, the execution entity can perform an inner join on the statistical table and the memory and disk exchange table based on the class name and the Jar package name for subsequent query of the field access frequency.

[0094] Step S206, call the memory management class to obtain the memory usage rate.

[0095] The memory management class, for example, can be Figure 7 the Runtime class of the jdk shown in

[0096] Step S207, in response to the field access frequency being greater than the first preset threshold or the memory usage rate being less than the second preset threshold, execute the deserialization process based on the serialized data.

[0097] By comparing the field access frequency obtained based on the inner connection with the first preset threshold, and comparing the memory usage rate obtained based on the memory management class with the second preset threshold, when the field access frequency corresponding to the data on the disk is greater than the first preset threshold or the memory usage rate is less than the second preset threshold, the deserialization process is performed on the corresponding data. Deserialization can be understood as converting the data on the disk into a memory object. When the array or container field access frequency is less than or equal to the first threshold (for example, less than or equal to K) and the memory usage rate is greater than or equal to the second preset threshold (for example, greater than or equal to M), enter the sleep state and return to the start program. The embodiment of the present application does not specifically limit K and M.

[0098] Specifically, the deserialization process is performed based on the serialized data, including:

[0099] Obtain a sequence identifier corresponding to the serialized data, and in response to the sequence identifier corresponding to an existing order, deserialize the serialized data to generate a deserialized object; and insert the deserialized object into a corresponding field in the memory according to a forward insertion method.

[0100] Specifically, a deserialization process is performed based on the serialized data, including: in response to the sequence identifier corresponding to a non-existent sequence, deserializing the serialized data to generate a deserialized object; and directly inserting the deserialized object into an arbitrary position in the memory.

[0101] like Figure 7 As shown, in the process of executing the deserialization process, when the access frequency of the corresponding array or container field is greater than the first threshold (for example, greater than K) and the memory usage rate is less than the second preset threshold (for example, less than M), it is possible to continue to determine whether the serialized data in the disk carries an order. If it carries an order, obtain the sequence identifier corresponding to the serialized data, such as 1, 2, 3, etc., and then serialize the serialized data in sequence according to the sequence identifier. Specifically, it can be inserted into the memory array or container field using the forward insertion method. If the order is not carried, deserialization is executed and directly inserted into the memory. After the deserialization is completed, this record is deleted in the memory and disk exchange table. Thereby realizing online automatic repair of exceptions caused by memory overflow, without human intervention, and reducing the negative impact caused by the exception.

[0102] Figure 3 FIG. 1 is a schematic diagram of a module architecture of an exception handling method provided according to an embodiment of the present application. Figure 3As shown, the statistics module: counts the memory usage rate and the frequency of use of global fields of arrays or containers. The memory usage rate is counted using the Runtime class API provided by JDK (JDK provides real-time status information of virtual machines such as maximum memory, available memory, free memory, etc., and the memory usage rate can be calculated based on this information). The frequency of use of global fields of arrays or containers is counted by adding a custom annotation @Stastics to the get and set methods of global fields of arrays or containers. The @Stastics annotation is intercepted during runtime to count the access frequency of global fields of arrays or containers and record it in the statistical information table for the memory and disk exchange module to call.

[0103] Memory and disk exchange table: The core is a two-dimensional table that records the class name and array or container global field name and the address serialized to the memory. It also provides external query services for querying the disk path based on the class name and field name, and restores memory usage for deserialization.

[0104] OOM exception (error) discovery module: The core is a piece of code. The code function is aspect-oriented programming. It creates an aspect, discovers exceptions in the AfterThrowing notification, and calls the memory and disk exchange module. This module, together with the memory and disk exchange module and the statistics module, acts as a client and needs to be referenced to the Java system for exception handling. Specifically, the @AfterThrowing annotation is used to specify the processing method that needs to be executed when an exception occurs during program execution.

[0105] Memory and disk exchange module: The core is a piece of code. According to the statistical results of the statistical module, the global arrays or containers with low access frequency are serialized to the disk, and the arrays or containers are cleared at the same time, and the class name, field name, disk address and other information are recorded in the memory and disk exchange table. On the other hand, according to the statistical results of the statistical module, when there is a large amount of free memory or the usage rate of the array or container field that has been swapped to the disk increases, the disk data is deserialized to the memory. When the exception detection module finds the OOM exception, it executes the process of serializing the memory object to the disk, serializes part of the memory data to the disk for temporary storage, and releases this part of the memory space, so that there is room to create new objects. The embodiment of the present application can automatically handle memory exceptions without manual intervention, thereby improving the rate and accuracy of exception handling. The exception is repaired quickly, reducing the time the system is in an unavailable state due to OOM exceptions, and improving system stability.

[0106] Figure 4This is a schematic diagram of an exception discovery process of an exception handling method provided according to an embodiment of the present application. The exception handling method of the embodiment of the present application is applied to the memory exception detection scenario. Specifically, the OOM exception (error) discovery module can be called, based on the aspect-oriented programming characteristics of spring, the aspect class is created, and the AfterThrowing notification is processed. If the exception that occurs is an OOM exception, the memory and disk exchange module is called to process it, such as Figure 4 As shown in the figure, the aspect logic is: if it is an OOM exception, call the memory and disk exchange module to execute the process of serializing memory objects into disk data. In this way, memory exceptions can be automatically handled without manual intervention, improving the speed and accuracy of exception handling.

[0107] Figure 8 Schematic diagram of the main units of the exception handling device according to an embodiment of the present application. Figure 8 As shown, the exception handling device 800 includes a first acquisition unit 801 , a second acquisition unit 802 , a target memory object determination unit 803 and a serialization unit 804 .

[0108] The first acquisition unit 801 is configured to acquire a corresponding exception type identifier in response to an exception handling request.

[0109] The second acquisition unit 802 is configured to call the statistical information table to acquire the occupied space of the memory object and the corresponding access frequency in response to the exception type identifier corresponding to the memory overflow exception.

[0110] The target memory object determining unit 803 is configured to determine the target memory object based on the occupied space and the access frequency.

[0111] The serialization unit 804 is configured to serialize the target memory object to obtain serialized data, store the serialized data in a preset container, and then clear the data corresponding to the target memory object.

[0112] In some embodiments, the device further comprises Figure 8 The deserialization unit not shown in the figure is configured to: in response to the current time reaching the execution time corresponding to the cyclic task, execute the corresponding cyclic task to call the statistical information table to obtain the field access frequency corresponding to the serialized data from the connected exchange table; call the memory management class to obtain the memory usage rate; in response to the field access frequency being greater than the first preset threshold or the memory usage being less than the second preset threshold, execute the deserialization process based on the serialized data.

[0113] In some embodiments, the deserialization unit is further configured to: obtain a sequence identifier corresponding to the serialized data, and in response to the sequence identifier corresponding to the existing order, deserialize the serialized data to generate a deserialized object; and insert the deserialized object into the corresponding field in the memory according to the front insertion method.

[0114] In some embodiments, the deserialization unit is further configured to: in response to the sequence identifier corresponding to a non-existent sequence, deserialize the serialized data to generate a deserialized object; and directly insert the deserialized object into an arbitrary position in the memory.

[0115] In some embodiments, the target memory object determination unit 803 is further configured to: sort the access frequencies in ascending order and the occupied spaces in descending order, and then sequentially obtain a preset number of memory objects as target memory objects.

[0116] In some embodiments, the exception handling device further includes Figure 8 The inner connection unit not shown in the figure is configured to: perform inner connection on the exchange table and the information statistics table based on the class name and the class packaging name.

[0117] In some embodiments, the second acquisition unit 802 is further configured to: intercept method annotations of global fields corresponding to memory objects; based on the method annotations, acquire the occupied space and corresponding access frequency of the memory objects and record them in the statistical information table.

[0118] It should be noted that the exception handling method and the exception handling device of the present application have a corresponding relationship in terms of specific implementation contents, so the repeated contents will not be described again.

[0119] Fig. 9 An exemplary system architecture 900 to which the exception handling method or exception handling device according to the embodiment of the present application can be applied is shown.

[0120] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0121] Users can use terminal devices 901, 902, 903 to interact with server 905 through network 904 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 901, 902, 903, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0122] The terminal devices 901 , 902 , and 903 may be various electronic devices having an exception processing screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0123] Server 905 can be a server that provides various services, such as a background management server that provides support for exception handling requests submitted by users using terminal devices 901, 902, and 903 (only as an example). The background management server responds to the exception handling request and obtains the corresponding exception type identification; in response to the exception type identification corresponding to the memory overflow exception, the statistical information table is called to obtain the occupied space and corresponding access frequency of the memory object; based on the occupied space and access frequency, the target memory object is determined; the target memory object is serialized to obtain serialized data, and the serialized data is stored in a preset container, and then the data corresponding to the target memory object is cleared. This can improve the efficiency of exception handling, reduce the time the system is in an unavailable state due to the memory overflow exception, and improve system stability.

[0124] It should be noted that the exception handling method provided in the embodiment of the present application is generally executed by the server 905 , and accordingly, the exception handling device is generally set in the server 905 .

[0125] It should be understood that Fig. 9 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0126] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present application. Fig.10 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0127] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the computer system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0128] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0129] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present application are executed.

[0130] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. Computer-readable storage media may include, for example, but are not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0131] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0132] The units involved in the embodiments described in the present application may be implemented by software or by hardware. The units described may also be set in a processor, for example, may be described as: a processor includes a first acquisition unit, a second acquisition unit, a target memory object determination unit, and a serialization unit. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0133] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device responds to an exception handling request and obtains a corresponding exception type identifier; in response to the exception type identifier corresponding to a memory overflow exception, calls a statistical information table to obtain the occupied space and corresponding access frequency of the memory object; based on the occupied space and access frequency, determines the target memory object; serializes the target memory object to obtain serialized data, stores the serialized data in a preset container, and then clears the data corresponding to the target memory object.

[0134] According to the technical solution of the embodiment of the present application, the efficiency of exception handling can be improved, the time that the system is in an unavailable state due to memory overflow exception can be reduced, and the system stability can be improved.

[0135] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.

Claims

1. An exception handling method, characterized in that: include: In response to the exception handling request, obtain a corresponding exception type identifier; In response to the exception type identifier corresponding to a memory overflow exception, calling a statistical information table to obtain an occupied space of a memory object and a corresponding access frequency; Determine a target memory object based on the occupied space and the access frequency; The target memory object is serialized to obtain serialized data, the serialized data is stored in a preset container, and then the data corresponding to the target memory object is cleared.

2. The method according to claim 1, characterized in that After clearing the data corresponding to the target memory object, the method further includes: In response to the current time reaching the execution time corresponding to the cyclic task, the corresponding cyclic task is executed to call the statistical information table to obtain the field access frequency corresponding to the serialized data from the connected exchange table; Call the memory management class to obtain memory usage; In response to the field access frequency being greater than a first preset threshold or the memory usage being less than a second preset threshold, a deserialization process is performed based on the serialized data.

3. The method according to claim 2, characterized in that The performing of the deserialization process based on the serialized data comprises: Obtaining a sequence identifier corresponding to the serialized data, and in response to the sequence identifier corresponding to an existing sequence, deserializing the serialized data to generate a deserialized object; The deserialized object is inserted into the corresponding field in the memory according to the front insertion method.

4. The method according to claim 2, characterized in that: The performing a deserialization process based on the serialized data includes: In response to the sequence identifier corresponding to a non-existent sequence, deserializing the serialized data to generate a deserialized object; Directly insert the deserialized object into any location in memory.

5. The method according to claim 1, characterized in that The determining of the target memory object comprises: The access frequencies are arranged in ascending order, and the occupied spaces are arranged in descending order, and then a preset number of memory objects are acquired in sequence and used as target memory objects.

6. The method according to claim 2, characterized in that Before the calling statistics information table obtains the field access frequency corresponding to the serialized data from the connected exchange table, the method further includes: Perform inner joins on the exchange table and the information statistics table based on the class name and class package name.

7. The method according to claim 1, characterized in that Before calling the statistical information table to obtain the occupied space and the corresponding access frequency of the memory object, the method further includes: Method annotations for intercepting global fields corresponding to memory objects; Based on the method annotation, the occupied space and the corresponding access frequency of the memory object are obtained and recorded in the statistical information table.

8. An exception handling device, characterized in that: include: A first acquisition unit is configured to acquire a corresponding exception type identifier in response to an exception handling request; A second acquisition unit is configured to call a statistical information table to acquire an occupied space of a memory object and a corresponding access frequency in response to the exception type identifier corresponding to a memory overflow exception; a target memory object determining unit, configured to determine a target memory object based on the occupied space and the access frequency; The serialization unit is configured to serialize the target memory object to obtain serialized data, store the serialized data in a preset container, and then clear the data corresponding to the target memory object.

9. An abnormality handling electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.