A method and apparatus for processing memory objects

By detecting and filtering the categories of memory objects, retaining only important objects and generating limited reference relationship information, the problem of excessively large memory snapshot files in mobile apps is solved, achieving more efficient memory snapshot generation and uploading.

CN114416356BActive Publication Date: 2026-03-27BEIJING 58 INFORMATION TTECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Mobile app memory snapshot files can become too large with ample memory, resulting in low upload success rates, long collection times, and high data consumption. Simply using compression tools is not very effective.

Method used

By detecting the category of memory objects, filtering out non-engineering custom classes, retaining only important memory objects, generating a preset number of reference relationship information, and updating the number threshold to reduce the memory snapshot size.

Benefits of technology

It effectively reduces the generation time and size of memory snapshots, lowers bandwidth usage, and improves upload success rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416356B_ABST
    Figure CN114416356B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a memory object processing method and device, and relate to the field of computers. The method comprises: detecting whether an undetected first memory object exists in a memory; if the undetected first memory object exists, obtaining a class corresponding to the first memory object; detecting whether to retain the first memory object based on the class; if the first memory object is retained, detecting whether a current quantity of memory objects corresponding to the class reaches a quantity threshold; if the quantity threshold is not reached, obtaining at least one second memory object referenced by the first memory object, and generating reference relationship information of the first memory object and the at least one second memory object; updating the current quantity to obtain an updated first latest quantity, and storing the reference relationship information and the first latest quantity. Embodiments of the present application reduce the size of a subsequently generated memory snapshot, and the time of generating the memory snapshot.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a memory object processing method and a memory object processing device. BACKGROUND

[0002] The memory snapshot generally refers to the information of all memory objects in the current process at a moment, including all created memory objects and the number, the reference relationship table between the memory objects, etc. When the memory reaches a high usage rate, the memory snapshot can be used to sort the size of all currently created memory objects, so as to find out the cause of the current memory problem.

[0003] Further, the memory snapshot of the mobile terminal APP refers to the information of all memory objects of the mobile terminal APP in the running process and the reference relationship therebetween. The APP generally reports the memory snapshot file, which is used to find out the memory problem when the memory is abnormal. When the memory snapshot file is relatively large, it not only has an influence on the upload success rate, but also takes a long time to collect and occupies a large amount of traffic. Especially when the memory reaches 1G or even more, the memory snapshot file reaches hundreds of megabytes.

[0004] In view of this situation, the memory snapshot is generally compressed by using a compression tool. However, the compressed file is also dozens of megabytes. The memory of the mobile terminal is large at present. When the memory reaches a large value, the memory snapshot file is very large. Therefore, it is not enough to simply compress the memory snapshot by using the compression tool. SUMMARY

[0005] In view of the above problems, the present application embodiment is proposed to provide a memory object processing method and a corresponding memory object processing device which can overcome the above problems or at least partially solve the above problems.

[0006] In order to solve the above problems, the present application embodiment discloses a memory object processing method, characterized in that the method comprises:

[0007] detecting whether there is an undetected first memory object in the memory;

[0008] if there is an undetected first memory object, obtaining the class corresponding to the first memory object;

[0009] detecting whether to retain the first memory object based on the class;

[0010] if the first memory object is retained, detecting whether the current number of memory objects corresponding to the class reaches a number threshold;

[0011] if the quantity threshold is not reached, obtaining at least one second memory object referenced by the first memory object, and generating reference relationship information of the first memory object and the at least one second memory object;

[0012] updating the current quantity to obtain an updated first latest quantity, and storing the reference relationship information and the first latest quantity.

[0013] In one or more embodiments, further comprising:

[0014] repeating the steps of detecting whether there is an undetected first memory object in the memory, if there is an undetected first memory object, obtaining a class corresponding to the first memory object, detecting whether to retain the first memory object based on the class, if the first memory object is retained, detecting whether a current quantity of memory objects corresponding to the class reaches a quantity threshold, if the quantity threshold is not reached, obtaining at least one second memory object referenced by the first memory object, and generating reference relationship information of the first memory object and the at least one second memory object, updating the current quantity to obtain an updated first latest quantity, and storing the reference relationship information and the first latest quantity, until there is no undetected first memory object in the memory, obtaining all generated reference relationship information;

[0015] generating a memory snapshot of the memory based on the all reference relationship information and the first latest quantity.

[0016] In one or more embodiments, further comprising:

[0017] if the quantity threshold is reached, updating the current quantity to obtain an updated second latest quantity, and storing the second latest quantity.

