Resource management method, device, medium and electronic device

By setting a proxy function in the client program to determine whether the variable address information of thread-local variables exists in the target linked list, it avoids the repeated creation of thread-local variables, solves the resource leakage problem, and improves system stability.

CN116244004BActive Publication Date: 2025-05-16BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310165179.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-21
Publication Date
2025-05-16
Estimated Expiration
2043-02-21

AI Technical Summary

Technical Problem

In large software projects, repeated creation of thread-local variables may lead to resource leakage, and it is difficult for engineers to detect such exception problems in a timely manner.

Method used

By setting the first proxy function, when the client program process calls the creation function, it jumps to the proxy function and determines whether the variable address information of the passed thread local variable exists in the target linked list. If present, the corresponding thread-local variable is not created to avoid repeated creation.

Benefits of technology

It effectively avoids the repeated creation of the same thread-local variables in the thread-local variable array, improves resource leakage problems, and improves system stability and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116244004B_ABST
    Figure CN116244004B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a resource management method, device, medium and electronic device, the method comprising: in response to obtaining an event that a client program process calls a creation function, jumping to a first proxy function, the creation function is used to create a thread local variable in a thread local variable array; through the first proxy function, determining whether the variable address information of the thread local variable passed in by the client program process exists in a target linked list, the target linked list is used to store the variable address information of the thread local variable created historically; if the variable address information exists in the target linked list, then the corresponding thread local variable is not created in the thread local variable array. The present disclosure avoids repeated creation of thread local variables in the thread local variable array by setting a proxy function, thereby improving possible resource leakage problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular, to a resource management method, device, medium and electronic device. Background Art

[0002] For global variables used in client programs, ordinary global variables are shared among multiple threads. If one thread modifies them, all other threads can see them. Thread local variables are global variables stored using thread local storage (TLS) technology, which can be understood as thread-private global variables. Thread-private global variables are different from ordinary global variables. Thread-private global variables are private property of threads. Each thread has its own copy. Modifications made by a thread will only modify its own copy, not the copies of other threads. In this way, a global variable can be accessed in each thread and its value does not affect each other and is independent of each other.

[0003] In large-scale software projects, many engineers will develop a client program at the same time. During the program writing process, a large number of thread local variables will be defined and used, which may lead to thread local variable resource leakage. Summary of the invention

[0004] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0005] In a first aspect, the present disclosure provides a resource management method, comprising:

[0006] In response to obtaining an event that a client program process calls a create function, jumping to a first proxy function, wherein the create function is used to create a thread local variable in a thread local variable array;

[0007] Determine, through the first proxy function, whether the variable address information of the thread local variables passed in by the client program process exists in a target linked list, where the target linked list is used to store the variable address information of the thread local variables created historically;

[0008] If the variable address information exists in the target linked list, the corresponding thread local variable is not created in the thread local variable array.

[0009] In a second aspect, the present disclosure provides a resource management device, including:

[0010] A first response module, configured to jump to a first proxy function in response to obtaining an event that a client program process calls a create function, wherein the create function is configured to create a thread local variable in a thread local variable array;

[0011] A judgment module, used to determine, through the first proxy function, whether the variable address information of the thread local variables passed in by the client program process exists in a target linked list, where the target linked list is used to store the variable address information of the thread local variables created historically;

[0012] The first processing module is used for not creating a corresponding thread local variable in the thread local variable array when the variable address information exists in the target linked list.

[0013] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the resource management method provided in the first aspect.

[0014] In a fourth aspect, the present disclosure provides an electronic device, including:

[0015] a storage device having a computer program stored thereon;

[0016] A processing device is used to execute the computer program in the storage device to implement the steps of the resource management method provided in the first aspect.

[0017] In the above technical solution, by setting the first proxy function, when the client program process calls the creation function, it will first jump to the first proxy function, execute the operation in the first proxy function, and then determine whether to create the corresponding thread local variable according to the judgment result in the first proxy function, that is, when the variable address information of the thread local variable passed in by the client program process already exists in the target linked list, the corresponding thread local variable is not created in the thread local variable array. Therefore, the present disclosure can avoid repeatedly creating the same thread local variable in the thread local variable array and improve the possible resource leakage problem.

[0018] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] 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 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. In the drawings:

[0020] Figure 1 A flowchart of a resource management method provided by some embodiments of the present disclosure is shown;

