Bitmap processing method and device, electronic equipment and readable storage medium
By processing bitmap objects in smart TVs with low memory, the method addresses performance issues by releasing unnecessary memory, improving efficiency and stability.
Patent Information
- Application Number
- CN202510388720.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-07-15
AI Technical Summary
Low-performance smart TVs have obvious lags and crashes when running applications, mainly due to insufficient memory, which makes the application difficult to run properly.
By obtaining the heap memory analysis file of the electronic device, parsing and determining the bitmap object of the current application interface, releasing other bitmap objects except the target bitmap object, and adjusting the image format or resolution of the bitmap object to reduce memory usage.
It effectively releases unnecessary memory resources, improves the operating efficiency of electronic devices, improves equipment performance, avoids lags and crashes, and improves application stability and compatibility.
Smart Images

Figure CN120315874A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and in particular, to a bitmap processing method, apparatus, electronic device, and readable storage medium. Background Art
[0002] With the development of technologies, smart TVs are being rapidly popularized. However, due to the relatively long update cycle of smart TVs themselves, there are still a large number of low-performance smart TVs in the existing stock, such as those with a memory less than 1 GB, or even less than 512 MB. Moreover, since the memory occupation of application programs generally reaches several hundred megabytes, it is difficult for these applications to run properly on smart TVs with low memory. For example, these application programs will cause obvious lags, crashes, etc. during startup, page switching, playing, etc., thus affecting the user experience.
[0003] It can be seen that there are obvious problems such as lags and crashes in the process of running application programs in smart TVs in the related technologies. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a bitmap processing method, apparatus, electronic device, and readable storage medium to solve the obvious problems such as lags and crashes in the process of running application programs in smart TVs in the related technologies. The specific technical solutions are as follows:
[0005] In the first aspect implemented by the present invention, a bitmap processing method is provided, which is applied to an electronic device and includes:
[0006] Obtain a heap memory analysis file of the electronic device at a target moment, where the heap memory analysis file is used to represent the memory snapshot of the electronic device at the target moment;
[0007] Parse the heap memory analysis file to obtain a plurality of bitmap objects;
[0008] Determine the application page to which each bitmap object in the plurality of bitmap objects belongs;
[0009] Determine the bitmap objects in the application page of the current application interface as target bitmap objects;
[0010] Release other bitmap objects in the plurality of bitmap objects except the target bitmap objects.
[0011] Optionally, after determining the bitmap objects in the application page of the current application interface as target bitmap objects, the method further includes:
[0012] Obtain the bitmap parameters of each bitmap object in the plurality of bitmap objects, where the bitmap parameters include image resolution or image format;
[0013] Mark the bitmap objects among the multiple bitmap objects whose bitmap parameters meet the preset conditions as the first bitmap objects;
[0014] When the target bitmap object is included in the first bitmap objects, adjust the bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object, and update the target bitmap object before adjustment to the adjusted target bitmap object.
[0015] Optionally, when the bitmap parameter is the image format, the adjusting the bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object includes:
[0016] Adjust the image format of the target bitmap object so that the memory occupancy rate of the image format of the adjusted target bitmap object is less than or equal to the preset memory occupancy rate of the electronic device.
[0017] Optionally, when the bitmap parameter is the image resolution, the adjusting the bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object includes:
[0018] Reduce the image resolution of the target bitmap object so that the image resolution of the target bitmap object is less than or equal to the device resolution of the electronic device.
[0019] Optionally, after adjusting the bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object and updating the target bitmap object before adjustment to the adjusted target bitmap object when the target bitmap object is included in the first bitmap objects, the method further includes:
[0020] Generate a bitmap object processing report, where the bitmap object processing report includes a parameter adjustment log for adjusting the bitmap parameters and picture information of the adjusted target bitmap object.
[0021] Optionally, the determining the application page to which each bitmap object among the multiple bitmap objects belongs includes:
[0022] Obtain the window information of each bitmap object among the multiple bitmap objects;
[0023] Based on the context information corresponding to the window information of each bitmap object, determine the application page to which the window information of each bitmap object belongs, and determine the application page to which the window information of each bitmap object belongs as the application page to which the corresponding bitmap object belongs.
[0024] In a second aspect of the implementation of the present invention, there is provided a bitmap processing apparatus applied to an electronic device, including:
[0025] A first acquisition module, configured to acquire a heap memory analysis file of the electronic device at a target moment, where the heap memory analysis file is used to characterize a memory snapshot of the electronic device at the target moment;
[0026] A parsing module, configured to parse the heap memory analysis file to obtain a plurality of bitmap objects;
[0027] A first determination module, configured to determine an application page to which each bitmap object in the plurality of bitmap objects belongs;
[0028] A second determination module, configured to determine a bitmap object in an application page in a current application interface as a target bitmap object;
[0029] A release module, configured to release other bitmap objects in the plurality of bitmap objects except the target bitmap object.
[0030] Optionally, the apparatus further includes:
[0031] A second acquisition module, configured to acquire bitmap parameters of each bitmap object in the plurality of bitmap objects, where the bitmap parameters include an image resolution or an image format;
[0032] A marking module, configured to mark a bitmap object whose bitmap parameters in the plurality of bitmap objects meet a preset condition as a first bitmap object;
[0033] An adjustment module, configured to, when the first bitmap object includes the target bitmap object, adjust bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object, and update the target bitmap object before adjustment to the adjusted target bitmap object.
[0034] Optionally, the adjustment module is specifically configured to adjust an image format of the target bitmap object, so that a memory occupancy rate of the adjusted image format of the target bitmap object is less than or equal to a preset memory occupancy rate of the electronic device.
[0035] Optionally, the adjustment module is specifically configured to reduce an image resolution of the target bitmap object, so that the image resolution of the target bitmap object is less than or equal to a device resolution of the electronic device.
[0036] Optionally, the apparatus further includes:
[0037] A generation module, configured to generate a bitmap object processing report, where the bitmap object processing report includes a parameter adjustment log for adjusting the bitmap parameters and picture information of the adjusted target bitmap object.
[0038] Optionally, the first determining module is specifically configured to:
[0039] Obtain window information of each bitmap object among the multiple bitmap objects;
[0040] Based on the context information corresponding to the window information of each bitmap object, determine the application page to which the window information of each bitmap object belongs, and determine the application page to which the window information of each bitmap object belongs as the application page to which the corresponding bitmap object belongs.
[0041] In a third aspect of the embodiments of the present invention, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;
[0042] The memory is used to store programs;
[0043] The processor is configured to implement the method described in the first aspect when executing the programs stored on the memory.
[0044] In a fourth aspect of the embodiments of the present invention, a readable storage medium is provided, on which a program is stored, and the program implements the method described in the first aspect when executed by a processor.
[0045] In a fifth aspect of the embodiments of the present invention, a computer program product is provided, including computer instructions, and the computer instructions implement the method described in the first aspect when executed by a processor.
[0046] In the embodiments of the present invention, by releasing other bitmap objects except the target bitmap object among the multiple bitmap objects, that is, by releasing other bitmap objects that do not have the viewable attribute among the multiple bitmap objects, the memory resources occupied by other bitmap objects can be released, thereby improving the running efficiency of the electronic device and improving the device performance of the electronic device, and can effectively avoid obvious problems such as stuttering and crashing during the operation of application programs on electronic devices such as smart TVs. Description of the Drawings
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art.
[0048] Figure 1 It is a flowchart of a bitmap processing method in an embodiment of the present invention;
[0049] Figure 2 It is a structural diagram of a bitmap processing device in an embodiment of the present invention;
[0050] Figure 3 It is a structural diagram of an electronic device in an embodiment of the present invention. Detailed implementation mode
[0051] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work belong to the scope of protection of the present invention.
[0052] Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of the steps can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but there can also be additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0053] In addition, terms such as "first" and "second" can be used in this article to describe various directions, actions, steps, or elements, etc., but these directions, actions, steps, or elements are not limited by these terms. These terms are only used to distinguish the first direction, action, step, or element from another direction, action, step, or element. For example, without departing from the scope of the present invention, the first speed difference can be the second speed difference, and similarly, the second speed difference can be called the first speed difference. Both the first speed difference and the second speed difference are speed differences, but they are not the same speed difference. Terms such as "first" and "second" should not be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, the meaning of "a plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0054] Next, in conjunction with the accompanying drawings, the bitmap processing method provided by the embodiments of the present invention will be described in detail through specific embodiments and their application scenarios.
[0055] See Figure 1 , Figure 1 is a schematic flowchart of a bitmap processing method in an embodiment of the present invention. As Figure 1 shown, the bitmap processing method provided by the embodiments of the present invention can be applied to electronic devices such as smart TVs, and the above bitmap processing method includes the following steps:
[0056] Step 101, obtain the heap memory analysis file of the electronic device at the target moment.
[0057] Among them, the heap memory analysis file is used to represent the memory snapshot of the electronic device at the target moment.
[0058] The above-mentioned target moment can be understood as the current moment, or a specific moment, such as the moment when the current application interface changes, or the moment when entering a preset scenario, etc. And the memory snapshot obtained at the target moment includes the snapshot information corresponding to all the application programs running on the electronic device such as a smart TV at this moment.
[0059] For example, if a smart TV is running application program A, application program B, and application program C at the target moment, and application programs B and C are background-running applications, then the memory snapshot obtained at the target moment includes the memory snapshot of application program A, the memory snapshot of application program B, and the memory snapshot of application program C.
[0060] In some embodiments, the above-mentioned heap memory analysis file may include the following contents:
[0061] All objects, such as the classes, fields, primitive data types, and references corresponding to the objects;
[0062] All classes, such as class loaders (Classloaders), class names, superclasses, and static fields;
[0063] The roots of the garbage collector (Garbage Collection Roots, GC Roots), such as those used in Java garbage collection, and reachability analysis can be performed based on the roots of the garbage collector to determine whether an object can be recycled;
[0064] Thread stacks and local variables.
[0065] For example, in a Java Virtual Machine (JVM), a garbage collector (Garbage Collection, GC) can recycle memory by traversing all reachable objects. Among them, reachability analysis starts from some root objects, and these root objects are called GC Roots. Moreover, GC Roots are reference objects that the garbage collector can access, and all other reachable objects can be found through these objects. In addition, understanding which objects can be used as GC Roots is crucial for optimizing the performance of the garbage collector and avoiding memory leaks.
[0066] In some embodiments, the heap memory analysis file (hprof) file of the application program running on the electronic device can be obtained through the Android Debug Bridge (ADB) tool.
[0067] For example, at the current time point, the current interface of the smart TV is the application interface of the first application, and the second application and the third application are also running in the background. If a heap memory analysis file is obtained at the current time point, the obtained heap memory analysis file includes the memory snapshots of the first application, the second application, and the third application. Correspondingly, if at the current time point, the user switches to the smart TV desktop and opens and enters the application interface of the fourth application, the heap memory analysis file obtained at the current time point includes not only the memory snapshots of the first application, the second application, and the third application, but also the memory snapshot of the fourth application.
[0068] The above target time point can be understood as the time point when the application interface running in the background is switched, the time point when a new application is opened, or the time point when the application corresponding to the current application interface is closed.
[0069] In some embodiments, an automated tool can be designed and developed to obtain a heap memory analysis file based on a preset scenario or a preset period. That is, the target time point can be understood as the time point when the smart TV switches to the preset scenario, or the cycle node time point corresponding to the preset period.
[0070] In some embodiments, for random testing, such as obtaining a heap memory analysis file at a random time point, a machine learning algorithm can be used to improve the effectiveness of the random testing and accurately trigger a memory bottleneck scenario.
[0071] Step 102: Parse the heap memory analysis file to obtain multiple bitmap objects.
[0072] In this step, a bitmap object can be understood as the bitmap image corresponding to the image included in a certain application interface. Among them, a bitmap image is also called a dot matrix image or a raster image, and is composed of individual points called pixels (picture elements).
[0073] If the heap memory analysis file includes the memory snapshots of the first application, the second application, and the third application, and the application interface of the first application includes a first image, the application interface of the second application includes a second image and a third image, and the application interface of the third application includes a fourth image, by parsing the heap memory analysis file, the bitmap object 1 corresponding to the first image, the bitmap image 2 corresponding to the second image, the bitmap object 3 corresponding to the third image, and the bitmap object 4 corresponding to the fourth image can be obtained.
[0074] In some embodiments, the heap memory analysis file can be imported into a parsing tool first, and then the memory usage can be analyzed through various views and functions provided by the parsing tool. By analyzing the memory usage, problem objects such as objects that occupy a large amount of memory or survive for a long time can be identified, thereby realizing the parsing and acquisition of bitmap objects.
[0075] It can be understood that during the process of parsing the heap memory analysis file, not only can the corresponding multiple bitmap objects be obtained, but also information such as the image resolution and image format of each bitmap object can be obtained.
[0076] Step 103: Determine the application page to which each bitmap object among the multiple bitmap objects belongs.
[0077] In this step, a chain analysis strategy can be adopted to determine the application page to which each bitmap object belongs.
[0078] For example, since the heap memory analysis file includes the roots of the garbage collector, the application page to which each bitmap object belongs can be found based on the reachability analysis ability of the roots of the garbage collector.
[0079] Step 104: Determine the bitmap objects in the application page of the current application interface as target bitmap objects.
[0080] In this step, the application page of the current application interface can be determined based on the heap memory analysis file, and the bitmap objects in the application page of the current application interface can be determined as target bitmap objects.
[0081] For example, when the current application interface is the application page of the first application, the bitmap objects included in the application page of the first application can be determined as target bitmap objects. That is, for the user, only the target bitmap objects in the current application interface have the viewable attribute, and the other bitmap objects among the multiple bitmap objects do not have the viewable attribute.
[0082] Step 105: Release the other bitmap objects among the multiple bitmap objects except the target bitmap objects.
[0083] In this step, by releasing the other bitmap objects among the multiple bitmap objects except the target bitmap objects, that is, by releasing the other bitmap objects that do not have the viewable attribute among the multiple bitmap objects, the memory resources occupied by the other bitmap objects can be released, thereby improving the running efficiency of the electronic device, improving the device performance of the electronic device, and effectively avoiding obvious problems such as stuttering and crashing during the operation of application programs on electronic devices such as smart TVs.
[0084] Among them, the above target bitmap object can be understood as the bitmap object corresponding to the image in the current application interface, and other bitmap objects can be understood as the bitmap objects corresponding to the images in the application interfaces of the applications running in the background; therefore, by releasing other bitmap objects, not only will the user experience not be affected, but also the memory resources occupied by other bitmap objects can be reduced, and the events of application unresponsiveness and application crashing can be reduced, improving the stability of the application.
[0085] In this embodiment, by parsing the heap memory analysis file, multiple bitmap objects are obtained, and other bitmap objects among the multiple bitmap objects are released, that is, by releasing the bitmap objects corresponding to the images in the application interfaces of the applications running in the background, the memory resources occupied by other bitmap objects can be effectively reduced, the operation efficiency of the electronic device is improved, and the device performance of the electronic device is improved.
[0086] In addition, by reducing the memory resources occupied by other bitmap objects, the compatibility and operation efficiency of the application on low-performance devices can also be improved, the service life of this type of electronic device is extended, and the user satisfaction is improved.
[0087] In some embodiments, step 103 specifically includes:
[0088] Obtain the window information of each bitmap object among the multiple bitmap objects;
[0089] Based on the context information corresponding to the window information of each bitmap object, determine the application page to which the window information of each bitmap object belongs, and determine the application page to which the window information of each bitmap object belongs as the application page to which the corresponding bitmap object belongs.
[0090] The above context information can be understood as different application pages of the same application program. For example, if the application program A running in the background has three application pages, and the middle application page among the three application pages includes a bitmap object, then the other two application pages can be determined as the context information corresponding to the window information of this bitmap object.
[0091] In this embodiment, by obtaining the window information of the bitmap object and the context information corresponding to the window information, the application page to which the window information of the bitmap object belongs can be determined, and then the application page to which the bitmap object belongs can be determined.
[0092] In some embodiments, after step 104, the method further includes:
[0093] Obtain the bitmap parameters of each bitmap object among the multiple bitmap objects, where the bitmap parameters include image resolution or image format;
[0094] Mark the bitmap objects among the multiple bitmap objects whose bitmap parameters meet the preset conditions as the first bitmap objects;
[0095] When the target bitmap object is included in the first bitmap objects, adjust the bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object, and update the target bitmap object before adjustment to the adjusted target bitmap object.
[0096] In this embodiment, when the target bitmap object is included in the first bitmap objects, that is, when the target bitmap object on the current application interface belongs to the marked first bitmap objects, the bitmap parameters of the target bitmap object can be adjusted to obtain the adjusted target bitmap object, and the target bitmap object before adjustment is updated to the adjusted target bitmap object. This can reduce the memory occupancy rate of the target bitmap object, thereby reducing the memory resources occupied by the target bitmap object. In addition, it also improves the operating efficiency of the electronic device and improves the device performance of the electronic device.
[0097] Among them, updating the target bitmap object before adjustment to the adjusted target bitmap object can be understood as replacing the target bitmap object before adjustment with the adjusted target bitmap object to achieve the update of the bitmap object. Among them, the replacement and update operation of the bitmap object can be implemented based on the bitmap object update and replacement plug-in to achieve the replacement and update of the bitmap object. Compared with the background operator manually implementing the replacement and update of the bitmap object, it effectively improves the update efficiency of the replacement and update of the bitmap object.
[0098] In some embodiments, the above-mentioned bitmap parameters meeting the preset conditions include at least one of the following:
[0099] The memory occupancy rate of the image format of the bitmap object is greater than the preset memory occupancy rate of the electronic device;
[0100] The image resolution of the bitmap object is greater than the device resolution of the electronic device.
[0101] Among them, when the memory occupancy rate of the image format is greater than the preset memory occupancy rate of the electronic device, the image format of the target bitmap object can be adjusted so that the memory occupancy rate of the image format of the adjusted target bitmap object is less than or equal to the preset memory occupancy rate of the electronic device.
[0102] The above-mentioned adjustment of the image format of the target bitmap object can be understood as adjusting the image format of the target bitmap object from image format A to image format B to reduce the memory occupancy rate of the target bitmap object.
[0103] Among them, the adjustment of the image format can be implemented based on an image format adjustment plugin to achieve automatic adjustment of the image format. Compared with the background operator changing the image format of the bitmap object by means of save as, the adjustment efficiency of the image format of the bitmap object is effectively improved.
[0104] Among them, in the case where the image resolution is greater than the device resolution of the electronic device, the image resolution of the target bitmap object can be reduced so that the image resolution of the target bitmap object is less than or equal to the device resolution of the electronic device.
[0105] The above reduction of the image resolution of the target bitmap object can be understood as reducing the image resolution of the target bitmap object from a high resolution to a low resolution to reduce the memory occupancy rate of the target bitmap object.
[0106] Among them, the adjustment of the image resolution can be implemented based on an image resolution adjustment plugin to achieve automatic adjustment of the image resolution. Compared with the background operator manually adjusting the image resolution of the bitmap object, the adjustment efficiency of the image resolution of the bitmap object is effectively improved. Among them, in the process of adjusting the image resolution of the bitmap object through the image resolution adjustment plugin, the image resolution can be adjusted by adjusting the horizontal value of the pixels of the bitmap object.
[0107] For example, if the target bitmap object is in the 4-channel color mode (Alpha Red Green Blue, ARGB) format, then its memory size should be 4 times the resolution of the electronic device; if the target bitmap object is in the RGB565 format, then its memory size should be 2 times the resolution of the electronic device; therefore, when it is determined that the memory occupancy rate of the image format of the target bitmap object is greater than the memory occupancy rate of the preset picture format, the image format of the target bitmap object can be adjusted to an image format with a low memory occupancy rate to reduce the memory occupancy rate of the target bitmap object, thereby reducing the memory resources occupied by the target bitmap object.
[0108] In some embodiments, not only can the bitmap parameters of the target bitmap object be adjusted, but also bitmap objects whose bitmap parameters in other bitmap objects meet preset conditions can be marked.
[0109] In some embodiments, if multiple bitmap objects include a target bitmap object belonging to the current application interface, a bitmap object a belonging to a second application running in the background, and a bitmap object b belonging to a third application running in the background; not only can it be analyzed whether the bitmap parameters of the target bitmap object meet the preset conditions, but also whether the bitmap parameters of the bitmap object a and the bitmap object b meet the preset conditions. If the analysis result indicates that the bitmap parameters of the bitmap object b meet the preset conditions and the bitmap parameters of the bitmap object a do not meet the preset conditions, then the bitmap object b and the target bitmap object can be marked as the first bitmap object, and the corresponding marking information can be obtained.
[0110] Among them, when the current interface switches from the application interface to which the target bitmap object belongs to the first application interface, it is possible to first identify whether the first application interface has a bitmap object with marking information. If it is identified that there is a bitmap object b with marking information, then the bitmap parameters of the bitmap object b can be quickly adjusted based on the marking information to reduce the memory occupancy rate of the bitmap object b, thereby reducing the memory resources occupied by the bitmap object b; if no bitmap object with marking information is identified, then the bitmap parameters of the bitmap objects in the first application interface can be not adjusted, and at the same time, other bitmap objects except the bitmap objects in the first application interface can be directly released to achieve the purpose of improving the operation efficiency of the electronic device and improving the device performance of the electronic device.
[0111] In some embodiments, after step 104, the method further includes:
[0112] Obtain the bitmap parameters of each bitmap object in the multiple bitmap objects, where the bitmap parameters include image resolution or image format;
[0113] Mark the bitmap objects in the multiple bitmap objects whose bitmap parameters meet the preset conditions as the first bitmap objects;
[0114] In the case that the target bitmap object is included in the first bitmap object, adjust the bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object, and update the target bitmap object before adjustment to the adjusted target bitmap object;
[0115] Generate a bitmap object processing report, where the bitmap object processing report includes a parameter adjustment log for adjusting the bitmap parameters and picture information of the adjusted target bitmap object.
[0116] In this embodiment, by generating a bitmap object processing report, it is convenient for back-end personnel to check the bitmap processing process.
[0117] Moreover, by generating a bitmap object processing report, not only can the visualization of the bitmap processing process be achieved, but also it is convenient for the back-end personnel to perform memory optimization efficiently, such as adjusting the image resolution or image format of the bitmap object, etc., so as to reduce the development and maintenance costs.
[0118] In the embodiment of the present invention, by obtaining the heap memory analysis file of the electronic device at the target moment, the heap memory analysis file is used to represent the memory snapshot of the electronic device at the target moment; parsing the heap memory analysis file to obtain a plurality of bitmap objects; determining the application page to which each bitmap object in the plurality of bitmap objects belongs; determining the bitmap objects in the application page of the current application interface as target bitmap objects; and releasing other bitmap objects in the plurality of bitmap objects except the target bitmap objects. In this way, by releasing other bitmap objects in the plurality of bitmap objects except the target bitmap objects, that is, by releasing other bitmap objects that do not have the viewable attribute in the plurality of bitmap objects, the memory resources occupied by other bitmap objects can be released, thereby improving the running efficiency of the electronic device, improving the device performance of the electronic device, and effectively avoiding obvious problems such as stuttering and crashing during the running of application programs on electronic devices such as smart TVs.
[0119] Such as Figure 2 As shown, the embodiment of the present invention further provides a bitmap processing device, which is applied to an electronic device. The bitmap processing device 200 includes:
[0120] A first acquisition module 201, configured to acquire the heap memory analysis file of the electronic device at the target moment, where the heap memory analysis file is used to represent the memory snapshot of the electronic device at the target moment;
[0121] A parsing module 202, configured to parse the heap memory analysis file to obtain a plurality of bitmap objects;
[0122] A first determination module 203, configured to determine the application page to which each bitmap object in the plurality of bitmap objects belongs;
[0123] A second determination module 204, configured to determine the bitmap objects in the application page of the current application interface as target bitmap objects;
[0124] A release module 205, configured to release other bitmap objects in the plurality of bitmap objects except the target bitmap objects.
[0125] Optionally, the bitmap processing device 200 further includes:
[0126] A second acquisition module, configured to acquire the bitmap parameters of each bitmap object in the plurality of bitmap objects, where the bitmap parameters include image resolution or image format;
[0127] A marking module, configured to mark a bitmap object whose bitmap parameters in the multiple bitmap objects meet a preset condition as a first bitmap object;
[0128] An adjustment module, configured to, when the target bitmap object is included in the first bitmap object, adjust the bitmap parameters of the target bitmap object to obtain the adjusted target bitmap object, and update the target bitmap object before adjustment to the adjusted target bitmap object.
[0129] Optionally, the adjustment module is specifically configured to adjust the image format of the target bitmap object, so that the memory occupancy rate of the image format of the adjusted target bitmap object is less than or equal to a preset memory occupancy rate of the electronic device.
[0130] Optionally, the adjustment module is specifically configured to reduce the image resolution of the target bitmap object, so that the image resolution of the target bitmap object is less than or equal to the device resolution of the electronic device.
[0131] Optionally, the bitmap processing apparatus 200 further includes:
[0132] A generation module, configured to generate a bitmap object processing report, where the bitmap object processing report includes a parameter adjustment log for adjusting the bitmap parameters and picture information of the adjusted target bitmap object.
[0133] Optionally, the first determination module 203 is specifically configured to:
[0134] Obtain window information of each bitmap object in the multiple bitmap objects;
[0135] Based on context information corresponding to the window information of each bitmap object, determine an application page to which the window information of each bitmap object belongs, and determine the application page to which the window information of each bitmap object belongs as the application page to which the corresponding bitmap object belongs.
[0136] The bitmap processing apparatus 200 provided by the embodiment of the present invention can implement Figure 1 each process implemented by the method embodiment shown, and can achieve the same beneficial effects. To avoid repetition, details are not described here again.
[0137] The embodiment of the present invention further provides an electronic device, as Figure 3 shown, the electronic device includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604. Among them, the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604;
[0138] A memory 603 for storing computer programs; a processor 601, when executing the programs stored on the memory 603, implements the following steps:
[0139] Obtain a heap memory analysis file of the electronic device at a target time, where the heap memory analysis file is used to represent a memory snapshot of the electronic device at the target time;
[0140] Parse the heap memory analysis file to obtain a plurality of bitmap objects;
[0141] Determine the application page to which each bitmap object in the plurality of bitmap objects belongs;
[0142] Determine the bitmap objects in the application page of the current application interface as target bitmap objects;
[0143] Release other bitmap objects in the plurality of bitmap objects except the target bitmap objects.
[0144] Optionally, the processor 601 is further configured to implement the following steps when executing the programs stored on the memory 603:
[0145] Obtain bitmap parameters of each bitmap object in the plurality of bitmap objects, where the bitmap parameters include image resolution or image format;
[0146] Mark the bitmap objects whose bitmap parameters in the plurality of bitmap objects meet a preset condition as first bitmap objects;
[0147] In the case that the first bitmap objects include the target bitmap objects, adjust the bitmap parameters of the target bitmap objects to obtain the adjusted target bitmap objects, and update the target bitmap objects before adjustment to the adjusted target bitmap objects.
[0148] Optionally, the processor 601 is further configured to implement the following steps when executing the programs stored on the memory 603:
[0149] Adjust the image format of the target bitmap object so that the memory occupancy rate of the adjusted image format of the target bitmap object is less than or equal to the preset memory occupancy rate of the electronic device.
[0150] Optionally, the processor 601 is further configured to implement the following steps when executing the programs stored on the memory 603:
[0151] Reduce the image resolution of the target bitmap object so that the image resolution of the target bitmap object is less than or equal to the device resolution of the electronic device.
[0152] Optionally, when the processor 601 is further configured to execute the program stored in the memory 603, the following steps are implemented:
[0153] Generate a bitmap object processing report, where the bitmap object processing report includes a parameter adjustment log for adjusting the bitmap parameters and picture information of the target bitmap object after adjustment.
[0154] Optionally, when the processor 601 is further configured to execute the program stored in the memory 603, the following steps are implemented:
[0155] Obtain the window information of each bitmap object among the multiple bitmap objects;
[0156] Based on the context information corresponding to the window information of each bitmap object, determine the application page to which the window information of each bitmap object belongs, and determine the application page to which the window information of each bitmap object belongs as the application page to which the corresponding bitmap object belongs.
[0157] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0158] The communication interface is used for communication between the above terminal and other devices.
[0159] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0160] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0161] In another embodiment provided by the present invention, there is also provided a computer-readable storage medium, in which instructions are stored. When it runs on a computer, it enables the computer to execute any one of the bitmap processing methods described in the above embodiments and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0162] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions. When it runs on a computer, it enables the computer to execute any one of the bitmap processing methods described in the above embodiments and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0163] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that the computer can access or a data storage device such as a server or data center that includes one or more integrated available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a Solid State Disk (SSD)).
[0164] It should be noted that in this specification, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0165] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference can be made to the corresponding part of the method embodiment for the relevant content.
[0166] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included within the protection scope of the present invention.
Claims
1. A bitmap processing method, characterized in that, Applied to an electronic device, including: Obtain a heap memory analysis file of the electronic device at a target moment, where the heap memory analysis file is used to represent a memory snapshot of the electronic device at the target moment; Parse the heap memory analysis file to obtain a plurality of bitmap objects; Determine the application page to which each bitmap object in the plurality of bitmap objects belongs; Determine the bitmap objects in the application page of the current application interface as target bitmap objects; Release other bitmap objects in the plurality of bitmap objects except the target bitmap objects.
2. The method according to claim 1, characterized in that After determining the bitmap objects in the application page of the current application interface as target bitmap objects, the method further includes: Obtain bitmap parameters of each bitmap object in the plurality of bitmap objects, where the bitmap parameters include image resolution or image format; Mark the bitmap objects in the plurality of bitmap objects whose bitmap parameters meet a preset condition as first bitmap objects; In the case that the first bitmap objects include the target bitmap objects, adjust the bitmap parameters of the target bitmap objects to obtain the adjusted target bitmap objects, and update the target bitmap objects before adjustment to the adjusted target bitmap objects.
3. The method according to claim 2, wherein In the case that the bitmap parameter is the image format, the adjusting the bitmap parameters of the target bitmap objects to obtain the adjusted target bitmap objects includes: Adjust the image format of the target bitmap object so that the memory occupancy rate of the image format of the adjusted target bitmap object is less than or equal to a preset memory occupancy rate of the electronic device.
4. The method according to claim 2, wherein In the case that the bitmap parameter is the image resolution, the adjusting the bitmap parameters of the target bitmap objects to obtain the adjusted target bitmap objects includes: Reduce the image resolution of the target bitmap object so that the image resolution of the target bitmap object is less than or equal to the device resolution of the electronic device.
5. The method according to any one of claims 2 to 4, characterized in that, After adjusting the bitmap parameters of the target bitmap objects to obtain the adjusted target bitmap objects and updating the target bitmap objects before adjustment to the adjusted target bitmap objects in the case that the first bitmap objects include the target bitmap objects, the method further includes: Generate a bitmap object processing report, where the bitmap object processing report includes a parameter adjustment log for adjusting the bitmap parameters and picture information of the adjusted target bitmap objects.
6. The method according to any one of claims 1 to 4, characterized in that The determining the application page to which each bitmap object in the plurality of bitmap objects belongs includes: Obtain window information of each bitmap object in the plurality of bitmap objects; Based on context information corresponding to the window information of each bitmap object, determine the application page to which the window information of each bitmap object belongs, and determine the application page to which the window information of each bitmap object belongs as the application page to which the corresponding bitmap object belongs.
7. A bitmap processing device, characterized in that, Applied to an electronic device, including: A first obtaining module, configured to obtain a heap memory analysis file of the electronic device at a target moment, where the heap memory analysis file is used to represent a memory snapshot of the electronic device at the target moment; A parsing module, configured to parse the heap memory analysis file to obtain a plurality of bitmap objects; A first determination module, configured to determine the application page to which each bitmap object in the plurality of bitmap objects belongs; A second determination module, configured to determine the bitmap objects in the application pages of the current application interface as target bitmap objects; A release module, configured to release other bitmap objects in the plurality of bitmap objects except the target bitmap objects.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store programs; The processor is configured to implement the method according to any one of claims 1 to 6 when executing the program stored on the memory.
9. A readable storage medium having a program stored thereon, characterized in that, When the program is executed by the processor, it implements the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that, It includes computer instructions, and when the computer instructions are executed by the processor, the steps of the method according to any one of claims 1 to 6 are implemented.