[0018] In one or more embodiments, further comprising:

[0019] repeating the steps of detecting whether there is an undetected first memory object in the memory, if there is an undetected first memory object, obtaining a class corresponding to the first memory object, detecting whether to retain the first memory object based on the class, if the first memory object is retained, detecting whether a current quantity of memory objects corresponding to the class reaches a quantity threshold, if the quantity threshold is reached, updating the current quantity to obtain an updated second latest quantity, and storing the second latest quantity, until there is no undetected first memory object in the memory, obtaining all generated reference relationship information;

[0020] generating a memory snapshot of the memory based on the all reference relationship information and the second latest quantity.

[0021] In one or more embodiments, the detecting whether to retain the first memory object based on the class comprises:

[0022] retrieving the class in a preset class table; the class table comprises at least one preset class;

[0023] if the retrieval succeeds, determining to retain the first memory object; if the retrieval fails, determining not to retain the first memory object.

[0024] In one or more embodiments, the method further comprises:

[0025] updating the current quantity to obtain an updated first latest quantity, comprising:

[0026] adding 1 to the current quantity to obtain the updated first latest quantity;

[0027] updating the current quantity to obtain an updated second latest quantity, comprising:

[0028] adding 1 to the current quantity to obtain the updated second latest quantity.

[0029] Correspondingly, the embodiment of the application discloses a memory object processing device, characterized in that the device comprises:

[0030] a detection module configured to detect whether there is an undetected first memory object in the memory;

[0031] an acquisition module configured to, if there is the undetected first memory object, acquire a class corresponding to the first memory object;

[0032] the detection module is further configured to detect whether to retain the first memory object based on the class;

[0033] the detection module is further configured to, if the first memory object is retained, detect whether a current quantity of a memory object corresponding to the class reaches a quantity threshold value;

[0034] the acquisition module is further configured to, if the quantity threshold value is not reached, acquire at least one second memory object referenced by the first memory object;

[0035] a first generation module configured to generate reference relationship information of the first memory object and the at least one second memory object;

[0036] an updating module configured to update the current quantity to obtain an updated first latest quantity;

[0037] a storage module configured to store the reference relationship information and the first latest quantity.

[0038] In one or more embodiments, further comprising:

[0039] repeatedly invoking the detection module, the acquisition module, the first generation module, the updating module and the storage module until there is no undetected first memory object in the memory, the acquisition module is further configured to acquire all generated reference relationship information.

[0040] a second generation module configured to generate a memory snapshot of the memory based on the all generated reference relationship information and the second latest number.

[0041] In one or more embodiments, the updating module is further configured to update the current number to obtain an updated second latest number if a quantity threshold is reached.

[0042] The storage module is further configured to store the second latest number.

[0043] In one or more embodiments, further comprising:

[0044] repeatedly invoking the detection module, the acquisition module, the updating module and the storage module until there is no undetected first memory object in the memory, the acquisition module is further configured to acquire all generated reference relationship information.

[0045] a third generation module configured to generate a memory snapshot of the memory based on the all generated reference relationship information and the second latest number.

[0046] In one or more embodiments, the detection module comprises:

[0047] a retrieval sub-module configured to search the class in a preset class table, the class table comprising at least one preset class.

[0048] a determination sub-module configured to determine to retain the first memory object if the search is successful, and determine not to retain the first memory object if the search fails.

[0049] In one or more embodiments, the updating module is specifically configured to:

[0050] add 1 to the current number to obtain an updated first latest number.

[0051] Correspondingly, an electronic device is disclosed, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, the computer program being executed by the processor to implement each step of the above memory object processing method embodiment.

[0052] Correspondingly, the embodiment of the application discloses a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize each step of the memory object processing method embodiment.

[0053] The embodiment of the application has the following advantages:

[0054] For all memory objects in the memory, it is detected whether there is an undetected first memory object in the memory; if there is an undetected first memory object, the class corresponding to the first memory object is obtained; then, it is detected whether to retain the first memory object based on the class; if the first memory object is retained, it is detected whether the current number of memory objects corresponding to the class reaches a number threshold; if the number threshold is not reached, at least one second memory object referenced by the first memory object is obtained, and reference relationship information of the first memory object and the at least one second memory object is generated; the current number is updated to obtain an updated first latest number, and the reference relationship information and the first latest number are stored. In this way, all memory objects in the memory are filtered based on the class, so that the memory objects corresponding to important and effective classes are retained, thereby greatly reducing the size of the subsequent generated memory snapshot. Moreover, when the memory objects of the same class are traversed, the reference relationship information of all memory objects of the class does not need to be generated, and the reference relationship information of a preset number of memory objects can be generated, thereby greatly reducing the number of repeated traversals and the number of repeated generations of reference relationship information, and thereby greatly reducing the time for generating the subsequent memory snapshot, and further reducing the size of the subsequent generated memory snapshot. BRIEF DESCRIPTION OF DRAWINGS

