CN108228331A - A kind of method for managing resource and system - Google Patents

A kind of method for managing resource and system Download PDF

Info

Publication number
CN108228331A
CN108228331A CN201611128750.2A CN201611128750A CN108228331A CN 108228331 A CN108228331 A CN 108228331A CN 201611128750 A CN201611128750 A CN 201611128750A CN 108228331 A CN108228331 A CN 108228331A
Authority
CN
China
Prior art keywords
resource
module
association
memory
primary module
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.)
Granted
Application number
CN201611128750.2A
Other languages
Chinese (zh)
Other versions
CN108228331B (en
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.)
Shanxi Kehua Yongxing Software Application Service 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 CN201611128750.2A priority Critical patent/CN108228331B/en
Publication of CN108228331A publication Critical patent/CN108228331A/en
Application granted granted Critical
Publication of CN108228331B publication Critical patent/CN108228331B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/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
    • 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/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Storage Device Security (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses the management method and system of a kind of resource, this method includes:Setting primary module is associated with the first of resource, is enable the primary module based on resource described in first associated access and is discharged the memory of the resource occupation;According to the described first association, the second association of setting;Described second association is passed at least one from module, enable described to be based on resource described in second associated access from module.The present invention provides the management method and system of resource, solves uncertain and the technical issues of can not effectively managing resource that resource present in resource allocation method in the prior art discharges, it can realize and resource is effectively managed, and realize the technique effect effectively managed to memory.

Description

A kind of method for managing resource and system
Technical field
The present invention relates to field of computer technology more particularly to a kind of method for managing resource and systems.
Background technology
With the development of computer technology, the transmission and utilization of resource have also obtained larger development, the money that people obtain Source is also varied, and above-mentioned resource includes video information, audio-frequency information or pictorial information etc., how resource is managed into For critical issue.
The prior art use method be to allow between multiple modules and resource establish a kind of association, and pair with resource establish close The module of connection is counted, and module above-mentioned in this way can share resource by the association of foundation, including reading and discharging, When resource failed, the module being each associated with the resource is associated release operation, i.e., is established with resource associated When module count is 0, the memory of resource occupation is released.
However in the above method, when the memory to resource occupation discharges, need each to be associated with the resource Module be all associated release operation, but the time that modules are associated release operation is uncertain, also can not Which module determine last execution association release operation is, resource can be caused to discharge so uncertain, and can not be effective Ground is managed resource.As it can be seen that there are limitations for method for managing resource in the prior art.
Invention content
The present invention provides a kind of method for managing resource and system, to solve to provide present in resource allocation method in the prior art The uncertainty of source release and the technical issues of can not effectively managing resource.
In a first aspect, an embodiment of the present invention provides a kind of management method of resource, including:Primary module and resource are set First association enables the primary module based on resource described in first associated access and discharges the memory of the resource occupation; According to the described first association, the second association of setting;Described second association is passed at least one from module, made described from module It can be based on resource described in second associated access.
Optionally, it before the setting primary module is associated with the first of resource, further includes:Obtain the resource;By institute It states resource and is sent to the primary module.
Optionally, the setting primary module is associated with the first of resource, and the primary module is enable to be based on the described first association It accesses the resource and discharges the memory of the resource occupation, including:Judge whether the resource fails;If failure, is looked into See whether the resource is accessed;If the resource is not accessed, the memory of the resource occupation is discharged.
Optionally, it after the memory of the release resource occupation, further includes:Release first association.
Optionally, it is described described second association is passed to it is at least one from module, enable it is described be based on from module it is described Resource described in second associated access, including:Based on the described second association, judge whether first association is released from;If not It is released from, then accesses the resource.
Based on same inventive concept, an embodiment of the present invention provides a kind of resource management system, including:First setting mould Block for primary module to be set to be associated with the first of resource, enables the primary module to be based on resource described in first associated access With the memory for discharging the resource occupation;Second setup module, for according to the described first association, the second association of setting;It transmits Module, the described second association is passed at least one from module, enables described to be based on the second associated access institute from module State resource.
Optionally, the system also includes:First acquisition module, for obtaining the resource;Sending module, for by institute It states resource and is sent to the primary module.
Optionally, first setup module includes:First judging unit, for judging whether the resource fails;It looks into It sees unit, if for the resource failed, checks whether the resource is accessed;Releasing unit, if for the money Source is not accessed, then discharges the memory of the resource occupation.
Optionally, first setup module, further includes:Lifting unit releases first association.
Optionally, the transfer module includes:Second judgment unit, for according to the described second association, judging described the Whether one association is released from;Access unit for working as whether first association is released from, then accesses the resource.
The technical solution provided in the embodiment of the present invention, has at least the following technical effects or advantages:
In the technical solution of the embodiment of the present invention, by the way that primary module is set to be associated with the first of resource so that the master Module can be based on resource described in first associated access or the release resource occupation memory;And it is closed according to described first Connection, then the second association of setting passes to the described second association at least one from module, make described to be based on described the from module Resource described in two associated access.Due in the above-mentioned technical solutions, being obtained since primary module is associated with by first to resource It accesses and release permission, the second association based on the first association setting transmitted from module by receiving primary module has to money The access rights in source, but without the permission that discharge to resource in the management to resource, specify primary module and from module pair The administration authority of resource, primary module and can access resource from module, and only primary module can discharge resource, so It, can be effective to the carry out of resource relative to for the prior art, the uncertainty of resource management is reduced in the present invention Management, so as to fulfill effective management to memory.
Above description is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention, And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects of the present invention, feature and advantage can It is clearer and more comprehensible, below the special specific embodiment for lifting the present invention.
Description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is this hair Some bright embodiments, for those of ordinary skill in the art, without creative efforts, can be with root Other attached drawings are obtained according to these attached drawings.
Fig. 1 is the schematic diagram for managing object by the way of pointer in the prior art;
Fig. 2 is the schematic diagram for managing object in the embodiment of the present invention using the pointer mode of pointer;
Fig. 3 is the schematic diagram for deleting object in the embodiment of the present invention using the pointer mode of pointer;
A kind of flow chart of the management method of resource in Fig. 4 embodiment of the present invention;
The logical construction schematic diagram of the management system of a kind of resource in Fig. 5 embodiment of the present invention.
Specific embodiment
The embodiment of the present invention solves resource allocation method in the prior art by providing the management method and system of a kind of resource Present in resource release uncertainty and the technical issues of can not effectively manage resource, can realize resource is carried out it is effective Management, and realize the technique effect effectively managed to memory.
Technical solution in the embodiment of the present invention, general thought are as follows:Setting primary module first is associated with the first of resource, Allow the primary module based on resource described in first associated access or discharge the first resource of the resource occupation;And According to the described first association, the second association of setting, then the described second association is passed to it is at least one from module, make it is described from Module is based on resource described in second associated access.
In the above method, since primary module obtains the access to resource by the first association and discharges permission, from module The second association based on the first association setting transmitted by receiving primary module, has the access rights to resource, but do not have To the permission of resource release, in the management to resource, primary module and the administration authority from module to resource, primary module are specified Can access resource with from module, only primary module can discharge resource, so relative to in the prior art, institute There is module all to have access and release permission to resource, and all modules is needed all to discharge resource to release the memory of resource For putting, administration authority of each module to resource is specified in the present invention, reduces the uncertainty of resource release, it can be to money Source is effectively managed, so as to fulfill the effective management of row is internally deposited into.
Purpose, technical scheme and advantage to make the embodiment of the present invention are clearer, below in conjunction with the embodiment of the present invention In attached drawing, the technical solution in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is Part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art All other embodiments obtained without creative efforts shall fall within the protection scope of the present invention.
Embodiment one
A kind of management method of resource is present embodiments provided, is please referred to Fig.4, the method includes:
S101:Setting primary module is associated with the first of resource, and the primary module is enable to be based on the first associated access institute It states resource and discharges the memory of the resource occupation;
S102:According to the described first association, the second association of setting;
S103:Described second association is passed at least one from module, enable described to be based on described second from module and close Connection accesses the resource.
In the following, a kind of specific implementation step of method for managing resource provided in an embodiment of the present invention is discussed in detail with reference to Fig. 4:
First, step S101 is performed, setting primary module be associated with the first of resource, enables the primary module based on described the Resource described in one associated access and the memory for discharging the resource occupation.
In embodiments of the present invention, above-mentioned resource can with audio resource, video resource, picture resource, literal resource etc., In, the first association refers to a kind of correspondence between primary module and resource so that primary module can be associated with by above-mentioned first, It accesses and discharges to resource, wherein representing the reading to resource to the access of resource, the release of resource is represented to resource Deletion.
Then, step S102 is performed, according to the described first association, the second association of setting.
In embodiments of the present invention, on the basis of first is associated, the second association of setting, i.e. another correspond to of setting is closed System, and it is related to the first association.
Then, step S103 is performed, the described second association is passed at least one from module, makes described to be based on from module Resource described in second associated access.
In embodiments of the present invention, the second association of foundation can pass to multiple from module, multiple in this way from module base Access resource in the second association, and it is each be independent of each other from module to the access of resource, and based on the second association, from module What is obtained is only the access rights of resource.
In order to illustrate more clearly of a kind of method of resource management of the present invention, with reference to Fig. 1-Fig. 3 to specific real Now it is explained.
The mode of pointer is usually used to realize in management of the prior art to resource, and pointer (Pointer) is to compile The object that journey language calls the turn, using address, its value is pointing directly at the value of another place in storage memory, such as Fig. 1 institutes Show.
The left side of Fig. 1 is the simple c++ codes of a line, and one piece of integer variable memory headroom is created using new keywords, and It is 10 by the memory space initialization value, is then directed toward the address using shaping pointer p.The right is memory allocation map explanation, can To see that pointer p is directed toward an address, which is 0x00281e08, which is the shaping variable that a numerical value is 10.In c ++ in, we are typically all that an object is created as so above, then operate the object by pointer to object.So as to provide In the management in source, the pointer can be directed toward the resource, by creating a pointer so as to which module can pass through above-mentioned pointer To manage resource.
In order to make multiple modules that can then be realized on the basis of pointer using intelligent pointer technology with shared resource, Intelligent pointer technology allows multiple pointers to be directed toward same object, and a counter is associated with the object being directed toward, reference It counts and tracks that how many pointer shares same target, so as to realize that multiple modules share resource, but when resource mistake Phase or it is invalid when, when needing to discharge the memory shared by resource, then each module is carried out release operation, when module performs Release operation, a to the last module execution release operation that reference count subtracts 1, is 0 to reference count, associated with resource When module is 0, resource could discharge, and could be discharged so as to the memory of resource occupation, however each module performs release operation Time is uncertain, resource management can be caused to discharge so uncertain, so as to generate exception, leads to not carry out resource Effectively management.
Then, the present invention on the basis of the above, object is managed by the way of the pointer of pointer, referring specifically to Fig. 2 and Fig. 3, the pointer of pointer is a kind of special pointer, and what what it was represented be that the pointer is directed toward is a pointer, that is, address.
From Fig. 2, it will be seen that taking address to pointer p, the pointer pp of pointer is assigned to, pp is directed toward the ground of p at this time Location if we need to access the shaping variable that numerical value is 10 by pp, needs two-stage indirect addressing.When another module Or object need using the shaping variable when, we transmit pp, and pp_copy is assigned a value of pp here, it can be seen that pp_copy It has been also directed to the address of p.That is become by shared p to obtain the access to shaping variable rather than directly shared shaping The address of amount.
As shown in figure 3, dischargeing the memory headroom of the integer variable of new applications if necessary, then the ground that P is directed toward is needed Location space is assigned a value of 0, then it can be seen that the value for the address space that pp, pp_copy are directed toward is 0;When the address space assignment that P is directed toward After 0, can the situation be got by pp or pp_copy, that is to say, that after the memory headroom is discharged, all use should The module and object of shared object can be known, it is only necessary to judge whether * pp==0 are very.It follows that pass through pointer Pointer manage shared object, can actively delete object by new operation applications, and share the module of the object, all It is known that whether the object is released, so as to solve it is mentioned above to the presence release of intelligent pointer probabilistic ask Topic.
It during concrete implementation, can be realized by c++ templates, such as following code establishings one can be real The template shared_r_pp templates of existing resource management, the realization of shared_r_pp templates exist with the difference of general intelligent pointer Setting and included release functions in member variable.In the template, member variable includes one pointer _ ptr and one The effect of pointer _ pptr of pointer, pointer _ ptr are in addition be that an effect can be used to distinguish to _ pptr assignment Master-slave relationship, release functions provide the function of active releasing object to user.Using shared pair of shared_r_pp management As, it is necessary first to mono- object object of new, be transmitted to shared_r_pp, the constructed fuction of shared_r_pp can right _ ptr and _ Pptr assignment.Due to the above-mentioned shared_r_pp objects constructed using constructed fuction, member variable _ ptr and _ pptr are not Can be 0, and if the shared_r_pp objects constructed by copy-constructor function and assignment operator, member variable _ The meeting of ptr is 0, takes another look at release functions, if _ ptr is 0, call the function will not really discharge be managed it is shared Object.Therefore, have above-mentioned it is found that the object of the shared_r_pp only constructed by constructed fuction, could discharge shared pair As, and the shared_r_pp objects of other rights to use that shared object is obtained by copy-constructor function and assignment operator Shared object cannot be discharged, the permission only read, in the management applied to the resource in the present invention, the second of primary module closes Connection is created by constructed fuction, it has release permission, and passing to from the second association of module is constructed by copying What function obtained, it does not have release permission, thus specifies administration authority of each module to resource, so as to be carried out to resource Effective management.Realize code in following parts for shared_r_pp objects:
Optionally, in a kind of method for managing resource provided in an embodiment of the present invention, in the setting primary module and resource First association before, further include:
Obtain the resource;
The resource is sent to the primary module.
In an embodiment of the present invention, the resource can be audio resource, video resource, picture resource, literal resource Deng the acquisition of resource can be obtained from network, can also be obtained from local device, in this regard, the present invention is not particularly limited.
Optionally, in a kind of method for managing resource provided in an embodiment of the present invention, the first of primary module and resource is set Association enables the primary module based on resource described in first associated access and discharges the memory of the resource occupation, including:
Judge whether the resource fails;
If failure, checks whether the resource is accessed;
If the resource is not accessed, the memory of the resource occupation is discharged.
Specifically, since resource updates comparatively fast in actual application, some resources can because time, content etc. because Element and fail, at this moment need release resource, but can access resource from module due to multiple, if from module accesses resource When, primary module performs release resource operation, also results in the exception of resource management in this way, therefore in order to preferably manage resource, Primary module delete resource occupation memory when, need first to judge whether resource fails, if failure, check resource whether by It accesses, if be not accessed, at this moment just discharges the memory of resource.
During concrete implementation, can the reading and release to resource be realized by the setting of Read-Write Locks, read and write Lock is really a kind of special spin lock, it is the management of shared resource is divided into reader and writer, and reader is only to shared resource Read operation is carried out, writer then can carry out write operation to shared resource.This lock can improve concurrent for spin lock Property, because in a multi-processor system, it allows have multiple readers to access shared resource simultaneously.Writer be it is exclusive, one A Read-Write Locks simultaneously can only be there are one writer or multiple readers, but existing reader cannot have writer again simultaneously.If Read-Write Locks are worked as It is preceding without reader, also without writer, then writer can be with immediately obtained Read-Write Locks, and otherwise it must spin there, until not having There are any writer or reader.If Read-Write Locks do not have writer, then reader can obtain the Read-Write Locks immediately, and otherwise reader is necessary It spins there, until writer discharges the Read-Write Locks.In the present invention, primary module has resource the power of read operation and write operation Limit, and only have the permission read to resource from module, it can realize primary module and the management from module to resource by Read-Write Locks.
There is also the need to introduce the concept of multithreading, multithreading (Multithreading) refers to from software or hardware The upper technology realized multiple threads and concurrently performed.Computer with multithreading ability can be in same a period of time when having hardware supported Between perform more than one thread, and then promote disposed of in its entirety performance.System with this ability includes symmetric multiprocessor, more Core processor and chip-scale multiprocessing (Chip-level multithreading) or simultaneous multi-threading (Simultaneous multithreading) processor.In a program, the usability of program fragments of these independent operatings is called " thread " (Thread), the concept programmed using it are just called " multiple threads (Multithreading) ".With multithreading The computer of ability can perform more than one thread when having hardware supported in the same time, and then promote disposed of in its entirety Energy.In multithreading application, need to consider that the data between different threads are synchronous and prevent deadlock.When two or more threads it Between simultaneously wait for other side discharge resource when will form the deadlock between thread.The generation of deadlock in order to prevent needs to lead to It crosses and synchronizes to realize thread-safe.It is multiple to be equivalent to multiple threads from module in the present invention, it is each by multiple threads It can be by data between different threads synchronous from module and prevent deadlock and accesses to resource.
Seen from the above description, the embodiment of the present invention is associated with by establishing first between primary module and resource, makes main mould Block has to the access of resource and release permission, based on first the second association of association setting, and pass through transmission second be associated with to from Module so that have from module to the access rights of resource, i.e., primary module with from module with the different administration authorities to resource, Cause administration authority clear and definite, primary module and can access resource from module, only primary module can to video resource into Row release, relative to for the prior art, the uncertainty of resource release being reduced in the present invention, can be had to resource Effect management, so as to fulfill effective management to memory.
Optionally, it after the memory of the release resource occupation, further includes:Release first association.
Specifically, due to the first associated effect of setting it is to be discharged in shared by resource by the first association It deposits, and after primary module is in the memory for discharging resource occupation, first between primary module and resource is associated with and also becomes nonsensical , therefore, it is necessary to release first association.
Optionally, it is described described second association is passed to it is at least one from module, enable it is described be based on from module it is described Resource described in second associated access, including:
According to the described second association, judge whether first association is released from;
If be not released from, the resource is accessed.
Specifically, it has been passed to since primary module is associated with second from module, and the second association is closed based on first Connection setting, therefore can the first associated situation be judged by the second association from module, if the first association is not present, It is then also meaningless to the access of resource, therefore, it is based on described in second associated access during resource from module, base can be passed through In the described second association, judge whether first association is released from;When the first association is not released from, then the money is accessed Source.
Based on same inventive concept, the present invention provides another embodiment, detailed in Example two.
Embodiment two
A kind of resource management system is present embodiments provided, including:
First setup module 201 for primary module to be set to be associated with the first of resource, enables the primary module to be based on described Resource described in first associated access and the memory for discharging the resource occupation;
Second setup module 202, for according to the described first association, the second association of setting;
Transfer module 203, the described second association is passed to it is at least one from module, enable it is described be based on from module it is described Resource described in second associated access.
Optionally, the system also includes:
First acquisition module, for obtaining the resource;
Sending module, for the resource to be sent to the primary module.
Optionally, first setup module includes:
First judging unit, for judging whether the resource fails;
It checks unit, if for the resource failed, checks whether the resource is accessed;
Releasing unit if be not accessed for the resource, discharges the memory of the resource occupation.
Optionally, first setup module, further includes:
Lifting unit releases first association.
Optionally, the transfer module includes:
Second judgment unit, for according to the described second association, judging whether first association is released from;
Access unit for working as whether first association is released from, then accesses the resource.
Embodiment three
In this embodiment, by taking video resource as an example, the management method and system of a kind of resource of the present invention is discussed in detail.
A video flowing is obtained from network first, which needs simultaneously after decoding process at multiple modules Reason (each processing module is to be decoded in different threads, and from video also in different threads), such as render, after watermark Written document, write-in shared drive used for other processes, for the convenience of description, here will by taking two rendering modules as an example, The processing procedure of the resource of video is introduced, primary module is decoder module, is two rendering modules from module, is obtained from network Video flowing, decoder module is responsible for being decoded video flowing, and rendering module carries out preview to video.Primarily with respect to video flowing It obtains, first obtains stream address, can be obtained about stream address by being inquired to Website server, then using FFmpeg libraries Avformat_open_input functions open the stream address, and obtain audio/video flow data using av_read_frame functions. FFmpeg (Fast ForwardMoving Picture Experts Group) be one increase income free cross-platform video and Audio stream scheme, it provides recording, conversion and the total solution for fluidizing audio and video.And contain very advanced sound Frequently/coding and decoding video library libavcodec, need to use in embodiments of the present invention is the acquisition that FFMPEG carries out video flowing And decoding.Due to only needing video data herein, when resolution flow, the id of the stream of video/audio is obtained, Then it when frame is read, is compared and is judged using the streamid of frame, if audio frame, direct pass is obtained Video data packet be directly passed to decoder module.
First setup module for primary module to be set to be associated with the first of resource, enables the primary module to be based on described the Resource described in one associated access and the memory for discharging the resource occupation;
Specifically, the video data packet passed over is decoded using avcodec_decode_video2, and new mono- A stVideoFrame objects preserve the video frame, are then created by transmitting stVideoFrame pointers using constructed fuction Shared_r_pp objects manage video stVideoFrame objects, due to creating shared_r_pp objects, member Variable includes a pointer _ ptr, wherein above-mentioned first association can be realized by pointer _ ptr, due to constructing shared_ herein R_pp objects are by stVideoFrame pointers, so being created by constructed fuction, _ ptr values are not 0.And it uses List containers preserve all shared_r_pp objects, are conducive to manage the video stVideoFrame that all new come out in this way Object.In addition decoder module can create shared_r_pp object of the timer for periodically traversal list containers preservation, And expired video data is recycled, shared_r_pp can be called::Release functions are recycled, specific steps For:The video information is resolved into video frame;Obtain the timestamp of the video frame;Judge whether the timestamp is more than pre- If the time;If it does, the memory that the video frame occupies then is discharged, until the memory summation of the Secondary resource of release is described The memory that video information occupies;It specifically, can be according to stVideoFrame::Pts is bound with the local time, is preset Time, those skilled in the art may be set according to actual conditions, such as 2 seconds, 3 seconds etc., just discharge video more than preset time Frame, until all composition video frame of the video all discharge, after release.StVideoFrame structures are defined as follows It is shown:
It can be seen from the above, the establishment and destruction of the stVideoFrame objects of management video data, all in decoder module, solution Code module applies for stVideoFrame objects (i.e. video resource) and discharges complete control, can use memory pool etc. in this way Better Memory Storage also can control the size of memory that program uses.
Second setup module, for according to the described first association, the second association of setting;Transfer module is closed described second Connection passes at least one from module, enables described to be based on resource described in second associated access from module.
Specifically, decoder module by shared_r_pp objects is delivered separately to decoded video data to render Module is (since what is transmitted is shared_r_pp objects herein, so the shared_r_pp objects that rendering module obtains are to pass through What copy-constructor function created, thus the object _ ptr values for 0), rendering module also can use the preservation of list containers receive Video shared_r_pp objects, the video shared_r_pp objects in list containers are needed according to stVideoFrame:: Pts sorts.What the stVideoFrame objects that the video data or coding module new used due to rendering module is come out preserved Video data, i.e., what is a frame video, coding module and rendering module used is all a video data, does not carry out video frame The memory copying of data, the use for reducing memory also improve performance.
Rendering module is according to stVideoFrame::The pts i.e. timestamp of the video frame determines when to render the video Frame.When a frame video arrived render time, obtain video shared_r_pp objects from list containers, pass through calling Shared_r_pp->Operator checks return value sees whether be 0, represents what the shared_r_pp objects preserved if it is 0 Video frame has been destroyed, and is skipped and is rendered the frame, does not need to render the video frame for 0.It can be seen that when decoder module destruction regards After frequency shared_r_pp objects, rendering module can also be learnt.In addition rendering module calls shared_r_pp::Release letters Number can not destroy video frame, and rendering module only has the permission read to video shared_r_pp objects.
The various change mode and specific example of method for managing resource in previous embodiment are equally applicable to the present embodiment System, by the detailed description of the aforementioned management method to resource, those skilled in the art are clear that this implementation The implementation of resource management system in example, so in order to illustrate the succinct of book, this will not be detailed here.
The technical solution provided in the embodiment of the present invention, has at least the following technical effects or advantages:
In the technical solution of the embodiment of the present invention, by the way that primary module is set to be associated with the first of resource so that the master Module can be based on resource described in first associated access or the release resource occupation memory;And it is closed according to described first Connection, then the second association of setting passes to the described second association at least one from module, make described to be based on described the from module Resource described in two associated access.Due in the above-mentioned technical solutions, being obtained since primary module is associated with by first to resource It accesses and release permission, the second association based on the first association setting transmitted from module by receiving primary module has to money The access rights in source, but without the permission that discharge to resource in the management to resource, specify primary module and from module pair The administration authority of resource, primary module and can access resource from module, and only primary module can discharge resource, so It, can be effective to the carry out of resource relative to for the prior art, the uncertainty of resource management is reduced in the present invention Management, so as to fulfill effective management to memory.
It should be understood by those skilled in the art that, the embodiment of the present invention can be provided as method, system or computer program Product.Therefore, the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware can be used in the present invention Apply the form of example.Moreover, the computer for wherein including computer usable program code in one or more can be used in the present invention The computer program production that usable storage medium is implemented on (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) The form of product.
The present invention be with reference to according to the method for the embodiment of the present invention, the flow of equipment (system) and computer program product Figure and/or block diagram describe.It should be understood that it can be realized by computer program instructions every first-class in flowchart and/or the block diagram The combination of flow and/or box in journey and/or box and flowchart and/or the block diagram.These computer programs can be provided The processor of all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce A raw machine so that the instruction performed by computer or the processor of other programmable data processing devices is generated for real The device of function specified in present one flow of flow chart or one box of multiple flows and/or block diagram or multiple boxes.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works so that the instruction generation being stored in the computer-readable memory includes referring to Enable the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one box of block diagram or The function of being specified in multiple boxes.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that counted Series of operation steps are performed on calculation machine or other programmable devices to generate computer implemented processing, so as in computer or The instruction offer performed on other programmable devices is used to implement in one flow of flow chart or multiple flows and/or block diagram one The step of function of being specified in a box or multiple boxes.
Although preferred embodiments of the present invention have been described, but those skilled in the art once know basic creation Property concept, then additional changes and modifications may be made to these embodiments.So appended claims be intended to be construed to include it is excellent It selects embodiment and falls into all change and modification of the scope of the invention.
Obviously, those skilled in the art can carry out the embodiment of the present invention various modification and variations without departing from this hair The spirit and scope of bright embodiment.In this way, if these modifications and variations of the embodiment of the present invention belong to the claims in the present invention And its within the scope of equivalent technologies, then the present invention is also intended to include these modifications and variations.

Claims (10)

1. a kind of method for managing resource, which is characterized in that including:
Setting primary module is associated with the first of resource, and the primary module is enable to be based on resource described in first associated access and release Put the memory of the resource occupation;
According to the described first association, the second association of setting;
Described second association is passed at least one from module, enable described to be based on described in second associated access from module Resource.
2. the method as described in claim 1, which is characterized in that before the setting primary module is associated with the first of resource, It further includes:
Obtain the resource;
The resource is sent to the primary module.
3. the method as described in claim 1, which is characterized in that the setting primary module is associated with the first of resource, is made described Primary module based on resource described in first associated access and can discharge the memory of the resource occupation, including:
Judge whether the resource fails;
If failure, checks whether the resource is accessed;
If the resource is not accessed, the memory of the resource occupation is discharged.
4. method as claimed in claim 3, which is characterized in that after the memory of the release resource occupation, further include:
Release first association.
5. the method as described in claim 1, which is characterized in that it is described by described second association pass to it is at least one from mould Block, enable it is described be based on resource described in second associated access from module, including:
According to the described second association, judge whether first association is released from;
If be not released from, the resource is accessed.
6. a kind of resource management system, which is characterized in that including:
First setup module for primary module to be set to be associated with the first of resource, enables the primary module to be based on described first and closes Connection accesses the resource and discharges the memory of the resource occupation;
Second setup module, for according to the described first association, the second association of setting;
Transfer module, the described second association is passed at least one from module, enables described to be based on described second from module and close Connection accesses the resource.
7. system as claimed in claim 6, which is characterized in that further include:
First acquisition module, for obtaining the resource;
Sending module, for the resource to be sent to the primary module.
8. system as claimed in claim 6, which is characterized in that first setup module includes:
First judging unit, for judging whether the resource fails;
It checks unit, if for the resource failed, checks whether the resource is accessed;
Releasing unit if be not accessed for the resource, discharges the memory of the resource occupation.
9. system as claimed in claim 8, which is characterized in that first setup module further includes:
Lifting unit releases first association.
10. system as claimed in claim 6, which is characterized in that the transfer module includes:
Second judgment unit, for according to the described second association, judging whether first association is released from;
Access unit for working as whether first association is released from, then accesses the resource.
CN201611128750.2A 2016-12-09 2016-12-09 Resource management method and system Active CN108228331B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611128750.2A CN108228331B (en) 2016-12-09 2016-12-09 Resource management method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611128750.2A CN108228331B (en) 2016-12-09 2016-12-09 Resource management method and system

Publications (2)

Publication Number Publication Date
CN108228331A true CN108228331A (en) 2018-06-29
CN108228331B CN108228331B (en) 2021-11-26

Family

ID=62637168

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611128750.2A Active CN108228331B (en) 2016-12-09 2016-12-09 Resource management method and system

Country Status (1)

Country Link
CN (1) CN108228331B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109982132A (en) * 2019-04-23 2019-07-05 姚耀 A kind of double recording systems of audio and video remote
CN110730364A (en) * 2019-10-14 2020-01-24 广州微算互联信息技术有限公司 Cloud mobile phone data transmission method and device and storage medium
CN113127140A (en) * 2019-12-31 2021-07-16 阿里巴巴集团控股有限公司 Resource management method, device and system
CN114531602A (en) * 2020-11-23 2022-05-24 ***通信集团安徽有限公司 Video live broadcast performance optimization method and device based on dynamic resource release

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046755A (en) * 2006-03-28 2007-10-03 郭明南 System and method of computer automatic memory management
CN105302580A (en) * 2015-11-28 2016-02-03 武汉斗鱼网络科技有限公司 Method and system for rapidly acquiring game graphics through GPU (Graphics Processing Unit) texture sharing
CN106231489A (en) * 2016-07-25 2016-12-14 深圳市米尔声学科技发展有限公司 The treating method and apparatus of audio frequency

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046755A (en) * 2006-03-28 2007-10-03 郭明南 System and method of computer automatic memory management
CN105302580A (en) * 2015-11-28 2016-02-03 武汉斗鱼网络科技有限公司 Method and system for rapidly acquiring game graphics through GPU (Graphics Processing Unit) texture sharing
CN106231489A (en) * 2016-07-25 2016-12-14 深圳市米尔声学科技发展有限公司 The treating method and apparatus of audio frequency

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
WEIXIN_30648587: "使用二级指针在多线程进行刷选操作", 《HTTPS://BLOG.CSDN.NET/WEIXIN_30648587/ARTICLE/DETAILS/98012721》 *
李文 等: "c++中资源泄露处理方法的研究与实现", 《计算机安全》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109982132A (en) * 2019-04-23 2019-07-05 姚耀 A kind of double recording systems of audio and video remote
CN110730364A (en) * 2019-10-14 2020-01-24 广州微算互联信息技术有限公司 Cloud mobile phone data transmission method and device and storage medium
CN110730364B (en) * 2019-10-14 2021-08-31 广州微算互联信息技术有限公司 Cloud mobile phone data transmission method and device and storage medium
CN113127140A (en) * 2019-12-31 2021-07-16 阿里巴巴集团控股有限公司 Resource management method, device and system
CN113127140B (en) * 2019-12-31 2024-06-11 阿里巴巴集团控股有限公司 Resource management method, device and system
CN114531602A (en) * 2020-11-23 2022-05-24 ***通信集团安徽有限公司 Video live broadcast performance optimization method and device based on dynamic resource release
CN114531602B (en) * 2020-11-23 2024-02-23 ***通信集团安徽有限公司 Video live broadcast performance optimization method and device based on dynamic resource release

Also Published As

Publication number Publication date
CN108228331B (en) 2021-11-26

Similar Documents

Publication Publication Date Title
CN108228331A (en) A kind of method for managing resource and system
CN101493785B (en) Support for transitioning to a virtual machine monitor based upon the privilege level of guest software
DE69729495T2 (en) Image information processing system and microprocessor for the protected reproduction of audiovisual data
KR101177971B1 (en) Methods, systems, and apparatus for object invocation across protection domain boundaries
DE3280446T2 (en) Digital data processing system.
US8327374B1 (en) Framework for executing multiple threads and sharing resources in a multithreaded computer programming environment
US20070124365A1 (en) Method, apparatus and program storage device that provides a user mode device interface
US5790979A (en) Translation method in which page-table progression is dynamically determined by guard-bit sequences
US8904400B2 (en) Processing system having a partitioning component for resource partitioning
US20240070121A1 (en) Thread safe lock-free concurrent write operations for use with multi-threaded in-line logging
CN104391695B (en) A kind of method and its device that control is synchronized by external equipment
CN101772764A (en) Multi-threaded business programming library
DE102019108266A1 (en) TECHNOLOGIES FOR PROVIDING INSULATION ON A FUNCTIONAL LEVEL WITH ABILITY-BASED SECURITY
CN103946827A (en) System and method for implementing locks shared between kernel and user space
DE102012200613A1 (en) System and method for supporting JIT in a secure system and randomly allocated memory areas
CN102254123B (en) Method and device for enhancing security of application software
US10831915B2 (en) Method and system for isolating application data access
CN111309289B (en) Memory pool management assembly
Migliavacca et al. {DEFCON}:{High-Performance} Event Processing with Information Security
US20070198522A1 (en) Virtual roles
CN114041119A (en) Memory deallocation across trust boundaries
CN110442492A (en) A kind of System Operation Log management method and device
CN105468304B (en) A kind of Native storage cards and its management method
US9286483B2 (en) Protecting visible data during computerized process usage
CN101196835B (en) Method and apparatus for communicating between threads

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240325

Address after: Room 8009-1, Block B, Dingchen Times Business Building, No. 5 Development Road, Xuefu Industrial Park, Shanxi Transformation and Comprehensive Reform Demonstration Zone, Taiyuan City, Shanxi Province, 030000

Patentee after: Shanxi Kehua Yongxing Software Application Service Co.,Ltd.

Country or region after: China

Address before: 430000 East Lake Development Zone, Wuhan City, Hubei Province, No. 1 Software Park East Road 4.1 Phase B1 Building 11 Building

Patentee before: WUHAN DOUYU NETWORK TECHNOLOGY Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right