CN114595008A - System resource management method and related equipment - Google Patents

System resource management method and related equipment Download PDF

Info

Publication number
CN114595008A
CN114595008A CN202011409225.4A CN202011409225A CN114595008A CN 114595008 A CN114595008 A CN 114595008A CN 202011409225 A CN202011409225 A CN 202011409225A CN 114595008 A CN114595008 A CN 114595008A
Authority
CN
China
Prior art keywords
resource
function
target system
system resource
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011409225.4A
Other languages
Chinese (zh)
Inventor
周志刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN202011409225.4A priority Critical patent/CN114595008A/en
Publication of CN114595008A publication Critical patent/CN114595008A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a system resource management method and related equipment, which can solve the problems that developers need to release each resource manually, the efficiency is low, and primary developers can still have the problem that the system resources cannot be released correctly because the primary developers do not know which system resources need to be released. The method comprises the following steps: acquiring a system function for creating and a system function for releasing target system resources; establishing a corresponding relation between the creating system function and the releasing system function; monitoring the calling of the target system resource; and when the execution of the function for calling the target system resource is monitored to be finished, releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource.

Description

System resource management method and related equipment
Technical Field
The present application relates to the field of program development technologies, and in particular, to a system resource management method and a related device.
Background
Some system resources in the program are invaluable, but some developers can cause the resources not to be released due to human negligence, so that the program is crashed when the running time is longer. Thus, some system resources need to be released.
At present, developers need to release each resource manually, the efficiency is low, and a large amount of repeated work is needed. Moreover, the primary developer may not know which system resources need to be released, and thus may not release the system resources correctly.
Disclosure of Invention
The embodiment of the application provides a system resource management method and related equipment, which can solve the problems that developers need to release each resource manually, the efficiency is low, and primary developers can still have the problem that the system resources cannot be released correctly because the primary developers do not know which system resources need to be released.
A first aspect of an embodiment of the present application provides a method for managing system resources, including:
acquiring a system function for creating and a system function for releasing target system resources;
establishing a corresponding relation between the creating system function and the releasing system function;
monitoring the calling of the target system resource;
and when the execution of the function for calling the target system resource is monitored to be finished, releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource.
Optionally, before the steps of acquiring a system function of the target system resource, and releasing the system function, the method further includes:
defining configuration information of system resources through a preset configuration template, wherein the configuration information comprises: the system resource creating system function, the system resource creating module name, the system resource releasing system function and the system resource releasing module name;
performing an incremental auto-scan check on the code based on a code baseline;
and if the codes matched with the configuration information are scanned and detected, increasing the system resources corresponding to the configuration information as target system resources.
Optionally, the step of monitoring the invocation of the target system resource includes:
monitoring the invocation of the target system resource by an additional process that is independent of the function that invoked the target system resource.
Optionally, the step of monitoring the call of the target system resource by an additional process independent of the function that calls the target system resource includes:
acquiring the distribution information and the destruction information of the target system resource;
serializing the distribution information and the destruction information to generate message data;
and sequencing the message data of the current target system resources of the same type according to time, and carrying out classified transmission on the message data of the target system resources of different types.
Optionally, the step of obtaining the allocation information and the destruction information of the target system resource includes:
acquiring call stack information of a current target system resource, wherein the acquisition mode of the call stack information comprises the following steps:
the step is obtained by a Stackwalk stacking mode, and/or,
and the assembly code is acquired by backtracking through an ebp extended base address pointer register and an esp extended stack pointer register.
Optionally, before the step of sorting the message data of the current same type of target system resource according to time and performing classified transmission on the message data of different types of target system resources, the method further includes:
creating template special classes for monitoring different target system resources through template < T > class screened resource, wherein T is a member variable, template represents a template, and screened resource represents resource monitoring;
assigning the parameters of the target system resource to the member variable T for storage through scoped resource (T resource) _ (resource);
the creation Time of the target system resource is recorded through the construction function, and specifically, the creation Time can be realized through Time start ═ Time:: CurrentTime (), wherein the Time start represents the creation Time.
Optionally, after the monitoring that the function for calling the target system resource is executed, the step of releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type to which the target system resource belongs includes:
if the function calling the target system resource is in an internal use condition, after the function calling the target system resource is monitored to be executed completely, the function automatically executes a destructor-scoped resource () of the function, and releases the target system resource through the destructor-scoped resource ();
if the function calling the target system resource is the external use condition, a template specific object autoResource needs to be instantiated according to the type of the current target system resource, and when the external use condition is the global use and/or class member function, the autoResource is established behind the target system resource to ensure that the autoResource is released behind the resource.
A second aspect of the present application provides a system resource management apparatus, including:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a system creating function and a system releasing function of target system resources;
a creating unit, configured to create a corresponding relationship between the creating system function and the releasing system function;
the monitoring unit is used for monitoring the calling of the target system resource;
and the release unit is used for releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource after the completion of the execution of the function for calling the target system resource is monitored.
A third aspect of the embodiments of the present application provides an electronic device, which includes a memory and a processor, where the processor is configured to implement the steps of the system resource management method when executing a computer program stored in the memory.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the system resource management method described above.
In summary, the system resource management method provided by the embodiment of the present application establishes a system function and releases the system function by acquiring a target system resource; establishing a corresponding relation between the creating system function and the releasing system function; monitoring the calling of the target system resource; and releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource after the completion of the execution of the function for calling the target system resource is monitored. Because a set of framework automation processing procedures for releasing system resources are designed from the bottom layer, the management of the system resources can be more intelligent and more suitable for all situations. Therefore, the system resources of different types can be adapted without modifying programs, so that the automatic release of the target system resources is realized, developers do not need to release the system resources manually, and openers do not need to master which resources need to be released and which resources do not need to be released.
Accordingly, the system resource management device, the electronic device and the computer-readable storage medium provided by the embodiment of the invention also have the technical effects.
Drawings
Fig. 1 is a schematic flowchart of a possible system resource management method according to an embodiment of the present disclosure;
fig. 2 is a schematic structural block diagram of a possible system resource management device according to an embodiment of the present disclosure;
fig. 3 is a schematic hardware structure diagram of a possible system resource management apparatus according to an embodiment of the present disclosure;
fig. 4 is a schematic structural block diagram of a possible electronic device provided in an embodiment of the present application;
fig. 5 is a schematic structural block diagram of a possible computer-readable storage medium provided in an embodiment of the present application.
Detailed Description
The embodiment of the application provides a system resource management method and related equipment, and can solve the problems that developers need to release each resource manually, the efficiency is low, and primary developers still do not know which system resources need to be released, so that the system resources cannot be released correctly.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the drawings described above, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments.
Referring to fig. 1, a flowchart of a system resource management method according to an embodiment of the present application may specifically include: S110-S140.
S110, acquiring a system function for creating the target system resource and a system function for releasing the target system resource.
For system resources, it is necessary to acquire which resources of the system are target system resources that must be released, and for resources that need to be released, automatic monitoring and releasing are required, and for unnecessary resources, releasing is not required, and then it is necessary to count and acquire system function creation and system function release of the target system resources.
Illustratively, the target system resource includes a system HANDLE, HANDLE, which is the basis for the entire Windows programming. A handle refers to a unique integer value, i.e., a 4-byte (8-byte in a 64-bit program) long value, used to identify different objects in an application and different instances of the same type of object, such as a window, button, icon, scroll bar, output device, control, or file. The system handle includes functions of system APIs, such as a handle for reading and writing files, a memory mapped file, a network socket handle, and the like.
Illustratively, before the steps of creating a system function and releasing the system function of the target system resource are obtained, the method further includes:
defining configuration information of system resources through a preset configuration template, wherein the configuration information comprises: the system resource creating system function, the system resource creating module name, the system resource releasing system function and the system resource releasing module name;
performing an incremental auto-scan check on the code based on a code baseline;
and if the codes matched with the configuration information are scanned and detected, increasing the system resources corresponding to the configuration information as target system resources.
It should be noted that all relevant target system resources are collected through S110, however, as time goes on, the system will release a new version, and thus will provide new resources and relevant system API functions, and then the above system resource management method needs to be automatically adapted and supported without modification for the new resources. The method can provide a user with new system resources automatically expanded by adding configuration items in a configuration mode.
Exemplary, Config: { configured using a Config file.
Each configuration item requires 4 data, and the configuration items are as follows:
SystemModuleName: "Module name to which System function for creating resource belongs";
SystemAPIName: "create system API function name for resource";
SystemModuleName2, "Module name to which System function for releasing resources belongs";
SystemAPIName2: "System API function name to release resources";
and if new configuration items need to be added, the new configuration items can be continuously added in the configuration file.
}
One of the configuration items is to know which are calls with resources when scanning the code, and how the resources should be released when automatically releasing the resources.
Illustratively, a suite of underlying automation frameworks may be provided, which may be transparent to developers without concern for implementation details. Monitoring and releasing to be able to automate cannot be set out from the development level point of view. The rules can be set to start from a code baseline of one version, identify all resource creations for an automatic scanning baseline version of the code, and then, on the basis of the baseline, when a subsequent developer submits the developed new function code, the code is subjected to incremental scanning inspection on a continuous integration server of the code through an inspection hook submitting the code.
By the method, the accuracy of the code can be improved, and the checking speed can be improved. After the subsequent codes are added, developers who submit the codes can observe the added functions of automatically monitoring and releasing resources and can achieve the effect of manual rechecking. If the creating system function and the releasing system function of the resource based on the target system resource acquired in S110 are checked, if there is a resource allocation situation when the corresponding system API function is called in the code, the marking is performed.
In some examples, two usage schemes, namely, the internal usage scheme and the external usage scheme, can be distinguished, so that a basis is provided for a subsequent release mode of target system resources. The internal use based function means that the function is used in one function, and the function is used after finishing. The function is used externally, the storage of the resource handle is in a member variable of a class or a global variable, so that the resource is used externally, the resource is created along with the creation of the object of the class, and the resource needs to be released along with the destruction of the object of the class. Global is the need to release as the program exits.
S120, establishing the corresponding relation between the creating system function and the releasing system function.
Illustratively, the release for each resource type is different and a good pairing relationship needs to be formed.
For example, creation of a system handle system function: HANDLE HANDLE is CreateFile (parameter); and creating a system function: HANDLE HANDLE ═ CreateFileMapping (parameter); the system handle mostly also includes the creation of other system handles, and all related handles need to be collected to create system functions. Release of system handle system function: CloseHandle (handle), which may be released by the system function CloseHandle. Here, the correspondence relationship between the creation system function and the release system function may be established.
As another example, the creation of a web socket handle is a system function: int socket fd ═ socket (parameter); release system function of web socket handle: close (sockfd), which can be released by the system function close. Here, the correspondence relationship between the creation system function and the release system function may be established.
As another example, the creation of a system information handle is a system function: struct addrinfo results; getaddrinfo (parameters) & results) may be created; where the core parameters & results are the created system resource data. Release system function of system information handle: freeaddrinfo (results); it can be released by releasing the system function freeaddrinfo. Here, the correspondence relationship between the creation system function and the release system function may be established.
By the above example, the creating system function and the releasing system function of all relevant system resources can be collected, and the creation of these resources must be created using the system functions and the pairing relationship thereof needs to be formed.
S130, monitoring the calling of the target system resource.
Illustratively, the step of monitoring the invocation of the target system resource includes:
the invocation of the target system resource is monitored by an additional process that is independent of the function that invokes the target system resource.
It should be noted that, the monitoring of the invocation of the target system resource may include counting the usage of the resource, monitoring the allocation and release of the resource, locating the creation time of the resource, creating the intensity of the resource, creating the quantity of the resource, and the like.
For example, a resource monitoring center may be established, where the monitoring center may be an additional process independent of a function program calling the target system resource, and the resource monitoring center is an independent process for displaying the usage of the resource and the creation and destruction of each resource. In order not to affect the performance and stability of the current calling function program, an independent resource monitoring center needs to be created to show the use condition of the current resource, wherein the creation time and the destruction time of each resource can be included, and the total number of each resource used currently can be displayed. The monitoring center acquires the use data of the resource from the following modules through interprocess communication. The monitoring center will mainly use web pages or some interface controls to show the use cases for these data. For example, an independent process monitor resource can be used for monitoring the resource, and the function of the independent process monitor resource is to receive the data sent to the monitoring process through inter-process communication, and the monitoring process performs interface display after acquiring the data.
Illustratively, the step of monitoring the invocation of the target system resource by an additional process independent of the release of the target system resource includes:
acquiring the distribution information and the destruction information of the target system resource;
serializing the distribution information and the destruction information to generate message data;
and sequencing the message data of the current target system resources of the same type according to time, and carrying out classified transmission on the message data of the target system resources of different types.
Exemplarily, the step of obtaining the allocation information and the destruction information of the target system resource includes:
acquiring call stack information of current target system resources, wherein the acquisition mode of the call stack information comprises the following steps:
the step is obtained by a Stackwalk stacking mode, and/or,
and obtaining the assembly code based on a retrospective mode through an ebp extended base address pointer register and an esp extended stack pointer register.
Specifically, in the monitoring step, a resource data distribution center needs to be created, where the center is a component belonging to the resource calling function program, and is used to convert and classify the resource information of the resource calling function program and transmit the resource information to the resource monitoring center SendResource of the independent process through inter-process communication. The center receives the message data which is distributed and destroyed by the resources and then is serialized into the message data which is convenient to communicate with the monitoring center, the resources related to the current moment are classified and transmitted, meanwhile, each resource is sequenced according to the time sequence, the resources including different types can also be sequenced according to the time sequence, the similar resources are packed and transmitted together, and therefore, the displayed curve and the displayed interface are more continuous when the monitoring center displays the resources.
Specifically, for the creation of each resource, the current call stack condition can be implanted and acquired during the creation, so that the function call stack information created by the current resource can be displayed or printed at any time, and the resource allocation of which resource calls is more, the resource allocation of which time is more, and the call chain condition of the function call stack can be conveniently checked. The specific acquisition of the function call stack can be realized by a StackWalk method, or by an assembly code in a backtracking manner through an ebp register esp register.
For example, before the step of sorting the message data of the current same type of target system resource according to time and performing classified transmission on the message data of different types of target system resources, the method further includes:
creating template special classes for monitoring different target system resources through template < T > class screened resource, wherein T is a member variable, template represents a template, and screened resource represents resource monitoring;
assigning the parameters of the target system resource to the member variable T for storage through scoped resource (T resource) _ (resource);
the creation Time of the target system resource is recorded through the construction function, and specifically, the creation Time can be realized through Time start ═ Time:: CurrentTime (), wherein the Time start represents the creation Time.
In particular, related functions may be encapsulated by a template class template < T > class ScopedResource class. The resource handles are of various types, some are handles, some are sockets, and the like, so that different resource types need to be adapted through the template. Using T resource _; this member variable storage resource handle is defined. Designing its constructor requires the introduction of the correspondingly created resource handle. The template designs a general method, and for each specific handle, the function corresponding to the template specialization needs to be realized. For example, if the resource is of type HANDLE, then a template specialization class of class ScopedResource < HANDLE > for template specialization needs to be implemented. The same applies to classes that implement template specialization for other resources. For each specialized template class, the following functions need to be performed: the parameters of the target system resource are assigned to the member variable T to be stored through scoped resource (T resource). The creation time of the resource is recorded in the constructor, so that the use duration of the resource is convenient to count. For example, using the statement Time start ═ Time:: CurrentTime (); the start time is defined to be equal to the current time. Meanwhile, the current call stack Stack walk can be obtained through the function call stack, so that the call stack information of the current resource allocation can be obtained. Meanwhile, the current resource information can be sent to the monitoring center by calling the SendResource component. The data sent specifically may include a resource type, a current creation time, and a current function call stack, and these pieces of information may be packaged and serialized by the component SendResource and sent to the monitoring process for presentation.
And S140, after the function calling the target system resource is monitored to be executed, releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource.
For example, the step of releasing the target system resource through a release system function corresponding to a create system function of the target system resource based on a preset type to which the target system resource belongs after monitoring that the function that calls the target system resource is executed, includes:
if the function calling the target system resource is in an internal use condition, after the function calling the target system resource is monitored to be executed completely, the function automatically executes a destructor-scoped resource () of the function, and releases the target system resource through the destructor-scoped resource ();
if the function calling the target system resource is the external use condition, a template specific object autoResource needs to be instantiated according to the type of the current target system resource, and when the external use condition is the global use and/or class member function, the autoResource is established behind the target system resource to ensure that the autoResource is released behind the resource.
Specifically, for the case of external use of a function, which is not within a function body, the case is classified into the case of global use and the case of class member functions. For both cases, a template-specific object auto resource needs to be instantiated according to the current resource type and a handle of the current resource is stored. For member variables in a class, the autoResource construct must be constructed behind it so that the object can be guaranteed to be released later. For the case of global objects we need to create behind the resource, we are guaranteed that our autoResource is released behind the resource. For example:
classs Test { e.g. class Test)
Handle h; it has a member variable handle h;
ScopedResource < HANDLE > AutoResource (h); the automatically filled object is declared behind it, thereby ensuring that the object is released after the system resource to be released.
The case for global variables is as follows:
handle h; it has a member variable handle h;
ScopedResource < HANDLE > AutoResource (h); the automatically filled object is declared behind it, thereby ensuring that the object is released after the system resource to be released. Therefore, the resource is released after the program to be executed is executed, and the resource is prevented from being released in advance.
Specifically, the resource can be released in a destructor — scope resource () of the resource calling function. Releasing resources may use the corresponding system API. In S110, a system creating function and a system releasing function of the target system resource are obtained, a system API function created corresponding to each resource is set, and what kind of system AP is used for releasing each resource when releasing is also recorded, so that the system function can be obtained to release the resource based on the matching relationship in S120. For example, the module HANDLE corresponding to the system release resource API function is obtained by a statement "HANDLE hmodule" ("system moduleiname 2"). And then obtain the API function corresponding to the released resource. API func — system function GetProcAddress (hmodule, "systempaniname 2"); func (resource _); wherein, systemipramime 2 is the name of the API function for releasing the resource. After the release is completed, current time data can be obtained, and/or current released function call stack information is sent to the monitoring center through SendResource to inform that the current resource is released, so that the monitoring center can dynamically show the creation and destruction of the resource.
In summary, the method for managing system resources provided in the foregoing embodiments establishes a system function and releases the system function by obtaining target system resources; establishing a corresponding relation between the creating system function and the releasing system function; monitoring the calling of the target system resource; and releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource after the completion of the execution of the function for calling the target system resource is monitored. Because a set of framework automation processing procedures for releasing system resources are designed from the bottom layer, the management of the system resources can be more intelligent and more suitable for all situations. Therefore, the system resources of different types can be adapted without modifying programs, so that the automatic release of the target system resources is realized, developers do not need to release the system resources manually, and openers do not need to master which resources need to be released and which resources do not need to be released.
The above describes a system resource management method in the embodiment of the present application, and the following describes a system resource management device in the embodiment of the present application.
Referring to fig. 2, an embodiment of a system resource management device described in the embodiment of the present application may include:
an obtaining unit 201, configured to obtain a system creating function and a system releasing function of a target system resource;
a creating unit 202, configured to establish a corresponding relationship between the creating system function and the releasing system function;
a monitoring unit 203, configured to monitor the invocation of the target system resource;
a releasing unit 204, configured to release, after it is monitored that the function that calls the target system resource is executed, the target system resource through a releasing system function corresponding to the creating system function of the target system resource based on the preset type to which the target system resource belongs.
In summary, the system resource management apparatus provided in the foregoing embodiment creates a system function and releases the system function by acquiring a target system resource; establishing a corresponding relation between the creating system function and the releasing system function; monitoring the calling of the target system resource; and releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource after the completion of the execution of the function for calling the target system resource is monitored. Because a set of framework automation processing procedures for releasing system resources are designed from the bottom layer, the management of the system resources can be more intelligent and more suitable for all situations. Therefore, the system resources of different types can be adapted without modifying programs, so that the automatic release of the target system resources is realized, developers do not need to release the system resources manually, and openers do not need to master which resources need to be released and which resources do not need to be released.
Fig. 2 above describes the system resource management device in the embodiment of the present application from the perspective of a modular functional entity, and the system resource management device in the embodiment of the present application is described in detail below from the perspective of hardware processing, please refer to fig. 3, where an embodiment of the system resource management device 300 in the embodiment of the present application includes:
an input device 301, an output device 302, a processor 303 and a memory 304, wherein the number of the processor 303 may be one or more, and one processor 303 is taken as an example in fig. 3. In some embodiments of the present application, the input device 301, the output device 502, the processor 303, and the memory 304 may be connected by a bus or other means, wherein fig. 3 illustrates the connection by the bus.
Wherein, by calling the operation instruction stored in the memory 304, the processor 303 is configured to perform the following steps:
acquiring a system function for creating and a system function for releasing target system resources;
establishing a corresponding relation between the creating system function and the releasing system function;
monitoring the calling of the target system resource;
and when the execution of the function for calling the target system resource is monitored to be finished, releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource.
The processor 303 is also configured to perform any of the methods in the corresponding embodiments of fig. 1 by calling the operation instructions stored in the memory 304.
Referring to fig. 4, fig. 4 is a schematic view of an embodiment of an electronic device according to an embodiment of the application.
As shown in fig. 4, an electronic device according to an embodiment of the present application includes a memory 410, a processor 420, and a computer program 411 stored in the memory 420 and running on the processor 420, where the processor 420 implements the following steps when executing the computer program 411:
acquiring a system function for creating and a system function for releasing target system resources;
establishing a corresponding relation between the creating system function and the releasing system function;
monitoring the calling of the target system resource;
and when the execution of the function for calling the target system resource is monitored to be finished, releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource.
In a specific implementation, when the processor 420 executes the computer program 411, any of the embodiments corresponding to fig. 1 may be implemented.
Since the electronic device described in this embodiment is a device used for implementing a system resource management apparatus in this embodiment, based on the method described in this embodiment, a person skilled in the art can understand a specific implementation manner of the electronic device of this embodiment and various variations thereof, so that how to implement the method in this embodiment by the electronic device is not described in detail herein, and as long as the person skilled in the art implements the device used for implementing the method in this embodiment, the device is within the scope of protection intended by this application.
Referring to fig. 5, fig. 5 is a schematic diagram illustrating an embodiment of a computer-readable storage medium according to the present application.
As shown in fig. 5, the present embodiment provides a computer-readable storage medium 500 having a computer program 511 stored thereon, the computer program 511 implementing the following steps when executed by a processor:
acquiring a system function for creating and a system function for releasing target system resources;
establishing a corresponding relation between the creating system function and the releasing system function;
monitoring the invocation of the target system resource;
and when the execution of the function for calling the target system resource is monitored to be finished, releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource.
In a specific implementation, the computer program 511 may implement any of the embodiments corresponding to fig. 1 when executed by a processor.
It should be noted that, in the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to relevant descriptions of other embodiments for parts that are not described in detail in a certain embodiment.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Embodiments of the present application further provide a computer program product, where the computer program product includes computer software instructions, and when the computer software instructions are run on a processing device, the processing device is caused to execute the flow in the system resource management method in the embodiment corresponding to fig. 1.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (10)