[0021] Figure 2 A flowchart showing an implementation method of step S102 in some embodiments of the present disclosure is shown;

[0022] Figure 3 A block diagram of a resource management device provided by some embodiments of the present disclosure is shown;

[0023] Figure 4 A block diagram of an electronic device provided by some embodiments of the present disclosure is shown. 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] At the same time, 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] As the development and operation of applications become increasingly complex, the number of thread local variables handled by developers during program implementation also increases significantly, which may lead to resource leakage. The inventors have found that a major reason for resource leakage is the repeated creation of thread local variables. For example, thread A and thread B apply to create the same thread local variable in succession. When thread A calls the creation function, the creation function creates a thread local variable at position a in the thread local variable array based on the variable address information passed in by thread A. When thread B calls the creation function, the creation function creates a thread local variable at position b in the thread local variable array based on the variable address information passed in by thread B. Therefore, two identical thread local variables are created at two different positions in the thread local variable array. The thread local variables that can be created in the thread local variable array are limited. As the number of thread local variables increases, resource leakage may occur.

[0036] Resource leakage anomalies are hidden and cumulative, and it is difficult for engineers to detect resource leakage anomalies in a timely manner. If there is a resource leakage anomaly when the client program is running, it will cause insufficient system memory, and in severe cases it will cause the system to crash, affecting the user experience.

[0037] In view of this, an embodiment of the present disclosure provides a resource management method, which manages the creation of thread local variables to avoid repeated creation of thread local variables, thereby improving possible resource leakage problems from the source.

[0038] Figure 1 A flowchart of a resource management method provided by some embodiments of the present disclosure is shown. Figure 1 , the method comprising:

[0039] Step S101, in response to obtaining an event that a client program process calls a create function, jump to a first proxy function, where the create function is used to create a thread local variable in a thread local variable array.

[0040] In the present disclosure, the client program process is the process of the client program running on the user terminal, and the user terminal is, for example: a smart phone (Mobile Phone), a Pocket Personal Computer (PPC), a personal digital assistant (PDA), a laptop computer, a tablet computer, a wearable device, or a vehicle-mounted device, etc., and the present disclosure does not make any specific limitations on this.

[0041] In some embodiments, the event of the client program process calling the create function can be obtained through the Hook technology.

[0042] In the present disclosure, by setting the first proxy function, when the client program process calls the create function, it will first jump to the first proxy function, execute the operations in the first proxy function, and then determine whether to execute the create function based on the judgment result in the first proxy function to create the corresponding thread local variables.

[0043] Step S102, through the first proxy function, determine whether the variable address information of the thread local variable passed in by the client program process exists in the target linked list, where the target linked list is used to store the variable address information of the thread local variable created historically.

[0044] In the present disclosure, the variable address information passed in by the client program process is compared with the variable address information stored in the target linked list to determine whether the variable address information passed in exists in the target linked list. It is easy to understand that if the variable address information of two thread local variables is the same, it means that the two thread local variables are the same variable. Therefore, if the variable address information passed in exists in the target linked list, it can be determined that the thread local variable created in this application is a duplicate creation.

[0045] Step S103: If the variable address information exists in the target linked list, then the corresponding thread local variable is not created in the thread local variable array.

[0046] In the first proxy function, a target linked list is maintained, and the variable address information of each created thread local variable is stored in the target linked list. After jumping to the first proxy function, the first proxy function is used to determine whether the variable address information of the thread local variable passed in by the client program process exists in the target linked list. If the passed in variable address information exists in the target linked list, it means that the client program process calls the creation function to create the thread local variable this time, which is a repeated creation. In this case, the first proxy function does not call the creation function, and thus does not create the corresponding thread local variable in the thread local variable array.

[0047] In some embodiments of the present disclosure, if the variable address information passed in does not exist in the target linked list, it means that the client program process calls the creation function this time to create the thread local variable, not a repeated creation, then the first proxy function calls the creation function, and through the creation function, creates the corresponding thread local variable in the thread local variable array according to the variable address information passed in, thereby creating the thread local variable normally. In addition, in this case, the first proxy function will also insert the variable address information in the target linked list, thereby recording the variable address information of the thread local variable created this time.