[0055] Figure 1 is a step flowchart of a memory object processing method embodiment one of the application;

[0056] Figure 2 is a memory object reference relationship diagram of the application Figure 1 ;

[0057] Figure 3 is a memory object reference relationship diagram of the application Figure 2 ;

[0058] Figure 4 is a step flowchart of a memory object processing method embodiment two of the application;

[0059] Figure 5 is a step flowchart of a memory object processing method embodiment three of the application;

[0060] Figure 6 is a complete logic flowchart of a memory object processing method embodiment of the application;

[0061] Figure 7 is a structural block diagram of an embodiment of a processing device of a memory object of the present application. DETAILED DESCRIPTION

[0062] In order to make the above-mentioned objectives, features and advantages of the present application more obvious and easy to understand, the present application will be further described in detail below with reference to the drawings and specific embodiments.

[0063] One of the core ideas of the embodiments of the present application is that, for all memory objects in the memory, it is detected whether there is an undetected first memory object in the memory; if there is an undetected first memory object, the class corresponding to the first memory object is obtained; then it is detected whether to retain the first memory object based on the class; if the first memory object is retained, it is detected whether the current number of memory objects corresponding to the class reaches a number threshold; if the number threshold is not reached, at least one second memory object referenced by the first memory object is obtained, and reference relationship information of the first memory object and the at least one second memory object is generated; the current number is updated to obtain an updated first latest number, and the reference relationship information and the first latest number are stored. In this way, all memory objects in the memory are filtered based on the class, thereby retaining the memory objects corresponding to the important and effective class, and thereby greatly reducing the size of the subsequently generated memory snapshot. Moreover, when traversing the memory objects of the same class, it is not necessary to generate the reference relationship information of all memory objects of the class, and the reference relationship information of a preset number of memory objects can be generated, thereby greatly reducing the number of repeated traversals and the number of repeated generations of reference relationship information, and thereby greatly reducing the time for generating the subsequent memory snapshot, and further reducing the size of the subsequently generated memory snapshot.

[0064] Reference Figure 1 Fig. 1 shows a step flowchart of an embodiment of a memory object processing method of the present application, which can specifically include the following steps:

[0065] Step 101, detecting whether there is an undetected first memory object in the memory;

[0066] Specifically, since all memory objects in the memory need to be traversed when generating a memory snapshot, it can be detected in real time whether there is an undetected memory object in the memory, which is referred to as a "first memory object" for convenience of distinction.

[0067] Step 102, if there is an undetected first memory object, obtaining the class corresponding to the first memory object;

[0068] Specifically, when it is detected that there is any undetected first memory object in the memory, the class corresponding to the any first memory object is obtained.

[0069] Step 103: Detect whether the first memory object should be retained based on the class;

[0070] After obtaining the class corresponding to the first memory object, check whether the class meets the preset conditions. If it does, keep the first memory object; otherwise, filter out the first memory object and continue to check whether there are any unchecked memory objects.

[0071] In this embodiment of the invention, the step of detecting whether to retain the first memory object based on the class includes:

[0072] The class is used to perform a search in a preset class table; the class table includes at least one preset class.

[0073] If the retrieval is successful, the first memory object is retained; if the retrieval fails, the first memory object is not retained.

[0074] Specifically, before generating a memory snapshot, a class table can be preset, including at least one preset class. The preset class can be any custom class created in the current project. During detection, the class corresponding to the first memory object can be searched in the class table. If the search is successful, the first memory object is considered valid. If the search fails, the memory object is determined to be a memory object created by a class not created in the current project. Therefore, it is not referenced by memory objects of custom classes in other projects and has no reference value for generating a memory snapshot; thus, the first memory object is filtered out.

[0075] Furthermore, you can determine whether it is referenced by a memory object of a custom class in another project using the following method.

[0076] When iterating over any memory object, there is no need to check whether it is referenced by other memory objects, because when iterating over the memory object of a custom class, the memory objects of non-custom classes referenced by the memory object of that custom class will also be checked, so there is no need to check repeatedly.