1. A method for managing system resources, comprising:
acquiring a system function for creating and a system function for releasing target system resources;
establishing a corresponding relation between the creating system function and the releasing system function;
monitoring the calling of the target system resource;
and when the execution of the function for calling the target system resource is monitored to be completed, releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource.
2. The method of claim 1, wherein the steps of obtaining the system function creation and the system function release of the target system resource are preceded by the method further comprising:
defining configuration information of system resources through a preset configuration template, wherein the configuration information comprises: the system resource creating system function, the system resource creating module name, the system resource releasing system function and the system resource releasing module name;
performing an incremental auto-scan check on the code based on a code baseline;
and if the codes matched with the configuration information are scanned and detected, increasing the system resources corresponding to the configuration information as target system resources.
3. The method of claim 1, wherein the step of monitoring the invocation of the target system resource comprises:
monitoring the invocation of the target system resource by an additional process that is independent of the function that invoked the target system resource.
4. The method of claim 3, wherein the step of monitoring the invocation of the target system resource by an additional process that is independent of the release of the target system resource comprises:
acquiring the distribution information and the destruction information of the target system resource;
serializing the distribution information and the destruction information to generate message data;
and sequencing the message data of the current target system resources of the same type according to time, and carrying out classified transmission on the message data of the target system resources of different types.
5. The method according to claim 4, wherein the step of obtaining the allocation information and the destruction information of the target system resource comprises:
acquiring call stack information of current target system resources, wherein the acquisition mode of the call stack information comprises the following steps:
the step is obtained by a Stackwalk stacking mode, and/or,
and obtaining the assembly code based on a retrospective mode through an ebp extended base address pointer register and an esp extended stack pointer register.
6. The method of claim 4, wherein before the step of sorting the message data of the current same type of target system resource according to time and performing classified transmission on the message data of different types of target system resources, the method further comprises:
creating template special classes for monitoring different target system resources through template < T > class screened resource, wherein T is a member variable, template represents a template, and screened resource represents resource monitoring;
assigning the parameters of the target system resource to the member variable T for storage through scoped resource (T resource) _ (resource);
the creation Time of the target system resource is recorded by a constructor Time start Time ═ Time:: CurrentTime (), where Time start represents the creation Time.
7. The method according to claim 1, wherein the step of releasing the target system resource through a release system function corresponding to a create system function of the target system resource based on a preset type to which the target system resource belongs after monitoring that the function calling the target system resource is executed completely comprises:
if the function calling the target system resource is in an internal use condition, after the function calling the target system resource is monitored to be executed completely, the function automatically executes a destructor-scoped resource () of the function, and releases the target system resource through the destructor-scoped resource ();
if the function calling the target system resource is the external use condition, a template specific object autoResource needs to be instantiated according to the type of the current target system resource, and when the external use condition is the global use and/or class member function, the autoResource is established behind the target system resource to ensure that the autoResource is released behind the resource.
8. A system resource management apparatus, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a system creating function and a system releasing function of target system resources;
a creating unit, configured to create a corresponding relationship between the creating system function and the releasing system function;
the monitoring unit is used for monitoring the calling of the target system resource;
and the release unit is used for releasing the target system resource through a release system function corresponding to the creation system function of the target system resource based on the preset type of the target system resource after the completion of the execution of the function for calling the target system resource is monitored.
9. An electronic device comprising a memory, a processor, wherein the processor is configured to implement the steps of the system resource management method according to any one of claims 1 to 7 when executing a computer program stored in the memory.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that: the computer program when executed by a processor implements the steps of the system resource management method of any of claims 1 to 7.
CN202011409225.4A 2020-12-03 2020-12-03 System resource management method and related equipment Pending CN114595008A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011409225.4A CN114595008A (en) 2020-12-03 2020-12-03 System resource management method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011409225.4A CN114595008A (en) 2020-12-03 2020-12-03 System resource management method and related equipment