[0048] According to the above technical solution, it is possible to avoid repeatedly creating the same thread local variables in the thread local variable array, and improve possible resource leakage problems. For example, when thread A calls the creation function, it will first jump to the first proxy function. The first proxy function determines that the variable address information passed in by thread A does not exist in the target linked list, so it executes the creation function, thereby creating a thread local variable in the thread local variable array according to the variable address information passed in by thread A; when thread B calls the creation function, it still jumps to the first proxy function first. The first proxy function determines that the variable address information passed in by thread B already exists in the target linked list, so it does not execute the creation function, and thus does not create a thread local variable in the thread local variable array. It can be seen that through this technical solution, it is ensured that the same thread local variables will not be repeatedly created in the thread local variable array.

[0049] In some embodiments, a first global count variable may be used to record the number of thread local variables created. In the first proxy function, each time a creation function is called to create a thread local variable, the value in the first global count variable is increased by one.

[0050] Optionally, Figure 2 A flowchart showing the implementation of step S102 in some embodiments of the present disclosure is shown. Figure 2 , you can use the following steps to determine whether the variable address information of the thread local variable passed in by the client program process exists in the target linked list.

[0051] Step S201, determine whether the target linked list is an empty linked list. If the target linked list is not an empty linked list, jump to step S202.

[0052] Optionally, if the target linked list is an empty linked list, jump to step S204.

[0053] Step 202, traverse each variable address information in the target linked list, and compare whether the variable address information input is the same as the variable address information in the target linked list. If the variable address information input is the same as any variable address information in the target linked list, jump to step S203.

[0054] Optionally, if the variable address passed in is different from all variable address information in the target linked list, jump to step S204.

[0055] Step S203, determining whether the variable address information passed in by the client program process exists in the target linked list.

[0056] Step S204, determining that the variable address information passed in by the client program process does not exist in the target linked list.

[0057] According to the above technical solution, it can be determined whether the variable address information passed in by the client program process exists in the target linked list.

[0058] Furthermore, in some embodiments of the present disclosure, the resource management method further includes the following steps:

[0059] In response to obtaining an event that a client program process calls a delete function, jump to a second proxy function, which is used to delete thread local variables in a thread local variable array; according to variable address information of the thread local variables passed in by the client program process, the variable address information is deleted in a target linked list through the second proxy function, and the delete function is called to delete the corresponding thread local variable in the thread local variable array according to the variable address information.

[0060] In some embodiments, the event of the client program process calling the deletion function can be obtained through the Hook technology.

[0061] In the present disclosure, by setting a second proxy function, when the client program process calls the deletion function, it will first jump to the second proxy function and execute the operations in the second proxy function. Through the second proxy function, on the one hand, the deletion function is executed normally, that is, the corresponding thread local variables are deleted in the thread local variable array, and on the other hand, the corresponding variable address information needs to be deleted in the target linked list, that is, the variable address information stored in the target linked list is updated.

[0062] In some embodiments, the number of deleted thread local variables can be recorded through a second global count variable. In the second proxy function, each time the delete function is called to delete a thread local variable, the value in the second global count variable is increased by one.

[0063] In some embodiments, each node of the target linked list stores a structure data, that is, the first proxy function inserts the variable address information into the target linked list, including: generating the structure data corresponding to the thread local variable according to the variable address information of the thread local variable and the dynamic library and thread that create the thread local variable, and then inserting the structure data into the target linked list. On this basis, the second proxy function deletes the variable address information in the target linked list, including: deleting the corresponding structure data in the target linked list according to the variable address information of the thread local variable.

[0064] Furthermore, when an exception occurs in the client program, such as freezing or crashing, the information in the target linked list is formatted and printed to a file. The file is parsed and analyzed by the client program to determine the dynamic libraries and threads that create the most thread local variables, and then the relevant information of the dynamic libraries and threads that create the most thread local variables is reported to the server. On the server side, the relevant information reported by multiple client programs can be classified and counted according to the recorded dynamic library names and thread names to find the dynamic libraries and threads that create the most thread local variables for engineers to process.

[0065] In addition, the client program may also report the number of thread local variables created and deleted in the client program together with the above-mentioned relevant information to the server according to the first global count variable and the second global count variable.

[0066] In order to enable those skilled in the art to better understand the resource management method provided by the present disclosure, the resource management method is described below with a complete embodiment.

[0067] First of all, it should be understood that the operating system of the above-mentioned user terminal can be an Android operating system, a UNIX operating system, a Linux operating system, etc., and a client program runs on the user terminal.

