CN109144902A - The application application method and device of memory - Google Patents

The application application method and device of memory Download PDF

Info

Publication number
CN109144902A
CN109144902A CN201810750692.XA CN201810750692A CN109144902A CN 109144902 A CN109144902 A CN 109144902A CN 201810750692 A CN201810750692 A CN 201810750692A CN 109144902 A CN109144902 A CN 109144902A
Authority
CN
China
Prior art keywords
memory
resource
resource pool
sent
information
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
CN201810750692.XA
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.)
Beijing Jiaxun Feihong Electrical Co Ltd
Original Assignee
Beijing Jiaxun Feihong Electrical 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 Beijing Jiaxun Feihong Electrical Co Ltd filed Critical Beijing Jiaxun Feihong Electrical Co Ltd
Priority to CN201810750692.XA priority Critical patent/CN109144902A/en
Publication of CN109144902A publication Critical patent/CN109144902A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/14Protection against unauthorised use of memory or access to memory
    • G06F12/1416Protection against unauthorised use of memory or access to memory by checking the object accessibility, e.g. type of access defined by the memory independently of subject rights
    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Memory System (AREA)

Abstract

The present invention provides the application application methods and device of a kind of memory, utilize the interaction of mission thread and resource pool, realize thread to the calling of memory, it can recycle after memory release and utilize again immediately, resource utilization is improved, and eliminates Memory Leaks caused by reference count circular reference.Memory is accessed by ID, eliminating wild pointer use may.Facilitate statistics memory usage, means can be provided for optimization application.

Description

The application application method and device of memory
Technical field
The present invention relates to resource management techniques fields, in particular to the application application method and device of a kind of memory.
Background technique
It is general to the use of resource that resource is used by the way of reference count, garbage reclamation at present in multi-thread programming.
For example intelligent pointer is introduced in C++, in establishing out interior, there are which to discharge ratio without being entangled with again by programmer Appropriate this problem.For example when a resource is shared by multiple threads, programmer needs the life cycle in all modules At the end of all, by the last one without using the release behavior of the thread triggering pointer of the pointer.
However everything all will not be perfect, intelligent pointer still haves the defects that certain:
It (1), can bring memory overflow when intelligent pointer based on reference count when circular reference occurs.
(2) resource release needs to discharge until reference count is 0, and resource utilization is low.
(3) increase program complexity, position fixing process is complicated when Memory Leaks occur.
Summary of the invention
For above-mentioned problems of the prior art, the present invention provides a kind of application application methods of memory.
In a first aspect, it is applied to mission thread the embodiment of the invention provides a kind of application application method of memory, it is described Method includes:
Resource bid request is sent to resource pool, to trigger resource pool storage allocation;
The memory information that the resource pool is sent is received, the memory information includes at least memory mark and memory address;
Resource, which is sent, to the resource pool uses request, it is whether effective to trigger the resource pool detection memory;
If effectively, receiving the resource effective information that the resource pool is sent, and use memory.
Further, if effectively, receiving the resource effective information that the resource pool is sent, and after use memory, institute State method further include:
Release resource request is sent to the resource pool, to trigger the resource pool release resource.
Further, if the memory is invalid, the resource inefficiencies information that the resource pool is sent is received, and again to institute State resource pool request memory.
Second aspect, the embodiment of the invention provides a kind of application application methods of memory, are applied to resource pool, the side Method includes:
The resource bid request that the mission thread is sent is received, to the mission thread storage allocation and sends memory letter Breath, the memory information include at least memory mark and memory address;
It receives the resource that the mission thread is sent and uses request, whether effective detect the memory;
If effectively, sending resource effective information to mission thread, the memory is used to trigger the mission thread.
Further, if effectively, sending resource effective information to mission thread, institute is used to trigger the mission thread After stating memory, the method also includes:
The resource release request that the mission thread is sent is received, discharges the memory, and send to the mission thread Discharge successful information.
The third aspect, the embodiment of the invention provides a kind of application use devices of memory, are applied to mission thread, described Device includes:
Apply for module, for sending resource bid request to resource pool, to trigger resource pool storage allocation;
Receiving module, the memory information sent for receiving the resource pool, the memory information include at least memory mark Knowledge and memory address;
Detection module is detected in described for sending resource using request to the resource pool with triggering the resource pool Whether effectively to deposit;
Using module, if receiving the resource effective information that the resource pool is sent, and use memory for effectively.
Further, described device further include:
Release module, for sending release resource request to the resource pool, to trigger the resource pool release resource.
Further, described device further include:
Request module again receives the resource inefficiencies information that the resource pool is sent if invalid for the memory, and Memory is requested to the resource pool again.
Fourth aspect, the embodiment of the invention provides a kind of application use devices of memory, are applied to resource pool, the dress It sets and includes:
Apply for request receiving module, the resource bid request sent for receiving the mission thread, to the task line Journey storage allocation simultaneously sends memory information, and the memory information includes at least memory mark and memory address;
Using request receiving module, request is used for receiving the resource that the mission thread is sent, detects the memory Whether effectively;
Effective information sending module, if sending resource effective information to mission thread for effectively, to trigger described appoint Business thread uses the memory.
5th aspect, the embodiment of the invention provides a kind of computer storage medium, for being stored as the third aspect and the Computer software instructions used in device described in four aspects.
The embodiment of the present invention bring it is following the utility model has the advantages that
The embodiment of the invention provides the application application method and device of a kind of memory, mission thread and resource pool are utilized Interaction realizes that thread to the calling of memory, can recycle immediately after memory release and utilize again, improve resource utilization, And eliminate Memory Leaks caused by reference count circular reference.Memory is accessed by ID, eliminates wild pointer use It may.Facilitate statistics memory usage, means can be provided for optimization application.
Other features and advantages of the present invention will illustrate in the following description, also, partly become from specification It obtains it is clear that understand through the implementation of the invention.The purpose of the present invention and other advantages in specification, claim Specifically noted structure is achieved and obtained in book and attached drawing.
To enable the above objects, features and advantages of the present invention to be clearer and more comprehensible, preferred embodiment is cited below particularly, and cooperate Appended attached drawing, is described in detail below.
Detailed description of the invention
It, below will be to specific in order to illustrate more clearly of the specific embodiment of the invention or technical solution in the prior art Embodiment or attached drawing needed to be used in the description of the prior art be briefly described, it should be apparent that, it is described below Attached drawing is some embodiments of the present invention, for those of ordinary skill in the art, before not making the creative labor It puts, is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of flow chart of the application application method of memory provided by first embodiment of the invention;
Fig. 2 is a kind of flow chart of the application application method of memory provided by second embodiment of the invention;
Fig. 3 is a kind of structural block diagram of the application use device of memory provided by third embodiment of the invention;
Fig. 4 is a kind of structural block diagram of the application use device of memory provided by fourth embodiment of the invention.
Specific embodiment
To keep destination, technical solution and the advantage of the embodiment of the present invention clearer, below in conjunction with attached drawing to this hair Bright technical solution is clearly and completely described, it is clear that and described embodiments are some of the embodiments of the present invention, without It is whole embodiments.The component of embodiments of the present invention, which are generally described and illustrated herein in the accompanying drawings can be with a variety of different Configuration is to arrange and design.Therefore, below the detailed description of the embodiment of the present invention provided in the accompanying drawings is not intended to limit The range of claimed invention processed, but it is merely representative of selected embodiment of the invention.Based on the embodiments of the present invention, Every other embodiment obtained by those of ordinary skill in the art without making creative efforts, belongs to this hair The range of bright protection.
Currently, mission thread needs to apply from resource pool that during processing task, using memory, the present invention is main Introduce the method that mission thread and resource pool are used interchangeably memory.
Embodiment one
A kind of flow chart of the application application method of memory shown in Figure 1, this method are applied to mission thread, task Thread includes task distribution thread and task processing thread, is specifically comprised the following steps:
S101. resource bid request is sent to resource pool, to trigger resource pool storage allocation;
Specifically, task distribution thread receives user's request, to resource pool application memory.
S102. the memory information that the resource pool is sent is received, the memory information includes at least memory mark and memory Address;
Wherein, memory mark can be 64 shaping ID, and the ID is only effective in this resource life cycle.ID is by 64 The incremental shaping in position guarantees that the ID is not repeated within the software cycle of operation.
Such as it is the memory that 100 addresses are 0x12340000 that resource pool, which returns to ID to task distribution thread,.Task distributes line Journey is located at the task of memory ID100 to task processing thread issues.
S103. resource is sent using request to the resource pool, detect whether the memory has to trigger the resource pool Effect;
Specifically, it when task processing thread uses resource, needs to obtain memory address from resource pool by ID100.
If effectively, thening follow the steps S104.
S104. the resource effective information that the resource pool is sent is received, and uses memory.
For example, resource pool returns to the memory address 0x12340000 of ID100 to task processing thread.Task handles thread pair Task is handled.
After the completion of use, task handles thread and sends release resource request to the resource pool, to trigger the resource pool Discharge resource.
If the memory is invalid, S105 is thened follow the steps.
S105. the resource inefficiencies information that the resource pool is sent is received, and requests memory to the resource pool again.
Embodiment two
A kind of flow chart of the application application method of memory shown in Figure 2, this method is applied to resource pool, specific to wrap Include following steps:
S201. the resource bid request that the mission thread is sent is received, to the mission thread storage allocation and is sent Memory information, the memory information include at least memory mark and memory address;
S202. it receives the resource that the mission thread is sent and uses request, whether effective detect the memory;
If effectively, thening follow the steps S203
S203. resource effective information is sent to mission thread, uses the memory to trigger the mission thread.
The resource release request that the mission thread is sent is received, discharges the memory, and send to the mission thread Discharge successful information.
If thening follow the steps S204 in vain.
S204. resource inefficiencies information is sent to the mission thread.
Embodiment three
For the application application method of memory provided by previous embodiment, the embodiment of the invention provides a kind of memories Apply for use device, referring to a kind of structural block diagram of the application use device of Fig. 3 memory shown, which is applied to task line Journey, including following part:
Apply for module 31, for sending resource bid request to resource pool, to trigger resource pool storage allocation;
Receiving module 32, the memory information sent for receiving the resource pool, the memory information include at least memory Mark and memory address;
Detection module 33, for sending resource using request, to trigger described in the resource pool detection to the resource pool Whether memory is effective;
Using module 34, if receiving the resource effective information that the resource pool is sent, and use memory for effectively.
Further, described device further include:
Release module 35, for sending release resource request to the resource pool, to trigger the resource pool release resource.
Further, described device further include:
Request module 36 again receive the resource inefficiencies information that the resource pool is sent if invalid for the memory, And memory is requested to the resource pool again.
Example IV
For the application application method of memory provided by previous embodiment, the embodiment of the invention provides a kind of memories Apply for use device, a kind of structural block diagram of the application use device of the memory shown referring to fig. 4, which is applied to resource pool, Including following part:
Apply for request receiving module 41, the resource bid request sent for receiving the mission thread, to the task Thread storage allocation simultaneously sends memory information, and the memory information includes at least memory mark and memory address;
Using request receiving module 42, request is used for receiving the resource that the mission thread is sent, is detected in described Whether effectively to deposit;
Effective information sending module 43, if resource effective information is sent to mission thread, described in triggering for effectively Mission thread uses the memory.
The embodiment of the invention also provides a kind of computer storage mediums, for being stored as device provided by the above embodiment Computer software instructions used.
In addition, in the description of the embodiment of the present invention unless specifically defined or limited otherwise, term " installation ", " phase Even ", " connection " shall be understood in a broad sense, for example, it may be being fixedly connected, may be a detachable connection, or be integrally connected;It can To be mechanical connection, it is also possible to be electrically connected;It can be directly connected, can also can be indirectly connected through an intermediary Connection inside two elements.For the ordinary skill in the art, above-mentioned term can be understood at this with concrete condition Concrete meaning in invention.
In the description of the present invention, it should be noted that term " center ", "upper", "lower", "left", "right", "vertical", The orientation or positional relationship of the instructions such as "horizontal", "inner", "outside" be based on the orientation or positional relationship shown in the drawings, merely to Convenient for description the present invention and simplify description, rather than the device or element of indication or suggestion meaning must have a particular orientation, It is constructed and operated in a specific orientation, therefore is not considered as limiting the invention.
In addition, term " first ", " second ", " third " are used for description purposes only, it is not understood to indicate or imply phase To importance.
It should be noted that in embodiment provided by the present invention, it should be understood that disclosed system and method, it can To realize by another way.The apparatus embodiments described above are merely exemplary, for example, the unit is drawn Point, only a kind of logical function partition, there may be another division manner in actual implementation, in another example, multiple units or group Part can be combined or can be integrated into another system, or some features can be ignored or not executed.It is described to be used as separation unit The unit that part illustrates may or may not be physically separated, and component shown as a unit can be or can also Not to be physical unit, it can it is in one place, or may be distributed over multiple network units.It can be according to reality Needs some or all of the units may be selected to achieve the purpose of the solution of this embodiment ground.
In addition, each functional unit in embodiment provided by the invention can integrate in one processing unit, it can also To be that each unit physically exists alone, can also be integrated in one unit with two or more units.
It, can be with if the function is realized in the form of SFU software functional unit and when sold or used as an independent product It is stored in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially in other words The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention. And storage medium above-mentioned includes: that USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic or disk.
Block diagram in attached drawing shows the system of multiple embodiments according to the present invention and the possibility of computer program product The architecture, function and operation of realization.In this regard, each box in block diagram can represent a module, program segment or A part of code, a part of the module, section or code include one or more for realizing defined logic function The executable instruction of energy.It should also be noted that in some implementations as replacements, function marked in the box can also be with not It is same as the sequence marked in attached drawing generation.For example, two continuous boxes can actually be basically executed in parallel, they have When can also execute in the opposite order, this depends on the function involved.It is also noted that each box in block diagram, And the combination of the box in block diagram, it can be with the defined function of execution or the dedicated hardware based system of movement come real It is existing, or can realize using a combination of dedicated hardware and computer instructions.
In addition, term " first ", " second ", " third " are used for description purposes only, it is not understood to indicate or imply phase To importance.
Unless specifically stated otherwise, the opposite numerical expression and numerical value of the component otherwise illustrated in these embodiments are simultaneously It does not limit the scope of the invention.
In all examples being illustrated and described herein, any occurrence should be construed as merely illustratively, without It is as limitation, therefore, other examples of exemplary embodiment can have different values.
Finally, it should be noted that embodiment described above, only a specific embodiment of the invention, to illustrate the present invention Technical solution, rather than its limitations, scope of protection of the present invention is not limited thereto, although with reference to the foregoing embodiments to this hair It is bright to be described in detail, those skilled in the art should understand that: anyone skilled in the art In the technical scope disclosed by the present invention, it can still modify to technical solution documented by previous embodiment or can be light It is readily conceivable that variation or equivalent replacement of some of the technical features;And these modifications, variation or replacement, do not make The essence of corresponding technical solution is detached from the spirit and scope of technical solution of the embodiment of the present invention, should all cover in protection of the invention Within the scope of.Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. a kind of application application method of memory, which is characterized in that be applied to mission thread, which comprises
Resource bid request is sent to resource pool, to trigger resource pool storage allocation;
The memory information that the resource pool is sent is received, the memory information includes at least memory mark and memory address;
Resource, which is sent, to the resource pool uses request, it is whether effective to trigger the resource pool detection memory;
If effectively, receiving the resource effective information that the resource pool is sent, and use memory.
2. the method according to claim 1, wherein if effectively, receiving the resource that the resource pool is sent has Information is imitated, and after use memory, the method also includes:
Release resource request is sent to the resource pool, to trigger the resource pool release resource.
3. the method according to claim 1, wherein the method also includes:
If the memory is invalid, the resource inefficiencies information that the resource pool is sent is received, and request again to the resource pool Memory.
4. a kind of application application method of memory, which is characterized in that be applied to resource pool, which comprises
The resource bid request that the mission thread is sent is received, to the mission thread storage allocation and sends memory information, The memory information includes at least memory mark and memory address;
It receives the resource that the mission thread is sent and uses request, whether effective detect the memory;
If effectively, sending resource effective information to mission thread, the memory is used to trigger the mission thread.
5. according to the method described in claim 4, it is characterized in that, if effectively, to mission thread send resource effective information, To trigger the mission thread using after the memory, the method also includes:
The resource release request that the mission thread is sent is received, discharges the memory, and send and discharge to the mission thread Successful information.
6. a kind of application use device of memory, which is characterized in that be applied to mission thread, described device includes:
Apply for module, for sending resource bid request to resource pool, to trigger resource pool storage allocation;
Receiving module, the memory information sent for receiving the resource pool, the memory information include at least memory mark and Memory address;
Detection module uses request for sending resource to the resource pool, is to trigger the resource pool detection memory It is no effective;
Using module, if receiving the resource effective information that the resource pool is sent, and use memory for effectively.
7. device according to claim 6, which is characterized in that described device further include:
Release module, for sending release resource request to the resource pool, to trigger the resource pool release resource.
8. device according to claim 6, which is characterized in that described device further include:
Request module again receives the resource inefficiencies information that the resource pool is sent, and again if invalid for the memory Memory is requested to the resource pool.
9. a kind of application use device of memory, which is characterized in that be applied to resource pool, described device includes:
Apply for request receiving module, the resource bid request sent for receiving the mission thread, to the mission thread point With memory and memory information is sent, the memory information includes at least memory mark and memory address;
Using request receiving module, request is used for receiving the resource that the mission thread is sent, whether detects the memory Effectively;
Effective information sending module, if resource effective information is sent to mission thread, for effectively to trigger the task line Journey uses the memory.
10. a kind of computer storage medium, which is characterized in that for being stored as device described in claim 6 to 9 any one Computer software instructions used.
CN201810750692.XA 2018-07-10 2018-07-10 The application application method and device of memory Pending CN109144902A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810750692.XA CN109144902A (en) 2018-07-10 2018-07-10 The application application method and device of memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810750692.XA CN109144902A (en) 2018-07-10 2018-07-10 The application application method and device of memory