Publications (1)

Publication Number Publication Date
CN114595008A true CN114595008A (en) 2022-06-07

Family

ID=81803220

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011409225.4A Pending CN114595008A (en) 2020-12-03 2020-12-03 System resource management method and related equipment

Country Status (1)

Country Link
CN (1) CN114595008A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010112A (en) * 2023-03-27 2023-04-25 北京渲光科技有限公司 Method and device for calling hook function, computer equipment and readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010112A (en) * 2023-03-27 2023-04-25 北京渲光科技有限公司 Method and device for calling hook function, computer equipment and readable storage medium

Similar Documents

Publication Publication Date Title
US7296188B2 (en) Formal test case definitions
CN108038045B (en) Android user behavior data acquisition method based on non-buried point
CN108427644A (en) Service test method, service testing system and service testing device
US20030126586A1 (en) Organization of test cases
JP2015526822A (en) Compliance testing engine for integrated computer systems
CN110704303B (en) Method and device for acquiring test coverage information
CN110515679A (en) Collecting method, device, equipment and storage medium
CN115934199A (en) Service performance monitoring tool, method, device and medium
CN114595008A (en) System resource management method and related equipment
CN115291856A (en) Flow establishing method and device and electronic equipment
CN115185496A (en) Service arrangement method based on Flowable workflow engine
US20060129891A1 (en) Software test framework
CN112764729B (en) Application software development method, device, computer equipment and readable storage medium
CN113641628B (en) Data quality detection method, device, equipment and storage medium
CN114942887A (en) Program safety testing method, device, equipment and medium
CN113407441A (en) Software testing method, device, equipment and storage medium
CN114003457A (en) Data acquisition method and device, storage medium and electronic equipment
CN112000386A (en) Application implementation method and device
Ngaogate Applying the flyweight design pattern to Android application development
CN112579530A (en) Data resource organization method and device of automatic test system
CN112069078A (en) ESA interface pressure testing method, device, testing equipment and storage medium
CN114070764B (en) Network function virtualization NFV test method, device and system
Teixeira et al. Compatibility evaluation of components specified in UML
Paradkar Inter-class testing of OO software in the presence of polymorphism
CN112612514B (en) Program development method and device, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination