CN116010105A - Resource management method, device, equipment and product - Google Patents

Resource management method, device, equipment and product Download PDF

Info

Publication number
CN116010105A
CN116010105A CN202310115834.6A CN202310115834A CN116010105A CN 116010105 A CN116010105 A CN 116010105A CN 202310115834 A CN202310115834 A CN 202310115834A CN 116010105 A CN116010105 A CN 116010105A
Authority
CN
China
Prior art keywords
virtual reference
pointer
management
reference object
queue
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
CN202310115834.6A
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.)
Autonavi Information Technology Co Ltd
Original Assignee
Autonavi Information 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 Autonavi Information Technology Co Ltd filed Critical Autonavi Information Technology Co Ltd
Priority to CN202310115834.6A priority Critical patent/CN116010105A/en
Publication of CN116010105A publication Critical patent/CN116010105A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a product for resource management, where the method includes: when a first object is created, creating a target virtual reference object corresponding to the first object, and binding the target virtual reference object with a virtual reference management queue; creating a corresponding relation between a pointer pointing to a second object and the target virtual reference object in an object management table; monitoring the virtual reference management queue, and if a virtual reference object enters the queue, removing the earliest entering virtual reference object; and querying at least a pointer corresponding to the moved virtual reference object in the object management table, and recovering a second object indicated by the queried pointer. According to the scheme, the second object can be recycled in time, so that the system is ensured not to overflow the system memory due to the fact that the second object occupies more system resources, the probability of normal operation of the system is improved, and the user experience is improved.

Description

Resource management method, device, equipment and product
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a product for resource management.
Background
In recent years, with the development of technology, the number of terminal devices such as mobile communication terminals and vehicle-mounted terminals has been rapidly increased, and various application programs APP (Application) have been widely used in the terminal devices in order to meet the increasing demands of users. Among them, the application program in the terminal device often needs to create various objects to implement the corresponding functions of the application program, such as information access, page presentation, status query, and the like.
The inventor of the application finds that if an application program running in a system (written in a first language) is written in a second language, an object called by the application program cannot be recovered in time, so that the possibility of memory overflow exists in the system, at this time, the system may take an operation of interrupting or terminating the application program in order to ensure normal running, which causes abnormal running (forced closing and the like) of the application program and influences user experience.
Disclosure of Invention
In order to solve the problems in the related art, embodiments of the present disclosure provide a resource management method, apparatus, device, and product.
In a first aspect, an embodiment of the present disclosure provides a resource management method, including:
when a first object is created, a target virtual reference object corresponding to the first object is created, and the target virtual reference object is bound with a virtual reference management queue, wherein the first object is an object written in a first language, and the virtual reference management queue is used for recording the virtual reference object corresponding to the recovered first object;
creating a corresponding relation between a pointer pointing to a second object and a target virtual reference object in an object management table, wherein the second object is held by a first object, and the second object is written in a second language;
monitoring a virtual reference management queue, and if a virtual reference object enters the queue, removing the earliest entering virtual reference object in the virtual reference management queue from the virtual reference management queue;
inquiring a pointer corresponding to the moved virtual reference object in the object management table, and recovering the second object indicated by the inquired pointer to release the memory resource occupied by the second object.
In a second aspect, an embodiment of the present disclosure provides a resource management apparatus, including:
the object creation module is configured to create a target virtual reference object corresponding to a first object when the first object is created, and bind the target virtual reference object with a virtual reference management queue, wherein the first object is an object written in a first language, and the virtual reference management queue is used for recording the virtual reference object corresponding to the recovered first object;
the relation creation module is configured to create a corresponding relation between a pointer pointing to a second object and a target virtual reference object in the object management table, wherein the second object is held by the first object, and the second object is written in a second language;
the monitoring module monitors the virtual reference management queue, and if a virtual reference object enters the queue, the virtual reference object which enters the reference management queue earliest is removed from the virtual reference management queue;
the object recycling module is configured to query pointers corresponding to the moved virtual reference objects in the object management table, and recycle the second objects indicated by the queried pointers so as to release memory resources occupied by the second objects.
In a third aspect, embodiments of the present disclosure provide an electronic device comprising a memory and a processor, wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement a method as in the first aspect or any implementation of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program/instruction, wherein the computer program/instruction, when executed by a processor, implements the method according to the first aspect or any implementation of the first aspect.
In the technical scheme of the disclosure, when a first object is created, a target virtual reference object corresponding to the first object is created, and the target virtual reference object is bound with a virtual reference management queue, wherein the target virtual reference object is used for being recorded by the virtual reference management queue when the first object is recycled, so that the virtual reference management queue can be understood to be used for storing the virtual reference object corresponding to the recycled first object; then, in the object management table, a corresponding relation between a pointer pointing to the second object and the target virtual reference object is created, the virtual reference management queue is monitored, if the virtual reference object in the queue enters, the first object corresponding to the virtual reference object can be considered to be recycled, in this case, the virtual reference object which enters the virtual reference management queue earliest is moved out of the virtual reference management queue, at least the pointer corresponding to the moved virtual reference object is queried in the object management table, and the second object indicated by the queried pointer is recycled, so that memory resources occupied by the second object are released, and the system can recover the second object (namely the recycled first object) corresponding to the virtual reference object stored in the virtual reference management queue more timely under the condition that the first object is recycled, so that the system can not overflow the system memory due to the fact that the second object occupies more system resources, and the normal operation probability of the system is improved, and user experience is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
Other features, objects and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments, taken in conjunction with the accompanying drawings. In the drawings:
fig. 1 shows a schematic flow chart of a resource management method according to an embodiment of the present disclosure.
Fig. 2 shows a schematic diagram of a first object and a second object according to an embodiment of the disclosure.
Fig. 3 shows a block diagram of a resource management device according to an embodiment of the present disclosure.
Fig. 4 shows a block diagram of an electronic device according to an embodiment of the disclosure.
Fig. 5 shows a schematic diagram of a computer system suitable for use in implementing methods according to embodiments of the present disclosure.
Detailed Description
Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. In addition, for the sake of clarity, portions irrelevant to description of the exemplary embodiments are omitted in the drawings.
In this disclosure, it should be understood that terms such as "comprises" or "comprising," etc., are intended to indicate the presence of features, numbers, steps, acts, components, portions, or combinations thereof disclosed in this specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, acts, components, portions, or combinations thereof are present or added.
In addition, it should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In the present disclosure, if an operation of acquiring user information or user data or an operation of presenting user information or user data to another person is referred to, the operations are all operations authorized, confirmed, or actively selected by the user.
The inventor of the application finds that in practical situations, if an application program running in a system (written in a first language) is written in a second language, an object called by the application program cannot be recovered in time, so that the possibility of memory overflow exists in the system. For example, an Android (Android) system is taken as an example, wherein the Android system is written based on a Java language (i.e., a first language), and if an application running in the Android system is written in a c++ language (i.e., a second language), an object called by the application (i.e., a c++ object) may not be recovered in time, so that there is a possibility that the Android system has memory overflow.
At this time, the system may take an operation of interrupting or terminating the application program to ensure normal operation, which may cause abnormal operation (forced shutdown, etc.) of the application program, affecting user experience.
In order to solve the above-mentioned problem, in the technical solution of the present disclosure, by creating a target virtual reference object corresponding to a first object when the first object is created, and binding the target virtual reference object with a virtual reference management queue, where the target virtual reference object is used to be recorded by the virtual reference management queue when the first object is reclaimed, so the virtual reference management queue can be understood to be used to save the virtual reference object corresponding to the reclaimed first object; then, in the object management table, a corresponding relation between a pointer pointing to the second object and the target virtual reference object is created, the virtual reference management queue is monitored, if the virtual reference object in the queue enters, the first object corresponding to the virtual reference object can be considered to be recycled, in this case, the virtual reference object which enters the virtual reference management queue earliest is moved out of the virtual reference management queue, at least the pointer corresponding to the moved virtual reference object is queried in the object management table, and the second object indicated by the queried pointer is recycled, so that memory resources occupied by the second object are released, and the system can recover the second object (namely the recycled first object) corresponding to the virtual reference object stored in the virtual reference management queue more timely under the condition that the first object is recycled, so that the system can not overflow the system memory due to the fact that the second object occupies more system resources, and the normal operation probability of the system is improved, and user experience is improved.
Fig. 1 shows a schematic flow chart of a resource management method according to an embodiment of the present disclosure. As shown in fig. 1, the resource management method includes the following steps S101 to S104:
in step S101, when a first object is created, creating a target virtual reference object corresponding to the first object, and binding the target virtual reference object with a virtual reference management queue;
the virtual reference management queue is used for recording virtual reference objects corresponding to the recovered first objects;
in step S102, creating, in the object management table, a correspondence relationship between a pointer to the second object and the target virtual reference object;
wherein the second object is held by the first object, and the second object is written in a second language;
in step S103, a virtual reference management queue is monitored, and if a virtual reference object in the queue enters, the virtual reference object which enters the virtual reference management queue earliest is removed from the virtual reference management queue;
in step S104, at least the pointer corresponding to the moved virtual reference object is queried in the object management table, and the second object indicated by the queried pointer is recycled, so as to release the memory resource occupied by the second object.
In one implementation of the present disclosure, the first object and the second object may be understood as objects implemented based on different languages, and by way of example, the first language may be Java, and the second language may be c++ or C; alternatively, the first language may be the c++ or C language and the second language may be the Java language. Where an object may be understood as an element of a corresponding system implemented based on a corresponding language, the object may comprise at least one variable, or comprise at least one data structure, or comprise at least one function (which may also be referred to as a method), etc.
By way of example, fig. 2 shows a schematic diagram of a first object and a second object according to an embodiment of the present disclosure, as shown in fig. 2, the first object is a Java object provided by a Java Native interface (Java Native Interface, JNI) located in a Java layer, and the first object accesses a c++ object located in a Native layer (i.e., c++ layer), i.e., the second object, through a pointer held by the first object by using a JNIWrapper tool.
In one implementation of the present disclosure, a virtual reference (Phantom Reference) object may be understood as an object that is not available for reference, and the garbage collector (Garbage Collection, GC) may ignore the virtual reference object.
In one implementation manner of the present disclosure, the object management table is used to indicate a correspondence between the virtual reference object and the pointer, which may be understood that the object management table stores at least one piece of relationship indicating information, where the relationship indicating information is used to indicate a relationship between the corresponding virtual reference object and the corresponding pointer; alternatively, it may be understood that the object management table stores at least one row of management table data, where each row of management table data includes an identifier of a corresponding virtual reference object and an identifier of a corresponding pointer.
In one implementation of the present disclosure, monitoring the virtual reference management queue may be understood as setting a corresponding work thread to monitor the virtual reference management queue, and when the virtual reference management queue is inserted into a new node corresponding to the virtual reference object, it may be determined that the virtual reference management queue has the virtual reference object entered.
In one implementation of the present disclosure, the virtual reference object that enters earliest in the virtual reference management queue may be determined according to the insertion time information for indicating the time when the corresponding virtual reference object enters the virtual reference management queue, or may be understood that the arrangement order of the virtual reference objects in the virtual reference management queue is set according to the time when the virtual reference object enters the reference management queue, and according to the arrangement order, the virtual reference object that enters earliest in the virtual reference management queue may be determined.
In one implementation of the present disclosure, the reclaiming operation is performed on the second object indicated by the queried pointer, which may be understood as acquiring a pre-stored reclaiming method corresponding to the second object and performing the reclaiming operation on the second object according to the reclaiming method, or may be understood as acquiring a reclaiming method corresponding to the second object from another device or system and performing the reclaiming operation on the second object according to the reclaiming method.
In the technical scheme of the disclosure, when a first object is created, a target virtual reference object corresponding to the first object is created, and the target virtual reference object is bound with a virtual reference management queue, wherein the target virtual reference object is used for being recorded by the virtual reference management queue when the first object is recycled, so that the virtual reference management queue can be understood to be used for storing the virtual reference object corresponding to the recycled first object; then, in the object management table, a corresponding relation between a pointer pointing to the second object and the target virtual reference object is created, the virtual reference management queue is monitored, if the virtual reference object in the queue enters, the first object corresponding to the virtual reference object can be considered to be recycled, in this case, the virtual reference object which enters the virtual reference management queue earliest is moved out of the virtual reference management queue, at least the pointer corresponding to the moved virtual reference object is queried in the object management table, and the second object indicated by the queried pointer is recycled, so that memory resources occupied by the second object are released, and the system can recover the second object (namely the recycled first object) corresponding to the virtual reference object stored in the virtual reference management queue more timely under the condition that the first object is recycled, so that the system can not overflow the system memory due to the fact that the second object occupies more system resources, and the normal operation probability of the system is improved, and user experience is improved.
In one embodiment of the present disclosure, removing the earliest incoming virtual reference object in the virtual reference management queue from the virtual reference management queue includes:
and removing the virtual reference object at the head of the virtual reference management queue from the virtual reference management queue.
In the technical scheme of the present disclosure, the virtual reference object at the head of the virtual reference management queue is moved out of the virtual reference management queue, so as to achieve the purpose of moving the virtual reference object which enters the virtual reference management queue earliest out of the virtual reference management queue, thereby reducing the difficulty of moving out the virtual reference object, reducing the required operand and lowering the cost.
In one embodiment of the present disclosure, creating, in an object management table, a correspondence of a pointer to a second object and a target virtual reference object includes:
taking the target virtual reference object as an index value, taking a pointer pointing to the second object as a table value corresponding to the index value, and inserting the target virtual reference object into an object management table;
querying pointers corresponding to the removed virtual reference objects in the object management table comprises the following steps:
and taking the shifted virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to acquire a pointer corresponding to the shifted virtual reference object.
In one implementation of the present disclosure, an index value may also be understood as a key value, and a table value may also be understood as a value.
In the technical scheme of the disclosure, the target virtual reference object is taken as an index value, the pointer pointing to the second object is taken as a table value corresponding to the index value, the object management table is inserted, then the moved virtual reference object is taken as the index value, the table value corresponding to the index value is queried in the object management table, so that the pointer corresponding to the moved virtual reference object can be obtained, the format of the object management table can be simplified as much as possible, and the storage space required by the object management table is reduced on the premise of not reducing the information quantity in the object management table, thereby reducing the cost.
In one embodiment of the present disclosure, the method further comprises the steps of:
acquiring the memory quantity occupied by the second object;
creating, in the object management table, a correspondence between a pointer to the second object and the target virtual reference object, including:
taking the target virtual reference object as an index value, taking a pointer pointing to the second object and the memory quantity as table values corresponding to the index value respectively, and inserting the table values into an object management table;
at least inquiring the pointer corresponding to the moved virtual reference object in the object management table can be realized by the following steps:
taking the removed virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the removed virtual reference object and a corresponding memory amount;
the method further comprises the following steps:
and sending memory quantity indicating information for indicating the memory quantity corresponding to the moved virtual reference object to the operating system.
In one implementation of the present disclosure, the memory amount indication information may be understood as an information for at least indicating the memory amount corresponding to the virtual reference object that is moved out by the system to enable a corresponding operator to perform corresponding recording or analysis; it may be understood that the system is indicated to perform one step operation according to the memory amount corresponding to the moved virtual reference object indicated by the memory amount indication information, and for example, when the memory amount corresponding to the moved virtual reference object is too high, the system may trigger the garbage collector (Garbage Collection, GC) to implement recycling of the unremoved object in the system.
In the technical scheme of the present disclosure, the memory amount occupied by the second object is obtained; taking the target virtual reference object as an index value, taking a pointer pointing to the second object and the memory quantity as table values corresponding to the index value respectively, and inserting the table values into an object management table; taking the removed virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the removed virtual reference object and a corresponding memory amount; and sending memory quantity indicating information for indicating the memory quantity corresponding to the moved virtual reference object to the operating system. The memory quantity corresponding to the virtual reference object, namely the memory quantity occupied by the second object, can be conveniently obtained by the operating system, so that an operator using the operating system can perform corresponding recording or analysis on the memory quantity, or the operating system can perform further processing according to the memory quantity, thereby improving the data transparency and improving the user experience.
In one embodiment of the disclosure, a static callback function is encapsulated in a first object, and the static callback function is used for recycling a second object held by the first object;
the recycling operation is performed on the second object indicated by the pointer, specifically:
and recycling the second object indicated by the inquired pointer through the static callback function.
In the technical scheme of the disclosure, the second object indicated by the queried pointer is recycled through the static callback function. The dependency of the first language on the corresponding callback function can be unbinding, the first object is guaranteed not to be held inside, the target second object is guaranteed to be normally subjected to recovery operation, and the reliability of the recovery operation is improved.
In one embodiment of the present disclosure, the method further comprises the steps of:
acquiring a static callback function encapsulated in a first object;
in the object management table, creating a correspondence between the pointer pointing to the second object and the target virtual reference object may be implemented by:
taking the target virtual reference object as an index value, taking a pointer pointing to the second object and a static callback function as table values corresponding to the index value respectively, and inserting the table values into an object management table;
querying pointers corresponding to the removed virtual reference objects in the object management table comprises the following steps:
taking the removed virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the removed virtual reference object and a corresponding static callback function;
and recycling the second object indicated by the inquired pointer through the static callback function, comprising the following steps:
and recycling the second object indicated by the queried pointer through the queried static callback function.
In one implementation of the present disclosure, in the object management table, a target virtual reference object may be used as an index value, and a pointer pointing to the second object and a static callback function may be respectively used as table values corresponding to the index value, and inserted into the object management table; or, on the premise of acquiring the memory amount occupied by the second object, the target virtual reference object is taken as an index value, and the pointer pointing to the second object, the static callback function and the memory amount occupied by the second object are respectively taken as table values corresponding to the index value and inserted into the object management table.
In one implementation of the present disclosure, the information may be stored in an object management table,
acquiring the memory quantity occupied by the second object;
creating, in the object management table, a correspondence between a pointer to the second object and the target virtual reference object, including:
taking the target virtual reference object as an index value, taking a pointer pointing to the second object and the memory quantity as table values corresponding to the index value respectively, and inserting the table values into an object management table;
at least inquiring the pointer corresponding to the moved virtual reference object in the object management table can be realized by the following steps:
taking the removed virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the removed virtual reference object and a corresponding memory amount;
the method further comprises the following steps:
and sending memory quantity indicating information for indicating the memory quantity corresponding to the moved virtual reference object to the operating system.
In the technical scheme of the disclosure, a static callback function encapsulated in a first object is obtained; taking the target virtual reference object as an index value, taking a pointer pointing to the second object and a static callback function as table values corresponding to the index value respectively, and inserting the table values into an object management table; taking the removed virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the removed virtual reference object and a corresponding static callback function; the queried static callback function is used for recycling the second object indicated by the queried pointer, so that the difficulty of acquiring the static callback function for recycling the second object can be reduced, the cost is reduced, and the user experience is improved.
Fig. 3 shows a block diagram of a resource management device according to an embodiment of the present disclosure. The apparatus may be implemented as part or all of an electronic device by software, hardware, or a combination of both.
As shown in fig. 3, the resource management device 200 includes:
the object creation module 201 is configured to create a target virtual reference object corresponding to a first object when the first object is created, and bind the target virtual reference object with a virtual reference management queue, where the first object is an object written in a first language, and the virtual reference management queue is used for recording the virtual reference object corresponding to the recovered first object;
a relationship creation module 202 configured to create, in the object management table, a correspondence relationship between a pointer to a second object held by the first object and a target virtual reference object, the second object being an object written in a second language;
the monitoring module 203 monitors the virtual reference management queue, and if a virtual reference object enters the queue, the virtual reference object which enters the reference management queue earliest is removed from the virtual reference management queue;
the object reclamation module 204 is configured to query at least a pointer corresponding to the moved virtual reference object in the object management table, and perform reclamation operation on the second object indicated by the queried pointer, so as to release the memory resource occupied by the second object.
In the technical scheme of the disclosure, when a first object is created, a target virtual reference object corresponding to the first object is created, and the target virtual reference object is bound with a virtual reference management queue, wherein the target virtual reference object is used for being recorded by the virtual reference management queue when the first object is recycled, so that the virtual reference management queue can be understood to be used for storing the virtual reference object corresponding to the recycled first object; then, in the object management table, a corresponding relation between a pointer pointing to the second object and the target virtual reference object is created, the virtual reference management queue is monitored, if the virtual reference object in the queue enters, the first object corresponding to the virtual reference object can be considered to be recycled, in this case, the virtual reference object which enters the virtual reference management queue earliest is moved out of the virtual reference management queue, at least the pointer corresponding to the moved virtual reference object is queried in the object management table, and the second object indicated by the queried pointer is recycled, so that memory resources occupied by the second object are released, and the system can recover the second object (namely the recycled first object) corresponding to the virtual reference object stored in the virtual reference management queue more timely under the condition that the first object is recycled, so that the system can not overflow the system memory due to the fact that the second object occupies more system resources, and the normal operation probability of the system is improved, and user experience is improved.
The present disclosure also discloses an electronic device, and fig. 4 shows a block diagram of the electronic device according to an embodiment of the present disclosure. As shown in fig. 4, the electronic device includes a memory and a processor, wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement a method according to an embodiment of the present disclosure.
The embodiment of the disclosure provides a resource management method, which comprises the following steps:
when a first object is created, a target virtual reference object corresponding to the first object is created, and the target virtual reference object is bound with a virtual reference management queue, wherein the first object is an object written in a first language, and the virtual reference management queue is used for recording the virtual reference object corresponding to the recovered first object;
creating a corresponding relation between a pointer pointing to a second object and a target virtual reference object in an object management table, wherein the second object is held by a first object, and the second object is written in a second language;
monitoring a virtual reference management queue, and if a virtual reference object enters the queue, removing the earliest entering virtual reference object in the virtual reference management queue from the virtual reference management queue;
querying at least a pointer corresponding to the moved virtual reference object in the object management table, and recovering the second object indicated by the queried pointer to release the memory resource occupied by the second object.
In one embodiment of the present disclosure, the first language is Java and the second language is C++ or C.
In one embodiment of the present disclosure, removing the earliest incoming virtual reference object in the virtual reference management queue from the virtual reference management queue includes:
and removing the virtual reference object at the head of the virtual reference management queue from the virtual reference management queue.
In one embodiment of the present disclosure, creating, in an object management table, a correspondence of a pointer to a second object and a target virtual reference object includes:
taking the target virtual reference object as an index value, taking a pointer pointing to the second object as a table value corresponding to the index value, and inserting the target virtual reference object into an object management table;
querying pointers corresponding to the removed virtual reference objects in the object management table comprises the following steps:
and taking the shifted virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to acquire a pointer corresponding to the shifted virtual reference object.
In one embodiment of the present disclosure, the method further comprises:
acquiring the memory quantity occupied by the second object;
creating, in the object management table, a correspondence between a pointer to the second object and the target virtual reference object, including:
taking the target virtual reference object as an index value, taking a pointer pointing to the second object and the memory quantity as table values corresponding to the index value respectively, and inserting the table values into an object management table;
querying at least a pointer corresponding to the shifted-out virtual reference object in the object management table, including:
taking the removed virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the removed virtual reference object and a corresponding memory amount;
the method further comprises the steps of:
and sending memory quantity indicating information for indicating the memory quantity corresponding to the moved virtual reference object to the operating system.
In one embodiment of the disclosure, a static callback function is encapsulated in a first object, and the static callback function is used for recycling a second object held by the first object;
the recycling operation is performed on the second object indicated by the pointer, specifically:
and recycling the second object indicated by the inquired pointer through the static callback function.
In one embodiment of the present disclosure, the method further comprises:
acquiring a static callback function encapsulated in a first object;
creating, in the object management table, a correspondence between a pointer to the second object and the target virtual reference object, including:
taking the target virtual reference object as an index value, taking a pointer pointing to the second object and a static callback function as table values corresponding to the index value respectively, and inserting the table values into an object management table;
querying pointers corresponding to the removed virtual reference objects in the object management table comprises the following steps:
taking the removed virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the removed virtual reference object and a corresponding static callback function;
and recycling the second object indicated by the inquired pointer through the static callback function, comprising the following steps:
and recycling the second object indicated by the queried pointer through the queried static callback function.
Fig. 5 shows a schematic diagram of a computer system suitable for use in implementing methods according to embodiments of the present disclosure.
As shown in fig. 5, the computer system includes a processing unit that can execute the various methods in the above embodiments according to a program stored in a Read Only Memory (ROM) or a program loaded from a storage section into a Random Access Memory (RAM). In the RAM, various programs and data required for the operation of the computer system are also stored. The processing unit, ROM and RAM are connected to each other by a bus. An input/output (I/O) interface is also connected to the bus.
The following components are connected to the I/O interface: an input section including a keyboard, a mouse, etc.; an output section including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage section including a hard disk or the like; and a communication section including a network interface card such as a LAN card, a modem, and the like. The communication section performs a communication process via a network such as the internet. The drives are also connected to the I/O interfaces as needed. Removable media such as magnetic disks, optical disks, magneto-optical disks, semiconductor memories, and the like are mounted on the drive as needed so that a computer program read therefrom is mounted into the storage section as needed. The processing unit may be implemented as a processing unit such as CPU, GPU, TPU, FPGA, NPU.
In particular, according to embodiments of the present disclosure, the methods described above may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the method described above. In such embodiments, the computer program may be downloaded and installed from a network via a communication portion, and/or installed from a removable medium.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules referred to in the embodiments of the present disclosure may be implemented in software or in programmable hardware. The units or modules described may also be provided in a processor, the names of which in some cases do not constitute a limitation of the unit or module itself.
As another aspect, the present disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or the computer system in the above-described embodiments; or may be a computer-readable storage medium, alone, that is not assembled into a device. The computer-readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present disclosure.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention referred to in this disclosure is not limited to the specific combination of features described above, but encompasses other embodiments in which any combination of features described above or their equivalents is contemplated without departing from the inventive concepts described. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).

Claims (10)

1. A resource management method, comprising:
when a first object is created, a target virtual reference object corresponding to the first object is created, the target virtual reference object is bound with a virtual reference management queue, the first object is written in a first language, and the virtual reference management queue is used for recording the virtual reference object corresponding to the recovered first object;
creating a corresponding relation between a pointer pointing to a second object and the target virtual reference object in an object management table, wherein the second object is held by the first object, and the second object is written in a second language;
monitoring the virtual reference management queue, and if a virtual reference object enters the queue, removing the earliest entering virtual reference object from the virtual reference management queue;
querying at least a pointer corresponding to the moved virtual reference object in the object management table, and recovering a second object indicated by the queried pointer to release memory resources occupied by the second object.
2. The resource management method of claim 1, wherein the first language is Java language and the second language is c++ or C language.
3. The resource management method of claim 1 wherein said dequeuing the earliest entering virtual reference object in the virtual reference management queue from the virtual reference management queue comprises:
and removing the virtual reference object at the head of the virtual reference management queue from the virtual reference management queue.
4. A resource management method as claimed in any one of claims 1 to 3 wherein said creating a correspondence of a pointer to a second object and said target virtual reference object in an object management table comprises:
taking the target virtual reference object as an index value, taking the pointer pointing to the second object as a table value corresponding to the index value, and inserting the pointer into an object management table;
the searching the pointer corresponding to the moved virtual reference object in the object management table comprises the following steps:
and taking the shifted-out virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to acquire a pointer corresponding to the shifted-out virtual reference object.
5. A resource management method as claimed in any one of claims 1 to 3 wherein the method further comprises:
acquiring the memory amount occupied by the second object;
the creating, in the object management table, a correspondence between a pointer pointing to the second object and the target virtual reference object includes:
taking the target virtual reference object as an index value, taking the pointer pointing to the second object and the memory quantity as table values corresponding to the index value respectively, and inserting the table values into an object management table;
at least the searching the pointer corresponding to the shifted virtual reference object in the object management table includes:
taking the shifted-out virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the shifted-out virtual reference object and a corresponding memory amount;
the method further comprises the steps of:
and sending memory quantity indicating information for indicating the memory quantity corresponding to the moved virtual reference object to an operating system.
6. The resource management method of any of claims 1-3, wherein a static callback function is encapsulated in the first object, the static callback function being used to recycle a second object held by the first object;
and recycling the second object indicated by the pointer, specifically:
and recycling the second object indicated by the inquired pointer through the static callback function.
7. The resource management method of claim 6, wherein the method further comprises:
acquiring a static callback function encapsulated in the first object;
creating a correspondence between a pointer pointing to a second object and the target virtual reference object in an object management table, including:
taking the target virtual reference object as an index value, taking the pointer pointing to the second object and the static callback function as table values corresponding to the index value respectively, and inserting the table values into an object management table;
the searching the pointer corresponding to the moved virtual reference object in the object management table comprises the following steps:
taking the shifted virtual reference object as an index value, and inquiring a table value corresponding to the index value in an object management table to obtain a pointer corresponding to the shifted virtual reference object and a corresponding static callback function;
the recovering operation of the second object indicated by the queried pointer through the static callback function comprises the following steps:
and recycling the second object indicated by the queried pointer through the queried static callback function.
8. A resource management device, comprising:
the object creation module is configured to create a target virtual reference object corresponding to a first object when the first object is created, and bind the target virtual reference object with a virtual reference management queue, wherein the first object is an object written in a first language, and the virtual reference management queue is used for recording the virtual reference object corresponding to the recovered first object;
a relationship creation module configured to create, in an object management table, a correspondence relationship between a pointer to a second object held by the first object and the target virtual reference object, the second object being an object written in a second language;
the monitoring module monitors the virtual reference management queue, and if a virtual reference object enters the virtual reference management queue, the virtual reference object which enters the virtual reference management queue earliest is removed from the virtual reference management queue;
and the object recycling module is configured to at least inquire pointers corresponding to the moved virtual reference objects in the object management table, and recycle the second objects indicated by the inquired pointers so as to release memory resources occupied by the second objects.
9. An electronic device includes a memory and a processor; wherein the memory is for storing one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps of any of claims 1-7.
10. A computer program product comprising computer programs/instructions which, when executed by a processor, implement the method steps of any of claims 1-7.
CN202310115834.6A 2023-02-08 2023-02-08 Resource management method, device, equipment and product Pending CN116010105A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310115834.6A CN116010105A (en) 2023-02-08 2023-02-08 Resource management method, device, equipment and product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310115834.6A CN116010105A (en) 2023-02-08 2023-02-08 Resource management method, device, equipment and product

Publications (1)

Publication Number Publication Date
CN116010105A true CN116010105A (en) 2023-04-25

Family

ID=86026916

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310115834.6A Pending CN116010105A (en) 2023-02-08 2023-02-08 Resource management method, device, equipment and product

Country Status (1)

Country Link
CN (1) CN116010105A (en)

Similar Documents

Publication Publication Date Title
US20060253498A1 (en) Method and apparatus for reclaiming memory from a heap
US7565645B2 (en) Method and apparatus for marking code for data versioning
CN111258921A (en) Method and device for recycling garbage memory, electronic equipment and storage medium
CN111273968A (en) Object calling method, device, equipment and medium
CN110825694A (en) Data processing method, device, equipment and storage medium
CN111954072A (en) Multimedia playing method, device, multimedia player and medium
US20060161598A1 (en) Method and apparatus for data versioning and recovery using delta content save and restore management
CN112115105A (en) Service processing method, device and equipment
GB2497172A (en) Reserving space on a storage device for new data based on predicted changes in access frequencies of storage devices
JP2000155719A (en) Backup and restoration system for data and asynchronous data managing method
CN110716804A (en) Method and device for automatically deleting useless resources, storage medium and electronic equipment
CN116881051B (en) Data backup and recovery method and device, electronic equipment and storage medium
CN111858393B (en) Memory page management method, memory page management device, medium and electronic equipment
CN111291006B (en) Data recovery processing method, device and equipment and readable storage medium
CN116010105A (en) Resource management method, device, equipment and product
CN110727565B (en) Network equipment platform information collection method and system
GB2506614A (en) Extracting core data for a summary dump file based upon most recent trace data entries
CN113568581B (en) Multi-application resource recovery method and system for embedded equipment
CN115964192A (en) Request processing method and device, electronic equipment and storage medium
CN111405015B (en) Data processing method, device, equipment and storage medium
US7769976B2 (en) Identifying code that wastes virtual memory
CN114238391A (en) Data paging query method and device, electronic equipment and storage medium
CN112817522A (en) Data storage method and device, electronic equipment and storage medium
CN106547589A (en) A kind of upgrade-system and upgrade method
CN112148279A (en) Log information processing method and device, electronic equipment and storage medium

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