Publications (1)

Publication Number Publication Date
CN109144902A true CN109144902A (en) 2019-01-04

Family

ID=64800269

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810750692.XA Pending CN109144902A (en) 2018-07-10 2018-07-10 The application application method and device of memory

Country Status (1)

Country Link
CN (1) CN109144902A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101178669A (en) * 2007-12-13 2008-05-14 华为技术有限公司 Resource recovery method and apparatus
CN102156631A (en) * 2011-04-27 2011-08-17 Tcl集团股份有限公司 Method and system for managing indicator in programming language
CN107515785A (en) * 2016-06-16 2017-12-26 大唐移动通信设备有限公司 A kind of EMS memory management process and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101178669A (en) * 2007-12-13 2008-05-14 华为技术有限公司 Resource recovery method and apparatus
CN102156631A (en) * 2011-04-27 2011-08-17 Tcl集团股份有限公司 Method and system for managing indicator in programming language
CN107515785A (en) * 2016-06-16 2017-12-26 大唐移动通信设备有限公司 A kind of EMS memory management process and device

Similar Documents

Publication Publication Date Title
CN102541640B (en) Cluster GPU (graphic processing unit) resource scheduling system and method
CN105912403B (en) The method for managing resource and device of Docker container
CN107301093B (en) Method and device for managing resources
CN107526645B (en) A kind of communication optimization method and system
CN102821164B (en) Efficient parallel-distribution type data processing system
CN106095589B (en) A kind of method, apparatus and system for distributing subregion
CN106502918B (en) A kind of scheduling memory method and device
CN103207774A (en) Method And System For Resolving Thread Divergences
CN110109756A (en) A kind of network target range construction method, system and storage medium
CN111722928A (en) Resource scheduling method and device, electronic equipment and storage medium
CN113284038B (en) Method, computing device, computing system, and storage medium for performing computations
CN104375838A (en) OpenMP-based astronomy software Gridding optimization method
CN103902353A (en) Virtual machine deployment method and device
CN105210324B (en) Strategy and charging rule functions virtual method, apparatus and system
CN107832151A (en) A kind of cpu resource distribution method, device and equipment
CN112114984A (en) Graph data processing method and device
CN110086643A (en) A kind of Risk Identification Method, terminal and storage medium
CN104536773B (en) Embedded software dynamic memory recovery method based on internal memory scanning
CN104346404A (en) Method, equipment and system for accessing data
CN105335135B (en) Data processing method and central node
CN102209016A (en) Data processing method, device and data processing system
CN109144902A (en) The application application method and device of memory
CN104050189B (en) The page shares processing method and processing device
CN107168800A (en) A kind of memory allocation method and device
CN104424123B (en) One kind is without lock data buffer zone and its application method

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