[0077] For example, such as Figure 2 The memory object reference diagram shown has the following addresses: memory object a is at address A, memory object b is at address G, memory object c is at address U, memory object d is at address α, and memory object e is at address α1. Among these, memory objects a and b are memory objects of custom classes, while memory objects c, d, and e are memory objects of system classes.

[0078] During the traversal of memory objects a, b, c, d, and e, the memory objects a and b of the custom classes are retained, while the memory objects c, d, and e of the system classes are filtered. Since memory object c is actually referenced by memory object b, it can be found while traversing memory object b and will not be lost. However, because memory object e is referenced by another system class memory object d, it has almost no reference value and can be filtered out.

[0079] Furthermore, when traversing memory objects, after filtering out memory objects corresponding to non-custom classes, it's necessary to further filter the reference relationship information of custom classes. In practical applications, the main reason for needing to obtain memory snapshots is that memory usage reaches a relatively high level. At this point, some memory objects may reference hundreds, thousands, or even tens of thousands of memory objects that have not been released. Therefore, when traversing these memory objects, if all memory object reference relationships are traversed and recorded, there will be many duplicate memory objects and duplicate reference relationships. Therefore, it is sufficient to record the number of identical memory objects and retain only a small amount of reference relationship information.

[0080] For example, such as Figure 3 The memory object reference diagram shown illustrates this: memory object 'a' of class A has the address A1, memory object 'b' of class A has the address A2, and memory object 'a' references memory object 'c' of class C with the address G1. If there are 10,000 memory objects of class A, then there are 10,000 memory objects of class A pointing to memory objects of class C. Only a small amount of data is needed to identify their relationships. Therefore, the number of memory objects of the same class and the detailed reference relationships can be limited, while the correct number of memory objects can be recorded. For example, there may be 10,000 memory objects of class A, but only 20 copies of the reference relationship information can be retained. This can significantly reduce the number of memory snapshots and also avoid repeatedly traversing the same memory object reference relationships, thus reducing snapshot generation time.

[0081] Step 104: If the first memory object is retained, then check whether the current number of memory objects corresponding to the class has reached the number threshold.

[0082] After retaining the first memory object, we can further count the current number of memory objects corresponding to that class, and then check whether the current number has reached the number threshold.

[0083] For example, if the class corresponding to a memory object k is K, after retaining a certain memory object k, the current number of memory objects corresponding to K (excluding k) m is counted, and then it is checked whether m has reached the number threshold.

[0084] If the current quantity does not reach the quantity threshold, the first memory object references at least one second memory object, and reference relationship information of the first memory object and the at least one second memory object is generated;

[0085] If the current quantity does not reach the quantity threshold, all memory objects referenced by the first memory object (referred to as "second memory objects" for convenience) are acquired, and reference relationship information of the first memory object and all second memory objects is generated. For example, if the memory object k references 100 memory objects, reference relationship information of k and the 100 memory objects is generated.

[0086] In step 106, the current quantity is updated to obtain an updated first latest quantity, and the reference relationship information and the first latest quantity are stored.

[0087] After the reference relationship information is generated, the current quantity of the class is updated to obtain an updated latest quantity (referred to as "first latest quantity" for convenience), and the reference relationship information and the first latest quantity are stored, so that after all memory objects are traversed, the final latest quantity of all stored reference relationship information is used to generate a memory snapshot.

[0088] In the embodiment of the present application, updating the current quantity to obtain an updated first latest quantity comprises:

[0089] The current quantity is added by 1 to obtain the updated first latest quantity.

[0090] Specifically, since the detection is performed on a certain memory object, after the detection on the memory object is completed, the current quantity is added by 1 to obtain the updated first latest quantity. For example, after the memory object k is reserved, the current quantity corresponding to k is 15, which does not reach the quantity threshold 20, so after the reference relationship information of k is generated, the current quantity is added by 1 to obtain the latest quantity (i.e., 16).

[0091] In the embodiment of the present application, for all memory objects in the memory, it is detected whether there is an undetected first memory object in the memory; if there is an undetected first memory object, a class corresponding to the first memory object is acquired; then it is detected whether to retain the first memory object based on the class; if the first memory object is retained, it is detected whether a current quantity of memory objects corresponding to the class reaches a quantity threshold; if the quantity threshold is not reached, at least one second memory object referenced by the first memory object is acquired, and reference relationship information of the first memory object and the at least one second memory object is generated; the current quantity is updated to obtain an updated first latest quantity, and the reference relationship information and the first latest quantity are stored. In this way, all memory objects in the memory are filtered based on the class, so that memory objects corresponding to important and effective classes are retained, thereby greatly reducing the size of a generated memory snapshot. Moreover, when memory objects of the same class are traversed, reference relationship information of all memory objects of the class does not need to be generated, and reference relationship information of a preset quantity of memory objects can be generated, thereby greatly reducing the number of repeated traversals and the number of repeated generations of reference relationship information, thereby greatly reducing the time for generating a subsequent memory snapshot, and further reducing the size of the generated memory snapshot.

[0092] With reference to Figure 4 An embodiment of a step flowchart of a memory object processing method of the present application is shown, which can specifically include the following steps:

[0093] Step 401, it is detected whether there is an undetected first memory object in the memory;

[0094] Step 402, if there is an undetected first memory object, a class corresponding to the first memory object is acquired;

[0095] Step 403, it is detected whether to retain the first memory object based on the class;

[0096] Step 404, if the first memory object is retained, it is detected whether a current quantity of memory objects corresponding to the class reaches a quantity threshold;

[0097] Step 405, if the quantity threshold is not reached, at least one second memory object referenced by the first memory object is acquired, and reference relationship information of the first memory object and the at least one second memory object is generated;

[0098] Step 406, the current quantity is updated to obtain an updated first latest quantity, and the reference relationship information and the first latest quantity are stored;

[0099] The steps 401-406 are substantially the same as the steps 101-106, and details can be referred to the steps 101-106. To avoid repetition, details are not described herein.

[0100] Then, the steps 401-406 are repeatedly executed until there is no undetected first memory object in the memory, and the step 407 is executed to obtain all generated reference relationship information;

[0101] In the step 408, the memory snapshot of the memory is generated based on the all reference relationship information and the first latest quantity.

[0102] Specifically, after all memory objects in the memory are traversed, all stored reference relationship information is obtained, and then the memory snapshot is generated based on the all reference relationship information and the first latest quantity obtained after the final update.

[0103] In the embodiment of the application, for all memory objects in the memory, it is detected whether there is an undetected first memory object in the memory; if there is an undetected first memory object, the class corresponding to the first memory object is obtained; then, it is detected whether to retain the first memory object based on the class; if the first memory object is retained, it is detected whether the current quantity of the memory object corresponding to the class reaches the quantity threshold; if the quantity threshold is not reached, at least one second memory object referenced by the first memory object is obtained, and the reference relationship information between the first memory object and the at least one second memory object is generated; the current quantity is updated to obtain an updated first latest quantity, and the reference relationship information and the first latest quantity are stored; then, the above steps are repeatedly executed until there is no undetected first memory object in the memory, all generated reference relationship information is obtained, and then the memory snapshot of the memory is generated based on the all reference relationship information and the first latest quantity. In this way, all memory objects in the memory are filtered based on the class, so that the memory objects corresponding to important and effective classes are retained, and the size of the generated memory snapshot is greatly reduced. Moreover, when the memory objects of the same class are traversed, the reference relationship information of all memory objects of the class does not need to be generated, and the reference relationship information of a preset quantity of memory objects can be generated, so that the number of repeated traversals and the number of repeated generation of reference relationship information are greatly reduced, and the time for generating the memory snapshot is greatly reduced, and the size of the generated memory snapshot is further reduced.

[0104] Referring to Figure 5 FIG. 5 shows a step flowchart of an embodiment three of the method for processing a memory object, and can include the following steps:

[0105] In the step 501, it is detected whether there is an undetected first memory object in the memory.

[0106] Step 502, if there is an undetected first memory object, obtaining the class corresponding to the first memory object;

[0107] Step 503, detecting whether to retain the first memory object based on the class;

[0108] Step 504, if the first memory object is retained, detecting whether the current quantity of memory objects corresponding to the class reaches a quantity threshold value;

[0109] Wherein, steps 501-504 are substantially the same as steps 101-104, and for brevity, reference is made to steps 101-104, and thus no further description is given.

[0110] Step 505, if the quantity threshold value is reached, updating the current quantity to obtain an updated second latest quantity, and storing the second latest quantity;

[0111] If the current quantity reaches the quantity threshold value, the current quantity of the class is updated to obtain an updated latest quantity (for convenience, recorded as a second latest quantity), and the second latest quantity is stored, so that after the traversal of all memory objects is completed, the final latest quantity of all stored reference relationship information is used to generate a memory snapshot.