[0068] In the Android operating system, the thread local variable TLS key is created by the pthread_key_create function, deleted by the pthread_key_delete function, and recorded and managed by the staticpthread_key_internal_t ​​key_map[] global static array defined in the libc.so dynamic library. The staticpthread_key_internal_t ​​key_map[] global static array can be referred to as the key_map array, that is, the thread local variable array in the present disclosure.

[0069] When the client program is started, a target linked list is created, and the client program process is hooked to call the pthread_key_create function and the pthread_key_delete function. After hooking these two functions, the client program process will create and delete TLS keys through the proxy functions proxy_pthread_key_create and proxy_pthread_key_delete. In this way, all created and deleted TLSkey resources can be monitored and recorded through the two proxy functions.

[0070] In one embodiment, when the client program process calls the pthread_key_create function, it first jumps to execute the proxy_pthread_key_create function.

[0071] Specifically, when the proxy_pthread_key_create function is executed, the key address information of a TLS key will be passed in. The proxy_pthread_key_create function first determines whether the target linked list is an empty linked list. If it is an empty linked list, the pthread_key_create function is executed to create a new TLS key in the key_map array, and the function address of the calling program that calls the pthread_key_create function is determined. The corresponding dynamic library name is found according to the function address of the calling program, and the thread name, thread ID and time of creating the TLS key are determined. The key address information passed in, as well as the above-mentioned dynamic library name, thread name, thread ID and time are composed of structure data, and the structure data is inserted into the target linked list.

[0072] If the target linked list is not an empty linked list, the target linked list is traversed, and the key address information is taken out and compared with the key address information passed in when proxy_pthread_key_create is currently executed. If the two are the same, the original structure data corresponding to the same key address information is deleted from the target linked list, and the new structure data is inserted into the original position in the target linked list. The new structure data may have different internal dynamic library name, thread name, thread ID and time than the original structure data. Therefore, the target linked list always records the latest creation information of the TLS key.

[0073] If the two are different, the pthread_key_create function is executed according to the previous process to create a new TLS key in the key_map array and insert the structure data into the target linked list.

[0074] In one embodiment, when the client program process calls the pthread_key_delete function, it first jumps to execute the proxy_pthread_key_delete function.

[0075] Specifically, when the proxy_pthread_key_delete function is executed, the key address information of a TLS key will be passed in. The proxy_pthread_key_delete function deletes the corresponding structure data from the target linked list according to the passed in key address information, and executes the pthread_key_delete function, thereby deleting the corresponding TLS key in the key_map array.

[0076] In some embodiments of the present disclosure, when the client program completely exits, the target linked list may be deleted, and the target linked list may be recreated after the client program is started next time.

[0077] Figure 3 FIG. 1 is a block diagram of a resource management device provided by some embodiments of the present disclosure. Figure 3 , the resource management device 300 comprises:

[0078] A first response module 301 is used to jump to a first proxy function in response to obtaining an event that a client program process calls a create function, wherein the create function is used to create a thread local variable in a thread local variable array;

[0079] A judgment module 302 is used to determine, through the first proxy function, whether the variable address information of the thread local variable passed in by the client program process exists in a target linked list, where the target linked list is used to store the variable address information of the thread local variable created historically;

[0080] The first processing module 303 is configured to not create a corresponding thread local variable in the thread local variable array if the variable address information exists in the target linked list.

[0081] Optionally, the first processing module 303 is used to, when the variable address information does not exist in the target linked list, insert the variable address information into the target linked list through the first proxy function; and, call the creation function through the first proxy function to create corresponding thread local variables in the thread local variable array according to the variable address information.

[0082] Optionally, the judgment module 302 is used to determine whether the target linked list is an empty linked list; when the target linked list is not an empty linked list, traverse each variable address information in the target linked list, and compare the input variable address information with the variable address information in the target linked list; when the input variable address information is the same as any variable address information in the target linked list, determine that the variable address information input by the client program process exists in the target linked list.

[0083] Optionally, the judgment module 302 is used to determine that the variable address information passed in by the client program process does not exist in the target linked list when the target linked list is an empty linked list or the passed in variable address information is different from all variable address information in the target linked list.

[0084] Optionally, the resource management device 300 further includes:

[0085] A second response module, configured to jump to a second proxy function in response to an event in which a client program process calls a delete function, wherein the delete function is configured to delete a thread local variable in a thread local variable array;

[0086] The second processing module is used to delete the variable address information of the thread local variable passed by the client program process in the target linked list through the second proxy function, and call the deletion function to delete the corresponding thread local variable in the thread local variable array according to the variable address information.

