A kind of method for releasing resource, device, equipment and mediumTechnical field
The present invention relates to resource management fields, more particularly to a kind of method for releasing resource, device, equipment and medium.
Background technique
Data are the bases that business works normally in support system, therefore system can be by run business during the work timeRequired data are stored temporarily in memory, data needed for capable of efficiently obtaining business so as to system, it is ensured that businessOrderly execute.
Data are stored in memory, need to continue committed memory resource, but since business is under different working stagesIt is different for the specific requirements of data, and the total resources in memory is relatively limited, thus business need periodically orUsed data in memory are removed under certain condition, accomplish the purpose of releasing memory resource with this, and then ensure that business is being worked asNew data required for last stage can normal storage into memory.Under current application scene, occupied in business releasing memoryResource, release order particular by the main thread resource response of business process, released order according to resource to phase in memoryThe data answered are removed, and then proceed to respond to subsequent incoming work order by main thread again.Due in practical situations,The data volume that business needs to remove in memory is often larger, therefore the overall time for causing main thread to remove data in EMS memory is openedIt sells relatively large, and then the whole time delay of main thread response follow-up work instruction may be will increase, it is difficult to ensure the entirety of businessWorking efficiency.
It can be seen that a kind of method for releasing resource is provided, the entirety instructed with relative reduction business main thread responsive operationTime delay, and then ensure the whole work efficiency of business, it is those skilled in the art's urgent problem to be solved.
Summary of the invention
The object of the present invention is to provide a kind of method for releasing resource, device, equipment and media, with relative reduction business main lineThe whole time delay of journey responsive operation instruction, and then ensure the whole work efficiency of business.
In order to solve the above technical problems, the present invention provides a kind of method for releasing resource, comprising:
When the main thread of business process, which receives resource, to release order, started by main thread independently of the auxiliary of main threadIndex contour journey;
It is released order by worker thread according to resource and removes corresponding data in memory.
Preferably, data include Inode data and content-data;
Correspondingly, specifically being wrapped by worker thread according to resource the step of removing corresponding data in memory of releasing orderIt includes:
By Inode data retrieval to memory in corresponding content-data remove;
Remove Inode data.
Preferably, when being nested with other Inode data in Inode data, according to Inode data retrieval to and removeIn memory after corresponding content-data, this method further comprises:
It obtains other Inode data and is separately written to memory.
Preferably, other Inode data are being obtained and are being separately written to memory, this method further comprises:
According to the corresponding object content data of other Inode data acquisitions, and object content data are written to memory.
Preferably, remove in memory after corresponding data being released order by worker thread according to resource, this method intoOne step includes:
Worker thread is hung up, and when main thread receives new resources and releases order, auxiliary line is waken up by main threadJourney is released order corresponding new data with removing in memory with new resources.
Preferably, it removes in memory before corresponding data being released order by worker thread according to resource, this methodFurther comprise:
Resource lock is arranged to data.
In addition, the present invention also provides a kind of resource release devices, comprising:
Thread starting module is opened when receiving resource for the main thread when business process and releasing order by main threadThe dynamic worker thread independently of main thread;
Resource release module removes corresponding data in memory for releasing order by worker thread according to resource.
In addition, the present invention also provides a kind of resource release devices, comprising:
Memory, for storing computer program;
Processor is realized when for executing computer program such as the step of above-mentioned method for releasing resource.
In addition, being stored with meter on computer readable storage medium the present invention also provides a kind of computer readable storage mediumCalculation machine program is realized when computer program is executed by processor such as the step of above-mentioned method for releasing resource.
Method for releasing resource provided by the present invention is released when the host process of business process receives characterization internal storage data needsWhen the resource put releases order, host process starting and itself mutually independent worker thread, and then by worker thread according to moneySource, which is released order, removes corresponding data in memory.This method receives after resource releases order in the main thread of business process,The relevant operation that releasing memory resource is individually performed in independent worker thread is opened, therefore middle main thread needs compared with the prior artFor first responding subsequent work order again after memory source discharges, the main thread in this method is internal without carrying outThe removal operation of corresponding data in depositing, can respond the follow-up work instruction of business process, therefore being capable of relative reduction businessThe whole time delay of main thread responsive operation instruction, and then can ensure the whole work efficiency of business.In addition, the present invention also providesA kind of resource release device, equipment and medium, beneficial effect are same as above.
Detailed description of the invention
In order to illustrate the embodiments of the present invention more clearly, attached drawing needed in the embodiment will be done simply belowIt introduces, it should be apparent that, drawings in the following description are only some embodiments of the invention, for ordinary skill peopleFor member, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of flow chart of method for releasing resource provided in an embodiment of the present invention;
Fig. 2 is a kind of structure chart of resource release device provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, completeSite preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, rather than whole embodiments.Based on thisEmbodiment in invention, those of ordinary skill in the art are without making creative work, obtained every otherEmbodiment belongs to the scope of the present invention.
Core of the invention is to provide a kind of method for releasing resource, with the instruction of relative reduction business main thread responsive operationWhole time delay, and then ensure the whole work efficiency of business.Another core of the invention is to provide a kind of resource release device, setsStandby and medium.
In order to enable those skilled in the art to better understand the solution of the present invention, with reference to the accompanying drawings and detailed descriptionThe present invention is described in further detail.
Embodiment one
Fig. 1 is a kind of flow chart of method for releasing resource provided in an embodiment of the present invention.Referring to FIG. 1, resource release sideThe specific steps of method include:
Step S10: when the main thread of business process, which receives resource, to release order, started by main thread independently of masterThe worker thread of thread.
It should be noted that the business process in this step characterized is the business for being in working condition, business can be withIt is interpreted as providing a user the computer program of related service.Business constantly responds direct or indirect by user during the work timeThe operational order of initiation is substantially business process after receiving operational order, by the operational order be transmitted to business intoThe main thread run in journey, and corresponding business operation is carried out according to the intention that operational order is characterized by main thread.This stepIt is to pass through main line when the main thread of business process receives the resource that characterization removes the data in memory and releases orderCheng Qidong in subsequent steps with this replaces main thread pair by worker thread independently of the worker thread of main thread itselfResource, which releases order, to be handled.In addition, the worker thread of this step and main thread are concepts in contrast, that is to say, that mainThread and worker thread are substantially the thread for being able to carry out task processing, and distinctive points functionally are only that, main threadFor handling the task in new arrival business other than removing internal storage data, and worker thread is newly arrived for individually handling main threadCarry out the task of the removal internal storage data in business.
Step S11: it is released order by worker thread according to resource and removes corresponding data in memory.
It is understood that this step releases order progress to resource in a manner of being asynchronous to main thread worker threadCorresponding operation, is realized to be released order according to resource with this and removes the final purpose of corresponding data in memory, due to memoryMiddle institute's storing data, which remove, is well known to those skilled in the art technology contents, therefore does not do specifically repeat herein.
Method for releasing resource provided by the present invention is released when the host process of business process receives characterization internal storage data needsWhen the resource put releases order, host process starting and itself mutually independent worker thread, and then by worker thread according to moneySource, which is released order, removes corresponding data in memory.This method receives after resource releases order in the main thread of business process,The relevant operation that releasing memory resource is individually performed in independent worker thread is opened, therefore middle main thread needs compared with the prior artFor first responding subsequent work order again after memory source discharges, the main thread in this method is internal without carrying outThe removal operation of corresponding data in depositing, can respond the follow-up work instruction of business process, therefore being capable of relative reduction businessThe whole time delay of main thread responsive operation instruction, and then can ensure the whole work efficiency of business.
Embodiment two
On the basis of the above embodiments, the present invention also provides a series of preferred embodiments.
As a preferred embodiment, it is characterized in that, data include Inode data and content-data;
Correspondingly, specifically being wrapped by worker thread according to resource the step of removing corresponding data in memory of releasing orderIt includes:
By Inode data retrieval to memory in corresponding content-data remove;
Remove Inode data.
It should be noted that Inode data, that is, index node data are wrapped for storing the essential information of archives and catalogueContaining time, shelves name, user and group etc., Inode data can be understood as it is interior there are in actual hardware equipment access content numberBe the data of description content data according to required metadata, mainly describe data attribute information, thus with content numberThere are corresponding relationships between.Under actual scene, when needing to read data during vocational work, the number is usually first obtainedIt stores according to corresponding Inode data, and then by Inode data to memory, it is further more efficiently quasi- according to Inode data with thisTrue gets required content-data, therefore under current scene, after business is completed to the use of content-data, leads in memoryOften it has been stored with Inode data and corresponding content-data.In order to more agree under currently used scene to content-dataAcquisition modes, further ensure in memory resource discharge overall effect, present embodiment remove memory inWhen corresponding data, first according to Inode data retrieval to and remove corresponding content-data in memory, and then will be used for againThe Inode data that content-data is retrieved in memory are deleted, and opposite can ensure that total data relevant to content-data is equal with thisMemory is removed out, it is opposite to improve the comprehensive of resource release, the generation of dirty data is avoided, memory headroom is further improvedAvailability.
On the basis of the above embodiment, as a preferred embodiment, it is other when being nested in Inode dataWhen Inode data, according to Inode data retrieval to and remove in memory after corresponding content-data, this method is furtherInclude:
It obtains other Inode data and is separately written to memory.
It should be noted that due to consideration that in practical applications, it is understood that there may be nested in Inode data otherThe case where Inode data, that is to say, that be able to access that its nested other Inode data pair by some Inode dataThe content-data answered, and currently when removing Inode data, it can the nested other Inode numbers of related removal Inode dataAccording to, but other Inode data may be used or will be used by business by business, therefore current related removalThe nested other Inode data of Inode data undoubtedly will cause business for other Inode data using abnormal.This realityMode is applied when removal is nested with the Inode data of other Inode data, other Inode data is individually obtained and is separately writtenTo memory, ensure that business still is able to get other Inode data in memory and uses with this, and then can guarantee businessOverall stability.
On the basis of the above embodiment, as a preferred embodiment, obtaining other Inode data and singleSolely after write-in to memory, this method further comprises:
According to the corresponding object content data of other Inode data acquisitions, and object content data are written to memory.
Due to consideration that content-data corresponding to other Inode data in memory can Inode data in memoryBefore being removed, it is removed as the corresponding content-data of Inode data, therefore even if by it after removing Inode dataNested other Inode data be separately written to memory, business is needing content-data corresponding to other Inode dataWhen, it is still necessary to first corresponding content-data is read in External memory equipment according to Inode data and is stored to memory, but thisOne operation can undoubtedly generate certain delay, cause business that can not efficiently get required content-data in memory.ThisEmbodiment is obtaining other Inode data and is being separately written to memory, according to other corresponding targets of Inode data acquisitionContent-data, and object content data are written to memory, and then when business is needed using the corresponding content of other Inode dataIt when data, can directly be obtained in memory according to Inode data, without consuming biggish time overhead in External memory equipmentMiddle reading further ensures the whole efficiency of vocational work.
In addition, as a preferred embodiment, being removed in memory being released order by worker thread according to resourceAfter corresponding data, this method further comprises:
Worker thread is hung up, and when main thread receives new resources and releases order, auxiliary line is waken up by main threadJourney is released order corresponding new data with removing in memory with new resources.
It should be noted that being to control worker thread in a dormant state by the essence that worker thread is hung up, due to consideringStarting to thread needs to occupy certain system resource, and in the case where system resource is relatively in short supply, the starting of thread is oftenIt needs that available system resource is waited to reach load quantity, therefore is difficult to ensure that worker thread can be in resource under actual sceneIt releases order and completes to start at once when arriving, present embodiment is released order by worker thread completion to resourceAfter processing, worker thread is hung up, i.e., does not discharge the system resource that worker thread has occupied, and then when main thread receives newlyWhen resource releases order, can immediately pass through main thread wake up worker thread so that worker thread processing new resources release order,The whole efficiency of resource release is further ensured that with this.
On the basis of a series of above-mentioned embodiments, as a preferred embodiment, passing through worker thread rootIt releases order and is removed in memory before corresponding data according to resource, this method further comprises:
Resource lock is arranged to data.
It should be noted that due to consideration that, it is removed in memory accordingly being released order by worker thread according to resourceData during, business process may receive the operational order for the data, in order to ensure business normally holdRow, should be avoided business process and gets the data removed in memory, due to the sheet removed for the data in memoryMatter is the formatting modification to data, therefore present embodiment removes in memory being released order by worker thread according to resourceBefore corresponding data, locking mechanisms when according to modification data avoid moving to the data setting resource lock in memory with thisIt is carried out using, it is ensured that the overall stability of business by business during except data.
Embodiment three
Hereinbefore the embodiment of method for releasing resource is described in detail, the present invention also provides one kind and is somebody's turn to doThe corresponding resource release device of method, since the embodiment of device part is corresponded to each other with the embodiment of method part, dressSet part embodiment refer to method part embodiment description, wouldn't repeat here.
Fig. 2 is a kind of structure chart of resource release device provided in an embodiment of the present invention.Money provided in an embodiment of the present inventionSource release device, comprising:
Thread starting module 10 passes through main thread when receiving resource for the main thread when business process and releasing orderStart the worker thread independently of main thread.
Resource release module 11 removes corresponding data in memory for releasing order by worker thread according to resource.
Resource release device provided by the present invention is released when the host process of business process receives characterization internal storage data needsWhen the resource put releases order, host process starting and itself mutually independent worker thread, and then by worker thread according to moneySource, which is released order, removes corresponding data in memory.The present apparatus receives after resource releases order in the main thread of business process,The relevant operation that releasing memory resource is individually performed in independent worker thread is opened, therefore middle main thread needs compared with the prior artFor first responding subsequent work order again after memory source discharges, the main thread in the present apparatus is internal without carrying outThe removal operation of corresponding data in depositing, can respond the follow-up work instruction of business process, therefore being capable of relative reduction businessThe whole time delay of main thread responsive operation instruction, and then can ensure the whole work efficiency of business.
Example IV
In addition, the present invention also provides a kind of resource release devices, comprising:
Memory, for storing computer program;
Processor is realized when for executing computer program such as the step of above-mentioned method for releasing resource.
Resource release device provided by the present invention is released when the host process of business process receives characterization internal storage data needsWhen the resource put releases order, host process starting and itself mutually independent worker thread, and then by worker thread according to moneySource, which is released order, removes corresponding data in memory.This equipment receives after resource releases order in the main thread of business process,The relevant operation that releasing memory resource is individually performed in independent worker thread is opened, therefore middle main thread needs compared with the prior artFor first responding subsequent work order again after memory source discharges, the main thread in this equipment is internal without carrying outThe removal operation of corresponding data in depositing, can respond the follow-up work instruction of business process, therefore being capable of relative reduction businessThe whole time delay of main thread responsive operation instruction, and then can ensure the whole work efficiency of business.
In addition, being stored with meter on computer readable storage medium the present invention also provides a kind of computer readable storage mediumCalculation machine program is realized when computer program is executed by processor such as the step of above-mentioned method for releasing resource.
Computer readable storage medium provided by the present invention, in the process of implementation, when the host process of business process receivesWhen needing the resource discharged to release order to characterization internal storage data, host process starting and itself mutually independent worker thread, intoAnd it is released order by worker thread according to resource and removes corresponding data in memory.This computer readable storage medium is in businessAfter the resource that the main thread of process receives releases order, the correlation that releasing memory resource is individually performed in independent worker thread is openedOperation, therefore middle main thread needs respond subsequent work order after first discharging to memory source again compared with the prior artFor, the main thread in this computer readable storage medium implementation procedure is without carrying out the behaviour of the removal to data corresponding in memoryMake, the follow-up work instruction of business process can be responded, therefore be capable of the whole of relative reduction business main thread responsive operation instructionBody time delay, and then can ensure the whole work efficiency of business.
A kind of method for releasing resource provided by the present invention, device, equipment and medium are described in detail above.It saysEach embodiment is described in a progressive manner in bright book, and the highlights of each of the examples are the differences with other embodimentsPlace, the same or similar parts in each embodiment may refer to each other.For device, equipment disclosed in embodiment and mediumSpeech, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method part illustration?.It should be pointed out that for those skilled in the art, without departing from the principle of the present invention, alsoCan be with several improvements and modifications are made to the present invention, these improvement and modification also fall into the protection scope of the claims in the present inventionIt is interior.
It should also be noted that, in the present specification, relational terms such as first and second and the like be used merely to byOne entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operationBetween there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaningCovering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes thatA little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article orThe intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arrangedExcept there is also other identical elements in the process, method, article or apparatus that includes the element.