Data processing method and device, equipment and storage medium
By adjusting the target heap size when the application is running, the increase in memory footprint and application lag caused by frequent garbage collection is solved, and more efficient memory management and smoother user experience is achieved.
Patent Information
- Application Number
- CN202311088454.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-25
- Publication Date
- 2025-02-25
AI Technical Summary
The prior art is difficult to effectively manage garbage collection during application operation, resulting in increased memory usage and application lag.
By obtaining and modifying the address and value of the target parameters when the preset application is run, the target heap size of the garbage collection event is increased, thereby reducing the frequency and activity of garbage collection.
By adjusting the target heap size, reduce the activity of garbage collection events, avoid the lag caused by frequent garbage collection by the application, and improve application performance and user experience.
Smart Images

Figure CN119512977A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular, to data processing methods, devices, equipment, and storage media. Background Art
[0002] When an application is running, many objects that are no longer needed are generated, which can be called garbage objects. Garbage objects will occupy a certain amount of memory space and need to be collected in time to release the memory space occupied by garbage objects. Summary of the invention
[0003] The embodiments of the present disclosure provide a data processing method, apparatus, device, and storage medium, which can optimize existing data processing solutions.
[0004] In a first aspect, an embodiment of the present disclosure provides a data processing method, including:
[0005] When a preset application is running, obtaining an address of a first target parameter, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered;
[0006] According to the address of the first target parameter, the original parameter value of the first target parameter is modified to a target parameter value, so that a first target heap size determined according to the target parameter value is larger than a second target heap size determined according to the original parameter value.
[0007] In a second aspect, the present disclosure also provides a data processing device, including:
[0008] An address acquisition module, used to acquire the address of a first target parameter when a preset application is running, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered;
[0009] The parameter value modification module is used to modify the original parameter value of the first target parameter to a target parameter value according to the address of the first target parameter, so that a first target heap size determined according to the target parameter value is larger than a second target heap size determined according to the original parameter value.
[0010] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0011] one or more processors;
[0012] a storage device for storing one or more programs,
[0013] When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method provided by the embodiment of the present disclosure.
[0014] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to execute the data processing method provided by the embodiment of the present disclosure.
[0015] The data processing scheme provided by the embodiment of the present disclosure obtains the address of the first target parameter when the preset application is running, wherein the parameter value of the first target parameter is used to determine the target heap size when the garbage collection event of the preset application is triggered, and the original parameter value of the first target parameter is adjusted according to the address of the first target parameter, so that the first target heap size determined according to the adjusted target parameter value of the first target parameter is larger than the second target heap size determined according to the original parameter value of the first target parameter. By adopting the above technical scheme, when the application is running, the target heap size for triggering the garbage collection event can be increased by adjusting the parameter value of the target parameter, and the difficulty of triggering the garbage collection event increases with the increase of the target heap size, which can reduce the activity of the garbage collection event, avoid problems such as application freezes caused by frequent garbage collection, improve application performance, and improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0017] Figure 1 A flowchart of a data processing method provided by an embodiment of the present disclosure;
[0018] Figure 2 A parameter relationship diagram provided by an embodiment of the present disclosure;
[0019] Figure 3 A schematic diagram of variable distribution provided by an embodiment of the present disclosure;
[0020] Figure 4 A schematic diagram of another variable distribution provided by an embodiment of the present disclosure;
[0021] Figure 5 A flowchart of another data processing method provided by an embodiment of the present disclosure;
[0022] Figure 6A schematic diagram of the structure of a data processing device provided by an embodiment of the present disclosure;
[0023] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0025] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0026] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0027] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0028] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0029] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0030] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0031] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0032] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0033] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0034] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0035] Figure 1 A data processing flow diagram provided for an embodiment of the present disclosure is applicable to data processing scenarios. The method can be executed by a data processing device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal such as a mobile phone, a smart watch, a tablet computer, and a personal digital assistant, or a personal computer (PC) or a server.
[0036] like Figure 1 As shown, the method includes:
[0037] Step 101: When a preset application is running, an address of a first target parameter is obtained, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered.
[0038] In the embodiments of the present disclosure, the type of operating system on which the preset application runs is not limited, and may be, for example, an Android operating system, a Windows Phone (WP) operating system, an Apple (iOS, macOS, or OS X) operating system, etc. For ease of explanation, the Android operating system will be used as an example for explanation below.
[0039] Android Runtime (ART) is part of the Android operating system and is the execution environment for Android Java applications. Android applications running in ART do not require developers to manually release memory, so some garbage objects that are no longer needed will be generated. If these memories are not reclaimed, it will eventually lead to memory exhaustion and cause the application to crash. Therefore, ART needs to perform garbage collection to release the memory space occupied by these no longer needed objects. Generally, the target heap size for the next GC trigger is calculated in the last stage of the garbage collection event, that is, the target heap size directly determines the timing of the next garbage collection event. The first target parameter includes at least one parameter involved in calculating the target heap size. In the embodiment of the present disclosure, the parameter value of the first target parameter can be adjusted to change the timing of triggering the garbage collection event. By increasing the target heap size, the difficulty of triggering the garbage collection event is increased, that is, the triggering timing is postponed.
[0040] Exemplarily, in order to adjust the parameter value of the first target parameter, in this step, the position of the first target parameter is first located, that is, the address of the first target parameter is obtained, and the specific acquisition method is not limited.
[0041] Step 102: According to the address of the first target parameter, modify the original parameter value of the first target parameter to a target parameter value, so that a first target heap size determined according to the target parameter value is larger than a second target heap size determined according to the original parameter value.
[0042] Exemplarily, the difficulty of triggering the garbage collection event increases with the increase of the target heap size. After obtaining the address of the first target parameter, the original parameter value stored in the address can be modified to the target parameter value, so that the first target heap size determined according to the target parameter value is larger than the second target heap size determined according to the original parameter value, that is, the difficulty of triggering the garbage collection event is increased, thereby reducing the frequency of garbage collection.
[0043] The data processing scheme provided by the embodiment of the present disclosure obtains the address of the first target parameter when the preset application is running, wherein the parameter value of the first target parameter is used to determine the target heap size when the garbage collection event of the preset application is triggered, and the original parameter value of the first target parameter is adjusted according to the address of the first target parameter, so that the first target heap size determined according to the adjusted target parameter value of the first target parameter is larger than the second target heap size determined according to the original parameter value of the first target parameter. By adopting the above technical scheme, when the application is running, the target heap size for triggering the garbage collection event can be increased by adjusting the parameter value of the target parameter, and the difficulty of triggering the garbage collection event increases with the increase of the target heap size, which can reduce the activity of the garbage collection event, avoid problems such as application freezes caused by frequent garbage collection, improve application performance, and improve user experience.
[0044] In some embodiments, the first target parameter includes a first parameter and / or a second parameter, the first parameter is used to represent the minimum free memory of the heap corresponding to the preset application, the second parameter is used to represent the maximum free memory of the heap corresponding to the preset application, the target heap size is determined according to the sum of the used memory and the reserved memory value of the preset application, and the parameter value of the first target parameter is used to determine the reserved memory value. In this way, the target heap size can be adjusted more quickly and accurately.
[0045] Figure 2 A parameter relationship diagram provided by an embodiment of the present disclosure, such as Figure 2 As shown, b represents the first parameter, which is used to represent the minimum free memory of the heap corresponding to the preset application, and can be recorded as min_free; a represents the second parameter, which is used to represent the maximum free memory of the heap corresponding to the preset application, and can be recorded as max_free; u represents the heap utilization, which can be recorded as utilization; d represents the multiplier factor, which can be recorded as multiplier. Figure 2 The horizontal axis is the used memory of the preset application, in bytes, and the vertical axis is the reserved memory (reserved free memory), in bytes. The sum of the horizontal and vertical axis values is the target heap size.
[0046] Exemplarily, during the startup phase of a preset application, the reserved memory value is generally db, which is the product of the first parameter and the multiplier factor. During this phase, the target heap size can be increased by increasing the parameter value of the first parameter. After the startup of the preset application is completed, the reserved memory value gradually increases until it reaches da, which is the product of the second parameter and the multiplier factor. When the value is da, the target heap size can be increased by increasing the parameter value of the second parameter.
[0047] In some embodiments, the obtaining of the address of the first target parameter includes: performing a secondary search within the runtime instance to locate the target address of the target instance corresponding to the referenced secondary address, including the address of the regional space variable, and determining the target address as the address of the heap instance; determining the address of the first target parameter according to the target address and the target offset, wherein the target offset is the offset of the first target parameter relative to the heap instance. Thus, the address of the first target parameter can be accurately located, and the corresponding parameter value can be accurately modified.
[0048] Figure 3 A variable distribution diagram provided by an embodiment of the present disclosure, such as Figure 3 As shown, the first parameter (min_free) and the second parameter (max_free) are located in the heap instance, and the Heap instance is stored in the heap_ of the runtime instance, that is, the Heap instance is pointed to by referencing the secondary address at the location of heap_. The address of the Heap instance can be found in the Runtime instance first, and then the address of the first target parameter is located. However, the address of the Heap instance cannot be found from the Runtime instance by direct search. Therefore, in the embodiment of the present disclosure, the Heap instance is located by indirect search. The Heap instance contains a region space (region_space) variable, and a secondary search is performed in the Runtime instance, that is, each time an address is searched, the instance corresponding to the secondary address it references is opened. If the instance contains the address of region_space, the address currently searched in the Runtime instance is recorded as the target address, and the target address is also the address of the Heap instance.
[0049] Exemplarily, the target offset may include a first target offset and a second target offset, the first target offset corresponds to the first parameter, and the second target offset corresponds to the second parameter. The address of the first parameter may be determined according to the sum of the target address and the first target offset; the address of the second parameter may be determined according to the sum of the target address and the second target offset. The first target offset and the second target offset may be acquired in advance, such as 24 and 25. Figure 3 As shown, the first parameter (min_free) and the second parameter (max_free) are located below region_space. The offset of the region space variable relative to the heap instance can also be calculated based on the address and target address of the region space variable, and the first target offset and the second target offset can be determined based on the offset of the region space variable relative to the heap instance.
[0050] In some embodiments, before performing the secondary search in the runtime instance, the method further includes: using a dynamic library open function to open the virtual machine dynamic library, and based on the handle returned by the dynamic library open function and the symbol of the runtime instance, using a dynamic library load function to obtain the address of the runtime instance. In this way, the Runtime instance can be safely and accurately located, and the address of the first target parameter can be accurately located.
[0051] Exemplarily, the dynamic library opening function may be a dlopen function, the dynamic library loading function may be a dlsym function, and the virtual machine dynamic library may be libart.so. The dlopen function may open the specified dynamic link library file and return a handle to the calling process of dlsym. By opening libart.so through the dlopen function, the symbol of the dlsym Runtime instance may safely obtain the address of the Runtime instance, wherein the symbol of the Runtime instance may be _ZN3art7Runtime9instance_E.
[0052] In some embodiments, before performing the secondary search within the target range of the runtime instance, the method further includes: using a dynamic library open function to open the virtual machine dynamic library, based on the handle returned by the dynamic library open function and the symbol of the virtual function table variable corresponding to the regional space variable, using a dynamic library load function to obtain the address of the virtual function table variable, and determining the address of the regional space variable according to the address of the virtual function table variable. In this way, the regional space variable can be safely and accurately located, and the address of the first target parameter can be accurately located.
[0053] Exemplarily, the virtual function table variable corresponding to the region space variable may be RegionSpace vtable, and after obtaining the address of RegionSpace vtable, the address of region_space may be obtained through conversion. Specifically, the conversion process may be obtained by adding a known offset to the address of RegionSpace vtable, where the known offset is the offset of the address of region_space relative to the address of RegionSpace vtable.
[0054] In some embodiments, the performing of a secondary search within the runtime instance to locate a target address including an address of a region space variable in a variable corresponding to the referenced secondary address includes: performing a secondary search starting from a virtual machine instance variable in the runtime instance toward a starting position of the runtime instance to locate a target address including an address of a region space variable in a variable corresponding to the referenced secondary address. Thus, the time consumption of searching for the target address can be shortened, and the efficiency of locating the address of the heap instance can be improved.
[0055] Figure 4 Another variable distribution diagram provided by the embodiment of the present disclosure is as follows: Figure 4 As shown, it is found that heap_ is located above the virtual machine instance variable (java_vm_) and is close to java_vm_. Searching upward from java_vm_ can search for heap_ faster. Exemplarily, the address of java_vm_ can be obtained in the Java Native Interface (JNI) through env->GetJavaVM(&java_vm). The offset of java_vm_ relative to the Runtime instance can be calculated based on the address of the Runtime instance and the address of java_vm_, and then the position of java_vm_ in the Runtime instance can be determined, and the target position can be searched upward from java_vm_.
[0056] Applications running in an operating system generally have their own heap space. The maximum heap size of a virtual machine is dynamically allocated by the operating system according to the memory requirements of the application when the application is started. The maximum heap size of the virtual machine limits the upper limit of the Java memory that the application can use. When the memory is used too much, if it is greater than or equal to the maximum heap size of the virtual machine, it triggers an Out of Memory (OOM) crash of the application. In the disclosed embodiment, the crash can be reduced by modifying the maximum heap size of the virtual machine in the preset application.
[0057] In some embodiments, it also includes: searching for a second target parameter, wherein the second target parameter includes a third parameter and a fourth parameter, the third parameter is used to represent the maximum capacity of the heap corresponding to the preset application, and the fourth parameter is used to represent the growth limit capacity of the heap corresponding to the preset application; modifying the parameter value of the second target parameter from a preset memory value to a target memory value, wherein the target memory value is greater than the preset memory value.
[0058] Exemplarily, the parameter that affects the maximum heap size of the virtual machine is recorded as the second target parameter. Among them, the third parameter is used to indicate the maximum capacity of the heap corresponding to the preset application, which can be recorded as capacity_, that is, the maximum size that the heap can reach; the fourth parameter is used to indicate the growth limit capacity of the heap corresponding to the preset application, which can be recorded as growth_limit_, that is, the maximum available memory value of the heap. After the application is started, as the heap space increases, the amount of system memory occupied will gradually increase, but the growth is limited. The fourth parameter can represent the upper limit of the growth of the heap memory. By modifying the memory values (recorded as preset memory values) allocated by the operating system corresponding to the third parameter and the fourth parameter respectively to a larger target memory value, the threshold for triggering a crash can be increased, thereby reducing the number of crashes of the preset application, ensuring the stability of the application operation, and improving the user experience.
[0059] Figure 5 This is a flow chart of another data processing method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is optimized based on the various optional solutions in the above embodiments, and adds relevant steps of locating the second target parameter and modifying the second target parameter. Specifically, the method includes the following steps:
[0060] Step 501: When a preset application is running, a dynamic library opening function is used to open a virtual machine dynamic library, and based on the symbol of the runtime instance and the handle returned by the dynamic library opening function, a dynamic library loading function is used to obtain the address of the runtime instance.
[0061] Step 502: Based on the symbol of the virtual function table variable corresponding to the regional space variable and the handle returned by the dynamic library open function, the address of the virtual function table variable is obtained by using the dynamic library load function, and the address of the regional space variable is determined according to the address of the virtual function table variable.
[0062] Step 503: Based on the address of the runtime instance, a secondary search is performed starting from the virtual machine instance variable in the runtime instance toward the starting position of the runtime instance to locate the target address of the address of the regional space variable in the variable corresponding to the referenced secondary address, and the target address is determined as the address of the heap instance.
[0063] Step 504: Determine the address of the first target parameter according to the target address and the target offset.
[0064] Step 505: According to the address of the first target parameter, modify the original parameter value of the first target parameter to the target parameter value, so that the first target heap size determined according to the target parameter value is larger than the second target heap size determined according to the original parameter value.
[0065] The difficulty of triggering the garbage collection event increases as the target heap size increases.
[0066] Step 506: Search for a preset memory value in the heap instance according to the target address. If the values of the third parameter and the fourth parameter are both preset memory values, determine the third parameter and the fourth parameter as second target parameters, wherein the third parameter and the fourth parameter are adjacent in the heap instance.
[0067] The third parameter is used to indicate the maximum capacity of the heap corresponding to the preset application, and the fourth parameter is used to indicate the growth limit capacity of the heap corresponding to the preset application.
[0068] After research, it was found that capacity_ and growth_limit_ are adjacent to each other in the Heap instance. For preset applications with high memory requirements, the parameter values of the third parameter and the fourth parameter in the memory are generally equal, for example, both are 512Mb=536870912, which are recorded as the preset memory value. The preset memory value can be used as the search target to search in the Heap instance, and finding two matching values at the same time is used as the basis for successful positioning, that is, if the preset memory value is searched twice in succession in the Heap instance, the parameters corresponding to the two preset memory values searched are determined as the third parameter and the fourth parameter.
[0069] Step 507: modify the parameter value of the second target parameter from the preset memory value to the target memory value, wherein the target memory value is greater than the preset memory value.
[0070] Optionally, the first target heap size is smaller than the target memory value, that is, the modification of the second target parameter and the modification of the first target parameter may be associated. The target heap size determined after the parameter value of the first target parameter is modified is smaller than the modified parameter value of the second target parameter, thereby ensuring the normal operation of the preset application.
[0071] The data processing method provided by the embodiment of the present disclosure dynamically locates the first target parameter and the second target parameter when a preset application is running, and increases the target heap size and increases the virtual machine heap size limit by adjusting the first target parameter and the second target parameter, thereby reducing the triggering frequency of garbage collection events and the number of application crashes, ensuring the performance and smooth operation of large applications with high memory requirements, and effectively improving the user experience when users use the applications.
[0072] Figure 6 A structural diagram of a data processing device provided by an embodiment of the present disclosure is shown in FIG. Figure 6 As shown, the device comprises:
[0073] An address acquisition module 601 is used to acquire the address of a first target parameter when a preset application is running, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered;
[0074] The parameter value modification module 602 is used to modify the original parameter value of the first target parameter to a target parameter value according to the address of the first target parameter, so that the first target heap size determined according to the target parameter value is larger than the second target heap size determined according to the original parameter value.
[0075] The data processing device provided in the embodiment of the present disclosure can increase the target heap size for triggering garbage collection events by adjusting the parameter value of the target parameter when the application is running. The difficulty of triggering the garbage collection event increases with the increase of the target heap size, which can reduce the activity of the garbage collection event, avoid problems such as application freezes caused by frequent garbage collection, improve application performance, and enhance user experience.
[0076] Optionally, the first target parameter includes a first parameter and / or a second parameter, the first parameter is used to indicate the minimum free memory of the heap corresponding to the preset application, the second parameter is used to indicate the maximum free memory of the heap corresponding to the preset application, the target heap size is determined based on the sum of the used memory and the reserved memory value of the preset application, and the parameter value of the first target parameter is used to determine the reserved memory value.
[0077] Optionally, the address acquisition module includes:
[0078] A search unit, configured to perform a secondary search in the runtime instance when the preset application is running, to locate a target address including an address of a regional space variable in a target instance corresponding to the referenced secondary address, and determine the target address as an address of the heap instance;
[0079] The address determining unit is used to determine the address of the first target parameter according to the target address and the target offset, wherein the target offset is the offset of the first target parameter relative to the heap instance.
[0080] Optionally, the search unit is specifically used for:
[0081] When the preset application is running, a secondary search is performed starting from the virtual machine instance variable in the runtime instance toward the starting position of the runtime instance to locate the target address of the address of the regional space variable in the variable corresponding to the referenced secondary address.
[0082] Optionally, the device further comprises:
[0083] an instance address acquisition module, used to use a dynamic library opening function to open a virtual machine dynamic library before performing a secondary search within a target range of a runtime instance, and to use a dynamic library loading function to acquire the address of the runtime instance based on a symbol of the runtime instance and a handle returned by the dynamic library opening function; and / or,
[0084] The variable address determination module is used to use a dynamic library opening function to open the virtual machine dynamic library before performing a secondary search within the target range of the runtime instance, obtain the address of the virtual function table variable using a dynamic library loading function based on the symbol of the virtual function table variable corresponding to the regional space variable and the handle returned by the dynamic library opening function, and determine the address of the regional space variable according to the address of the virtual function table variable.
[0085] Optionally, the device further comprises:
[0086] a parameter determination module, configured to search for a preset memory value in the heap instance, and if the values of the third parameter and the fourth parameter found to be both the preset memory values, determine the third parameter and the fourth parameter as the second target parameter, wherein the third parameter is used to indicate the maximum capacity of the heap corresponding to the preset application, the fourth parameter is used to indicate the growth limit capacity of the heap corresponding to the preset application, and the third parameter and the fourth parameter are adjacent in the heap instance;
[0087] A parameter value adjustment module is used to modify the parameter value of the second target parameter from the preset memory value to a target memory value, wherein the target memory value is greater than the preset memory value.
[0088] Optionally, the first target heap size is smaller than the target memory value.
[0089] The data processing device provided in the embodiments of the present disclosure can execute the data processing method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0090] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0091] Figure 7 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 7 , which shows an electronic device (eg, Figure 7The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0092] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An edit / output (I / O) interface 705 is also connected to the bus 704.
[0093] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0094] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 709, or installed from a storage device 708, or installed from a ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0095] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0096] The electronic device provided by the embodiment of the present disclosure and the data processing method provided by the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0097] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the data processing method provided by the above embodiments is implemented.
[0098] The embodiments of the present disclosure provide a computer program product, including a computer program, which implements the data processing method provided in the above embodiments when executed by a processor.
[0099] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0100] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0101] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0102] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains the address of a first target parameter when a preset application is running, wherein the parameter value of the first target parameter is used to determine the target heap size when a garbage collection event of the preset application is triggered; according to the address of the first target parameter, modifies the original parameter value of the first target parameter to the target parameter value, so that the first target heap size determined according to the target parameter value is larger than the second target heap size determined according to the original parameter value, wherein the difficulty of triggering the garbage collection event increases with the increase of the target heap size.
[0103] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0104] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0105] The units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The name of a module does not limit the module itself in some cases. For example, the address acquisition module may also be described as "a module for acquiring the address of a first target parameter when a preset application is running, wherein the parameter value of the first target parameter is used to determine the target heap size when a garbage collection event of the preset application is triggered".
[0106] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0107] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0108] According to one or more embodiments of the present disclosure, a data processing method is provided, including:
[0109] When a preset application is running, obtaining an address of a first target parameter, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered;
[0110] According to the address of the first target parameter, the original parameter value of the first target parameter is modified to a target parameter value, so that a first target heap size determined according to the target parameter value is larger than a second target heap size determined according to the original parameter value.
[0111] According to one or more embodiments of the present disclosure, the first target parameter includes a first parameter and / or a second parameter, the first parameter is used to represent the minimum free memory of the heap corresponding to the preset application, the second parameter is used to represent the maximum free memory of the heap corresponding to the preset application, the target heap size is determined based on the sum of the used memory of the preset application and the reserved memory value, and the parameter value of the first target parameter is used to determine the reserved memory value.
[0112] According to one or more embodiments of the present disclosure, obtaining the address of the first target parameter includes:
[0113] Performing a secondary search within the runtime instance to locate a target address including an address of a local space variable in a target instance corresponding to the referenced secondary address, and determining the target address as an address of a heap instance;
[0114] An address of a first target parameter is determined according to the target address and the target offset, wherein the target offset is an offset of the first target parameter relative to the heap instance.
[0115] According to one or more embodiments of the present disclosure, performing a secondary search within a runtime instance to locate a target address including an address of a regional space variable in a variable corresponding to a referenced secondary address includes:
[0116] A secondary search is performed starting from the virtual machine instance variable in the runtime instance toward the starting position of the runtime instance to locate a target address including the address of the regional space variable in the variable corresponding to the referenced secondary address.
[0117] According to one or more embodiments of the present disclosure, before performing the secondary search within the target scope of the runtime instance, the method further includes:
[0118] Using a dynamic library open function to open the virtual machine dynamic library, based on the symbol of the runtime instance and the handle returned by the dynamic library open function, using a dynamic library load function to obtain the address of the runtime instance; and / or,
[0119] A dynamic library opening function is used to open the dynamic library of the virtual machine. Based on the symbol of the virtual function table variable corresponding to the regional space variable and the handle returned by the dynamic library opening function, the address of the virtual function table variable is obtained using the dynamic library loading function, and the address of the regional space variable is determined according to the address of the virtual function table variable.
[0120] According to one or more embodiments of the present disclosure, the present invention further includes:
[0121] Searching for a preset memory value in the heap instance, and if the values of the third parameter and the fourth parameter are both the preset memory value, determining the third parameter and the fourth parameter as the second target parameter, wherein the third parameter is used to indicate the maximum capacity of the heap corresponding to the preset application, the fourth parameter is used to indicate the growth limit capacity of the heap corresponding to the preset application, and the third parameter and the fourth parameter are adjacent in the heap instance;
[0122] The parameter value of the second target parameter is modified from the preset memory value to a target memory value, wherein the target memory value is greater than the preset memory value.
[0123] According to one or more embodiments of the present disclosure, the first target heap size is smaller than the target memory value.
[0124] According to one or more embodiments of the present disclosure, there is provided a data processing device, including:
[0125] An address acquisition module, used to acquire the address of a first target parameter when a preset application is running, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered;
[0126] The parameter value modification module is used to modify the original parameter value of the first target parameter to a target parameter value according to the address of the first target parameter, so that a first target heap size determined according to the target parameter value is larger than a second target heap size determined according to the original parameter value.
[0127] According to one or more embodiments of the present disclosure, an electronic device is provided, the electronic device comprising:
[0128] one or more processors;
[0129] a storage device for storing one or more programs,
[0130] When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method provided by the embodiment of the present disclosure.
[0131] According to one or more embodiments of the present disclosure, a storage medium containing computer executable instructions is provided. When the computer executable instructions are executed by a computer processor, they are used to execute the data processing method provided by the embodiments of the present disclosure.
[0132] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0133] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0134] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A data processing method, characterized in that: include: When a preset application is running, obtaining an address of a first target parameter, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered; According to the address of the first target parameter, the original parameter value of the first target parameter is modified to a target parameter value, so that a first target heap size determined according to the target parameter value is larger than a second target heap size determined according to the original parameter value.
2. The method according to claim 1, characterized in that The first target parameter includes a first parameter and / or a second parameter, the first parameter is used to indicate the minimum free memory of the heap corresponding to the preset application, the second parameter is used to indicate the maximum free memory of the heap corresponding to the preset application, the target heap size is determined based on the sum of the used memory and the reserved memory value of the preset application, and the parameter value of the first target parameter is used to determine the reserved memory value.
3. The method according to claim 2, characterized in that The obtaining the address of the first target parameter includes: Performing a secondary search within the runtime instance to locate a target address including an address of a local space variable in a target instance corresponding to the referenced secondary address, and determining the target address as an address of a heap instance; An address of a first target parameter is determined according to the target address and the target offset, wherein the target offset is an offset of the first target parameter relative to the heap instance.
4. The method according to claim 3, characterized in that The performing of the secondary search within the runtime instance to locate the target address of the address of the regional space variable in the variable corresponding to the referenced secondary address includes: A secondary search is performed starting from the virtual machine instance variable in the runtime instance toward the start position of the runtime instance to locate a target address including the address of the regional space variable in the variable corresponding to the referenced secondary address.
5. The method according to claim 3, characterized in that: Before the secondary search in the target scope of the runtime instance, also include: Using a dynamic library open function to open the virtual machine dynamic library, based on the symbol of the runtime instance and the handle returned by the dynamic library open function, using a dynamic library load function to obtain the address of the runtime instance; and / or, A dynamic library opening function is used to open the virtual machine dynamic library. Based on the symbol of the virtual function table variable corresponding to the regional space variable and the handle returned by the dynamic library opening function, the address of the virtual function table variable is obtained using the dynamic library loading function, and the address of the regional space variable is determined according to the address of the virtual function table variable.
6. The method according to claim 3, characterized in that Also includes: Searching for a preset memory value in the heap instance, and if the values of the third parameter and the fourth parameter are both the preset memory value, determining the third parameter and the fourth parameter as the second target parameter, wherein the third parameter is used to indicate the maximum capacity of the heap corresponding to the preset application, the fourth parameter is used to indicate the growth limit capacity of the heap corresponding to the preset application, and the third parameter and the fourth parameter are adjacent in the heap instance; The parameter value of the second target parameter is modified from the preset memory value to a target memory value, wherein the target memory value is greater than the preset memory value.
7. The method according to claim 6, characterized in that The first target heap size is smaller than the target memory value.
8. A data processing device, characterized in that: include: An address acquisition module, used to acquire the address of a first target parameter when a preset application is running, wherein a parameter value of the first target parameter is used to determine a target heap size when a garbage collection event of the preset application is triggered; The parameter value modification module is used to modify the original parameter value of the first target parameter to a target parameter value according to the address of the first target parameter, so that a first target heap size determined according to the target parameter value is larger than a second target heap size determined according to the original parameter value.
9. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method according to any one of claims 1 to 7.
10. A storage medium containing computer executable instructions, characterized in that: When the computer executable instructions are executed by a computer processor, they are used to perform the data processing method according to any one of claims 1 to 7.