[0087] Optionally, the first processing module 303 is used to generate structure data corresponding to the thread local variable according to the variable address information of the thread local variable and the dynamic library and thread for creating the thread local variable, and insert the structure data into the target linked list. The second processing module is used to delete the corresponding structure data in the target linked list according to the variable address information of the thread local variable.

[0088] Optionally, the resource management device 300 also includes a reporting module for printing the information in the target linked list to a file in response to an exception in the client program; determining the dynamic library and thread that create the most thread local variables based on the information in the file; and reporting the relevant information of the dynamic library and thread that create the most thread local variables to the server.

[0089] Regarding the resource management device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0090] Reference below Figure 4 , which shows a schematic diagram of the structure of an electronic device (such as a user terminal in the above embodiment) 400 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include, but is not limited to, a smart phone, a laptop computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (such as a vehicle navigation terminal), a digital TV, a desktop computer, etc. Figure 4 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.

[0091] like Figure 4 As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0092] Typically, the following devices may be connected to the I / O interface 405: an input device 406 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 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 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.

[0093] 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 the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

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

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

[0096] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0097] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: in response to obtaining an event that a client program process calls a creation function, jumps to a first proxy function, wherein the creation function is used to create thread local variables in a thread local variable array; through the first proxy function, determines whether the variable address information of the thread local variables passed in by the client program process exists in a target linked list, wherein the target linked list is used to store the variable address information of historically created thread local variables; if the variable address information exists in the target linked list, the corresponding thread local variables are not created in the thread local variable array.

[0098] 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., via the Internet using an Internet service provider).

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

[0100] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of the module does not limit the module itself in some cases. For example, the first response module may also be described as "a module that jumps to the first proxy function in response to an event that a client program process calls a create function."

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

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

[0103] According to one or more embodiments of the present disclosure, Example 1 provides a resource management method, including:

[0104] In response to obtaining an event that a client program process calls a create function, jumping to a first proxy function, wherein the create function is used to create a thread local variable in a thread local variable array;

[0105] Determine, through the first proxy function, whether the variable address information of the thread local variables passed in by the client program process exists in a target linked list, where the target linked list is used to store the variable address information of the thread local variables created historically;

[0106] If the variable address information exists in the target linked list, the corresponding thread local variable is not created in the thread local variable array.

[0107] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the method further includes:

[0108] If the variable address information does not exist in the target linked list, inserting the variable address information into the target linked list through the first proxy function; and,

[0109] The creation function is called through the first proxy function to create corresponding thread local variables in the thread local variable array according to the variable address information.

[0110] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein determining whether the variable address information of the thread local variable passed in by the client program process exists in the target linked list includes:

[0111] Determine whether the target linked list is an empty linked list;

[0112] If the target linked list is not an empty linked list, traverse each variable address information in the target linked list, and compare the variable address information input with the variable address information in the target linked list;

[0113] If the variable address information passed in is the same as any variable address information in the target linked list, it is determined that the variable address information passed in by the client program process exists in the target linked list.

[0114] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein determining whether the variable address information of the thread local variable passed in by the client program process exists in the target linked list includes:

[0115] If the target linked list is an empty linked list, or the variable address information passed in is different from all the variable address information in the target linked list, it is determined that the variable address information passed in by the client program process does not exist in the target linked list.

[0116] According to one or more embodiments of the present disclosure, Example 5 provides a method of any one of Examples 2 to 4, wherein the method further includes:

[0117] In response to obtaining an event that a client program process calls a delete function, jumping to a second proxy function, wherein the delete function is used to delete a thread local variable in a thread local variable array;

[0118] According to the variable address information of the thread local variable passed by the client program process, the variable address information is deleted in the target linked list through the second proxy function, and the deletion function is called to delete the corresponding thread local variable in the thread local variable array according to the variable address information.

[0119] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 5, wherein inserting the variable address information into the target linked list includes:

[0120] Generate structure data corresponding to the thread local variable according to the variable address information of the thread local variable and the dynamic library and thread for creating the thread local variable;

[0121] Insert the structure data into the target linked list;

[0122] Deleting the variable address information in the target linked list includes:

[0123] According to the variable address information of the thread local variable, the corresponding structure data is deleted in the target linked list.

[0124] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6, wherein the method further includes:

[0125] In response to an exception occurring in the client program, printing the information in the target linked list to a file;