[0112] In the embodiment of the application, updating the current quantity to obtain an updated second latest quantity comprises:

[0113] Adding 1 to the current quantity to obtain the updated second latest quantity.

[0114] Specifically, since it is a certain memory object that is detected, after the detection of the memory object is completed, adding 1 to the current quantity can obtain the updated second latest quantity. For example, the class corresponding to the memory object n is N, after the memory object n is retained, the current quantity corresponding to N is 25, which reaches the quantity threshold value 20, and thus adding 1 to the current quantity can directly obtain the latest quantity (i.e. 26).

[0115] Then, steps 501-505 are repeatedly executed until there is no undetected first memory object in the memory, step 506 is executed to obtain all generated reference relationship information;

[0116] Step 507, generating a memory snapshot of the memory based on the all reference relationship information and the second latest quantity.

[0117] Specifically, after all the memory objects in the memory are traversed, all the reference relationship information stored is obtained, and then the memory snapshot is generated based on the all reference relationship information and the second latest quantity obtained after the final update.

[0118] In the embodiment of the present application, for all the memory objects in the memory, it is detected whether there is an undetected first memory object in the memory; if there is an undetected first memory object, the class corresponding to the first memory object is obtained; then it is detected whether to retain the first memory object based on the class; if the first memory object is retained, it is detected whether the current quantity of the memory objects corresponding to the class reaches the quantity threshold; if the quantity threshold is reached, the current quantity is updated to obtain an updated second latest quantity, and the second latest quantity is stored, and then the above steps are repeatedly executed until there is no undetected first memory object in the memory, all the reference relationship information generated is obtained, and then the memory snapshot of the memory is generated based on the all reference relationship information and the first latest quantity. In this way, all the memory objects in the memory are filtered based on the class, so that the memory objects corresponding to the important and effective class are retained, thereby greatly reducing the size of the generated memory snapshot. Moreover, when the memory objects of the same class are traversed, the reference relationship information of all the memory objects of the class does not need to be generated, and the reference relationship information of a preset quantity of memory objects can be generated, thereby greatly reducing the number of repeated traversals and the number of repeated generation of reference relationship information, thereby greatly reducing the time for generating the memory snapshot, and further reducing the size of the generated memory snapshot.

[0119] For the convenience of understanding, Figure 6 The complete logic flowchart of the embodiment of the present application is shown. Specifically, it includes:

[0120] 1) generating a class table;

[0121] 2) detecting whether there is an undetected memory object in the memory, if not, executing 8); if there is, executing 4);

[0122] 3) obtaining the class corresponding to the memory object;

[0123] 4) detecting whether to retain the memory object based on the class and the class table, if retained, executing 5), if not retained, executing 2);

[0124] 5) detecting whether the quantity of the memory objects corresponding to the class reaches the quantity threshold, if not, executing 6), if yes, executing 7);

[0125] 6) obtaining at least one memory object referenced by the memory object, and generating the reference relationship information of the memory object and the at least one memory object referenced;

[0126] 7) the number of the corresponding memory objects of the class plus 1;

[0127] 8) the flow ends.

[0128] It should be noted that, for the method embodiments, for the simplicity of description, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited to the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other order or at the same time. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions involved are not necessarily necessary for the embodiments of the present application.

[0129] Referring to Figure 7 , a structural block diagram of an embodiment of a memory object processing apparatus of the present application is shown, which can specifically include the following modules:

[0130] The detection module 701 is configured to detect whether there is an undetected first memory object in the memory.

[0131] The acquisition module 702 is configured to acquire a class corresponding to the first memory object if there is an undetected first memory object.

[0132] The detection module is further configured to detect whether to retain the first memory object based on the class.

[0133] The detection module is further configured to detect whether the current number of memory objects corresponding to the class reaches a number threshold if the first memory object is retained.

[0134] The acquisition module is further configured to acquire at least one second memory object referenced by the first memory object if the number threshold is not reached.

[0135] The first generation module 703 is configured to generate reference relationship information of the first memory object and the at least one second memory object.

[0136] The update module 704 is configured to update the current number to obtain a first latest number after the update.

[0137] The storage module 705 is configured to store the reference relationship information and the first latest number.

[0138] In the embodiments of the present application, the following are further included:

[0139] The detection module, the acquisition module, the first generation module, the update module and the storage module are repeatedly called until there is no undetected first memory object in the memory, and the acquisition module is further configured to acquire all the generated reference relationship information.