[0126] Determine the dynamic library and thread that create the most thread local variables based on the information in the file;

[0127] Report the dynamic library and thread information that creates the most thread local variables to the server.

[0128] According to one or more embodiments of the present disclosure, Example 8 provides a resource management device, including:

[0129] A first response module, configured to jump to a first proxy function in response to obtaining an event that a client program process calls a create function, wherein the create function is configured to create a thread local variable in a thread local variable array;

[0130] A judgment module, used to determine, through the first proxy function, whether the variable address information of the thread local variables passed in by the client program process exists in a target linked list, where the target linked list is used to store the variable address information of the thread local variables created historically;

[0131] The first processing module is used for not creating a corresponding thread local variable in the thread local variable array when the variable address information exists in the target linked list.

[0132] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon, which implements the method of any one of Examples 1 to 7 when executed by a processing device.

[0133] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, including:

[0134] a storage device having a computer program stored thereon;

[0135] A processing device is used to execute the computer program in the storage device to implement the method of any one of Examples 1 to 7.

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

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

[0138] 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 resource management method, characterized in that: include: In response to an event of a client program process calling a create function obtained by a Hook method, jumping to a first proxy function, wherein the create function is used to create a corresponding thread local variable in a thread local variable array according to the variable address information passed in; Determine, through the first proxy function, whether the variable address information of the thread local variables passed in by the client program process exists in a target linked list, where the target linked list is used to store the variable address information of the thread local variables created historically; If the variable address information exists in the target linked list, then the corresponding thread local variable is not created in the thread local variable array; If the variable address information does not exist in the target linked list, inserting the variable address information into the target linked list through the first proxy function; And, calling the creation function through the first proxy function to create corresponding thread local variables in the thread local variable array according to the variable address information.

2. The method according to claim 1, characterized in that The determining whether the variable address information of the thread local variable passed in by the client program process exists in the target linked list includes: Determine whether the target linked list is an empty linked list; If the target linked list is not an empty linked list, traverse each variable address information in the target linked list, and compare the variable address information input with the variable address information in the target linked list; If the variable address information passed in is the same as any variable address information in the target linked list, it is determined that the variable address information passed in by the client program process exists in the target linked list.

3. The method according to claim 2, characterized in that The determining whether the variable address information of the thread local variable passed in by the client program process exists in the target linked list includes: If the target linked list is an empty linked list, or the variable address information passed in is different from all the variable address information in the target linked list, it is determined that the variable address information passed in by the client program process does not exist in the target linked list.

4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: In response to obtaining an event that a client program process calls a delete function, jumping to a second proxy function, wherein the delete function is used to delete a thread local variable in a thread local variable array; According to the variable address information of the thread local variable passed by the client program process, the variable address information is deleted in the target linked list through the second proxy function, and the deletion function is called to delete the corresponding thread local variable in the thread local variable array according to the variable address information.

5. The method according to claim 4, characterized in that Inserting the variable address information into the target linked list includes: Generate structure data corresponding to the thread local variable according to the variable address information of the thread local variable and the dynamic library and thread for creating the thread local variable; Insert the structure data into the target linked list; Deleting the variable address information in the target linked list includes: According to the variable address information of the thread local variable, the corresponding structure data is deleted in the target linked list.

6. The method according to claim 5, characterized in that The method further comprises: In response to an exception occurring in the client program, printing the information in the target linked list to a file; Determine the dynamic library and thread that create the most thread local variables based on the information in the file; Report the dynamic library and thread information that creates the most thread local variables to the server.

7. A resource management device, characterized in that: include: A first response module, configured to jump to a first proxy function in response to an event that a client program process calls a create function obtained by a Hook method, wherein the create function is configured to create a corresponding thread local variable in a thread local variable array according to the variable address information passed in; A judgment module, used to determine, through the first proxy function, whether the variable address information of the thread local variables passed in by the client program process exists in a target linked list, wherein the target linked list is used to store the variable address information of the thread local variables created historically; A first processing module is used for not creating a corresponding thread local variable in the thread local variable array if the variable address information exists in the target linked list; and is also used for: if the variable address information does not exist in the target linked list, inserting the variable address information in the target linked list through the first proxy function; And, calling the creation function through the first proxy function to create corresponding thread local variables in the thread local variable array according to the variable address information.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the steps of the method described in any one of claims 1 to 6 are implemented.

9. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 6.