[0140] a second generating module configured to generate a memory snapshot of the memory based on the total reference relationship information and the first latest number.

[0141] In the embodiment of the present application, the updating module is further configured to update the current number to obtain an updated second latest number if the number threshold is reached.

[0142] The storage module is further configured to store the second latest number.

[0143] In the embodiment of the present application, the method further comprises:

[0144] The detection module, the obtaining module, the updating module and the storage module are repeatedly called until there is no undetected first memory object in the memory, and the obtaining module is further configured to obtain all generated reference relationship information.

[0145] a third generating module configured to generate a memory snapshot of the memory based on the total reference relationship information and the second latest number.

[0146] In the embodiment of the present application, the detection module comprises:

[0147] a searching sub-module configured to search in a preset class table using the class; the class table comprises at least one preset class.

[0148] a judging sub-module configured to judge to retain the first memory object if the searching is successful, and to judge not to retain the first memory object if the searching fails.

[0149] In the embodiment of the present application, the updating module is specifically configured to:

[0150] add 1 to the current number to obtain an updated first latest number.

[0151] For the device embodiment, it is basically similar to the method embodiment, so the description is relatively simple, and the related parts refer to the part of the method embodiment.

[0152] The embodiment of the present application further provides an electronic device, comprising:

[0153] The electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program is executed by the processor to realize each process of the memory object processing method embodiment and achieve the same technical effect, and thus the description is omitted here.

[0154] The embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program, the computer program is executed by a processor to realize each process of the memory object processing method embodiment, and the same technical effects can be achieved, and thus details are not repeated herein.

[0155] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments, and the same or similar parts between each embodiment are referred to each other.

[0156] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, device or computer program product. Therefore, the embodiments of the present application can be in the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.

[0157] The embodiments of the present application are described with reference to flowcharts and / or block diagrams according to the method, terminal device (system) and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram and the combination of the flows and / or blocks in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to produce a machine, so that the instructions executed by the computer or other programmable data processing terminal device produce a device for realizing the functions specified in the flowchart and / or block diagram. Figure 1 The device for realizing the functions specified in one flow or multiple flows and / or blocks. Figure 1 The device for realizing the functions specified in one flow or multiple flows and / or blocks.

[0158] These computer program instructions can also be stored in a computer readable storage medium which can guide the computer or other programmable data processing terminal device to work in a specific way, so that the instructions stored in the computer readable storage medium produce a product including instruction devices, which realize the functions specified in the flowchart and / or block diagram. Figure 1 The device for realizing the functions specified in one flow or multiple flows and / or blocks. Figure 1 The device for realizing the functions specified in one flow or multiple flows and / or blocks.

[0159] These computer program instructions can also be loaded into a computer or other programmable data processing terminal device, so that a series of operation steps are performed on the computer or other programmable terminal device to produce a computer implemented process, so that the instructions executed on the computer or other programmable terminal device provide a device for realizing the functions specified in the flowchart and / or block diagram. Figure 1one or more processes and / or blocks Figure 1 the steps of a function specified in one or more blocks.

[0160] While the preferred embodiments of the application have been described, additional variations and modifications can be made to the embodiments by those of skill in the art once they have the benefit of the present disclosure. Therefore, the appended claims are intended to encompass within their scope all possible alternatives and modifications to the embodiments. What is claimed is:

[0161] Finally, it should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting. It is further noted that, as used herein, the singular forms "a", "an" and "the" include plural references unless the context clearly dictates otherwise. The terms "comprises", "comprising", "includes", "including" and "contains", "containing" as used herein, are intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus that comprises, includes, or contains one or more elements or steps does not include only those one or more elements or steps but can include other elements or steps not expressly listed or inherent to such process, method, article, or apparatus. The use of the terms "first", "second", and the like does not imply any physical or logical ordering of the elements or steps described and / or illustrated herein.

[0162] The above provides a memory object processing method and a memory object processing device, and the principles and implementation manners of the present application are described by using specific examples. The above description of the embodiments is only used to help understand the method of the present application and its core idea. Meanwhile, for those skilled in the art, the specific implementation manners and application scope can be changed according to the idea of the present application. In summary, the content of the specification should not be understood as a limitation of the present application.

Claims

1. A method for processing memory objects, characterized in that, The method includes: Check if there is an undetected first memory object in memory; If an undetected first memory object exists, then obtain the class corresponding to the first memory object; The system checks whether to retain the first memory object based on a preset class table. If the first memory object is retained, then check whether the current number of memory objects corresponding to the class has reached the number threshold; If the quantity threshold is not reached, at least one second memory object referenced by the first memory object is obtained, and reference relationship information between the first memory object and the at least one second memory object is generated. The current quantity is updated to obtain the updated first latest quantity, and the reference relationship information and the first latest quantity are stored. If the quantity threshold is reached, the current quantity is updated to obtain the updated second latest quantity, and the generated reference relationship information and the second latest quantity are stored. The class table includes at least one preset class; the preset class is all custom classes created in the current project, and the quantity threshold is used to limit the number of records of reference relationship information of memory objects corresponding to the same class; The step of detecting whether to retain the first memory object based on a preset class table includes: The class is used to perform a search in a preset class table; the class table includes at least one preset class. If the retrieval is successful, the first memory object is retained; if the retrieval fails, the first memory object is not retained.

2. The method for processing memory objects according to claim 1, characterized in that, Also includes: Repeat the process of checking whether an undetected first memory object exists in memory; If an undetected first memory object exists, then obtain the class corresponding to the first memory object; Based on the class, determine whether to retain the first memory object; If the first memory object is retained, then check whether the current number of memory objects corresponding to the class has reached the number threshold; If the quantity threshold is not reached, at least one second memory object referenced by the first memory object is obtained, and reference relationship information between the first memory object and the at least one second memory object is generated. The steps of updating the current quantity to obtain the updated first latest quantity and storing the reference relationship information and the first latest quantity continue until there are no undetected first memory objects in the memory, at which point all generated reference relationship information is obtained. A memory snapshot of the memory is generated based on all the reference relationship information and the first latest quantity.

3. The method for processing memory objects according to claim 1, characterized in that, Also includes: Repeatedly execute the check to see if there is an undetected first memory object in memory; If an undetected first memory object exists, then obtain the class corresponding to the first memory object; Based on the class, determine whether to retain the first memory object; If the first memory object is retained, then check whether the current number of memory objects corresponding to the class has reached the number threshold; If the quantity threshold is reached, the current quantity is updated to obtain the updated second latest quantity; The step of storing the second latest quantity continues until there are no undetected first memory objects in the memory, at which point all generated reference relationship information is obtained; A memory snapshot of the memory is generated based on all the reference relationship information and the second latest quantity.

4. The method for processing memory objects according to claim 1, characterized in that, The current quantity is updated to obtain the first latest quantity, including: Increment the current quantity by 1 to obtain the updated first latest quantity; The current quantity is updated to obtain the updated second latest quantity, including: Increment the current quantity by 1 to obtain the updated second latest quantity.

5. A memory object processing apparatus, characterized in that, The device includes: The detection module is used to detect whether there is an undetected first memory object in memory; The acquisition module is used to acquire the class corresponding to the first memory object if there is an undetected first memory object; The detection module is also used to detect whether the first memory object is retained based on a preset class table; The detection module is further configured to detect whether the current number of memory objects corresponding to the class has reached a number threshold if the first memory object is retained. The acquisition module is further configured to acquire at least one second memory object referenced by the first memory object if the quantity threshold is not reached. The first generation module is used to generate reference relationship information between the first memory object and the at least one second memory object; The update module is used to update the current quantity to obtain the first latest quantity after the update; A storage module is used to store the reference relationship information and the first latest quantity; The class table includes at least one preset class; the preset class is all custom classes created in the current project, and the quantity threshold is used to limit the number of records of reference relationship information of memory objects corresponding to the same class; The update module is further configured to update the current quantity if a quantity threshold is reached, to obtain the updated second latest quantity; The storage module is also used to store the generated reference relationship information and the second latest quantity; The detection module includes: A retrieval submodule is used to perform a retrieval in a preset class table using the class; the class table includes at least one preset class; The determination submodule is used to determine whether to retain the first memory object if the retrieval is successful, and whether to retain the first memory object if the retrieval fails.

6. The memory object processing apparatus according to claim 5, characterized in that, Also includes: The detection module, the acquisition module, the first generation module, the update module, and the storage module are repeatedly called until there are no undetected first memory objects in the memory. The acquisition module is also used to acquire all generated reference relationship information. The second generation module is used to generate a memory snapshot of the memory based on all the reference relationship information and the first latest quantity.

7. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for processing the memory object as described in any one of claims 1 to 4.

8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the steps of the method for processing a memory object as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Memory analysis method and device, system and computing device

    CN107967205A

  • Memory processing method and device, electronic equipment and computer readable storage medium

    CN111694673A