Summary of the invention
Problem to be solved by this invention is to solve the problem of EMS memory occupation in Web/Hybrid application.
For solving the problems referred to above, the scheme that the present invention uses is as follows:
A kind of device for solving Web application memory occupation problem, provides including page events trapping module and multimedia
Source replacement module;Described page events trapping module is used for capturing Web page navigation event and obtaining page data;Described
Multimedia resource replacement module analyzes multimedia resource in history page when being used for Web page navigation event or exit event generation
And self-defining community/multimedia resource file is pointed in its multimedia resource path.
Further, the described device being used for solving Web application memory occupation problem can also include community/multimedia resource
File generating module and multimedia resource recovery module;Described community/multimedia resource file generation module is for dynamically generating bag
Community/multimedia resource file containing initial multimedia resource path;Described multimedia resource recovery module is in Web page
Community/multimedia resource literary composition when face navigation event occurs and when current page is history page, multimedia resource in the page pointed to
Part is reduced into initial multimedia resource path.
Further, the described device for solving Web application memory occupation problem it can also include that resource replaces plan
Slightly control module, described resource replacement policy control module is for judging whether to need the multimedia resource by history page to replace
Change self-defining community/multimedia resource file into.Further, described resource replacement policy control module includes page access
Frequency statistics module and resource Replacement Decision module;Described page access frequency statistics module is used for adding up page access
Number;Described resource Replacement Decision module is replaced for judging whether to multimedia resource according to page access number of times.
A kind of method for solving Web application memory occupation problem, comprises the steps:
S1: capture Web page navigation event and acquisition page data;
When S2:Web page navigation event or the event that exits occur, multimedia resource by its many matchmakers in the analysis of history page
Body resource path points to self-defining community/multimedia resource file.
Further, the described method being used for solving Web application memory occupation problem, it is also possible to comprise the steps:
S20: dynamically generate the community/multimedia resource file including initial multimedia resource path;
S3:Web page navigation event occurs to judge whether current page is history page;
When S4: current page is history page, the community/multimedia resource file that multimedia resource in the page points to is reduced into
Initial multimedia resource path.
Further, the described method for solving Web application memory occupation problem, it can also include:
S21: judge whether to need the multimedia resource in history page replaces to self-defining community/multimedia resource literary composition
Part.
Described step S21 includes:
S211: statistics page access number of times;
S212: judge whether to multimedia resource according to page access number of times and replace.
A kind of machine readable media, on this computer-readable recording medium, storage has instruction set, when this instruction set is performed so that
This machine can perform the above-mentioned method for solving Web application memory occupation problem.
The technique effect of the present invention:
1, present invention utilizes browser kernel internal memory releasing mechanism, make former multimedia resource lack by the way of replacement
Quote basis less so that browser kernel is automatically releasable and lacks the multimedia resource quoting basis, thus releasing memory, last solution
Certainly Web/Hybrid application memory occupation problem.
2, the enforcement means framework of the present invention is outside browser kernel, compare with revise browser kernel solve internal memory account for
By the method for problem, this invention ensures that the independence of browser kernel, robustness and integrality.
3, being multimedia resource due to present invention release, these resources typically require substantial amounts of memory source, and internal memory
The little content of text of occupancy is retained rather than is merely discharged together by full content, and this delivery mode strengthens
Consumer's Experience, application operating is more smooth, Consumer's Experience is the most comfortable.
4, the present invention can realize the combination of two kinds of internal memory release strategies.Based on the present invention, developer can depend on
According to applying the internal memory release strategy of self specific adjusted rather than using lru algorithm monotonously, can be at browser kernel LRU
Self-defined internal memory release strategy on the basis of algorithm, so that developer can develop more preferable Mobile solution.
Detailed description of the invention
Below the summary of the invention of the present invention is described in further details.
The invention mainly comprises five modules: page events trapping module, multimedia resource replacement module, community/multimedia provide
Source file generation module, multimedia resource recovery module and resource replacement policy control module.In the case of simplest, it is only necessary to
Two modules: page events trapping module, multimedia resource replacement module.Separately below between these modules and module
Relation describes in detail.
1, page events trapping module
Page events trapping module is used for capturing Web page navigation event and obtaining page data.Here page navigation
Event includes advancing, retreats, back to homepage, target goal address, exits the events such as navigation.In the input of this module is browser
The page data carried in the page navigation event of core offer and page navigation event.It is output as the page in page navigation event
Face data pass to multimedia resource replacement module and multimedia resource recovery module.Concrete handling process be referred to as
Under:
Step11: receive browser kernel page navigation event and page data.
Step12: judge whether the page of historical viewings.If there is turning Step13, otherwise turn Step15.
Step13: by historical viewings page data transmission to by resource replacement policy control module.
Step14: after resource replacement policy control module analyzes and processes, it would be desirable to carry out the history page of resource replacement
Data are transferred to multimedia resource replacement module, then are turned Step15 by after the process of multimedia resource replacement module.
Step15: judge that whether page navigation event is for exiting event.If the event that exits then terminates, otherwise turn
Step16。
Step16: judge that current page is whether in the historical viewings page.If it is, these history page data are transmitted
Process to multimedia resource recovery module.
Above-mentioned flow process shows that this module is replaced with multimedia resource replacement module, multimedia resource recovery module and resource
Relation between strategic control module.Above-mentioned flow process is a kind of embodiment of this module, one skilled in the art will appreciate that also
There is other embodiments, such as, above-mentioned Step14 can put into resource replacement policy control module and process.Simplest
Under situation, above-mentioned Step13 can be made into " by historical viewings page data transmission to multimedia resource replacement module " and omit
Subsequent step just can solve problem to be solved by this invention.
2, multimedia resource replacement module
Multimedia resource replacement module is used for Web page navigation event or exits when event occurs many in analysis history page
Self-defining community/multimedia resource file is also pointed in its multimedia resource path by media resource." Web page navigation event or move back
When outgoing event occurs " illustrate the relation between this module and page events trapping module, and capture at aforesaid page events
Module has been described.The input of this module is page data, specifically Web page file.Output is amended
Page data.Here multimedia resource refers to picture, audio frequency, video, even can be with other the number with bigger internal memory
According to.Here self-defining community/multimedia resource file can be picture, the audio or video minimized.The most a size of 1
The picture file of × 1 or the audio or video file of only 1 second, even can also is that file that file size is 0 or
Text.Community/multimedia resource file can be with predefined, it is also possible to dynamically generate.Multimedia resource replacement process mainly leads to
Cross the multimedia resource searched in history page data to realize.Owing to Web page file is generally html file or XML file.
Therefore this process is namely by specifically marking, such as in lookup html file or XML file<bgsound>,<img
>,<embed>, the mark such as<object>.Such process belongs to prior art for a person skilled in the art, and it is specifically real
The most not difficulty.
It should be noted that the input of this module can be single history page data, it is also possible to be multiple history page
Data.
3, community/multimedia resource file generation module
Community/multimedia resource file generation module includes little many matchmakers of initial multimedia resource path for dynamically generating
Body resource file.The input of this module is initial multimedia resource path.It is output as including initial multimedia resource path
Community/multimedia resource file.The function of this module needs and multimedia resource recovery module synergy.Aforementioned multimedia resource
Replacement module illustrating, community/multimedia resource file can be with predefined, it is also possible to dynamically generate.But " dynamically giving birth in this explanation
Become " it is not equivalent to the implication in this module." comprise because the community/multimedia resource file generation module of this module refers exclusively to generate
There is the community/multimedia resource file of initial multimedia resource path "." dynamically generate " and simply indicated that this module provides with multimedia
Relation between the replacement module of source: this module is called by multimedia resource replacement module, output is by multimedia resource replacement module
Use.The multimedia resource that this module makes multimedia resource replacement module replace in history page is community/multimedia resource file
After, multimedia resource recovery module according to the initial multimedia resource path comprised in community/multimedia resource file again by history
The page returns to the state before amendment.Therefore the community/multimedia resource file that this module generates is actually text, text
Content be initial multimedia resource path.This document can't be processed owing to browser kernel is actual, the most such place
Reason mode has no effect on the browser kernel process to file.
4, multimedia resource recovery module
Multimedia resource recovery module is used for when Web page navigation event occurs and when current page is history page will
The community/multimedia resource file that in the page, multimedia resource points to is reduced into initial multimedia resource path.Its input is page number
According to, it is output as amended page data." by page when Web page navigation event occurs and when current page is history page
In face " indicate the call relation between this module and page events trapping module, and at aforesaid page events trapping module
In have been described.The processing procedure of this module is identical with multimedia resource replacement module.But concrete content is different.Due to front
Stating the multimedia resource pointed by the history page through processing for multimedia resource replacement module is local community/multimedia money
Source file, and this community/multimedia resource file has comprised initial multimedia resource path.Therefore, the process data that this module is concrete
Content be only by history page data point to community/multimedia resource file remodify into community/multimedia resource file
In the initial multimedia resource path that comprises.
5, resource replacement policy control module
Resource replacement policy control module is used for judging whether to need to be replaced to by the multimedia resource in history page certainly
The community/multimedia resource file of definition.The foundation judging whether replacement of resource replacement policy control module has a variety of, such as
Aforesaid lru algorithm.Simplest situation is that the multimedia resource in all of history page replaces to self-defining little many matchmakers
Body resource file.In this module, user can set self-defining rule and decide whether to be replaced.Such as user can
Never replacing setting some webpage, and some webpages are dynamic page, image content always real-time change, such picture provides
Source just retains not necessarily in history, can replace to community/multimedia resource file each time and release to realize maximized internal memory
Put.User can also be realized by self-defining algorithm.Such as by adding up the access times of the page, then according to page access
Number of times determines the need for replacing.Following embodiment describes this access times by the statistics page in detail and according to the page
Access times determine the need for replacement and realize this functions of modules.
Under this embodiment, this module includes page access frequency statistics module and resource Replacement Decision module.The page is visited
Ask that frequency statistics module is called by aforementioned page events trapping module.When browsers page navigation, page access frequency statistics
The current page of browser directed is counted and preserves by module.Then resource Replacement Decision module judges according to page access number of times
Whether carry out multimedia resource replacement.Concrete " judging whether to multimedia resource according to page access number of times replace " also has
A variety of methods.Such as threshold method, page access number of times is less than a fixed number, is then replaced.For another example, to history page according to
Page access number of times is ranked up, and most front 10 pages of page access number of times are not replaced, and other pages all replace
Change.
In foregoing summary, each step of method is corresponding with each functional module aforesaid, and by its corresponding module
Realize: step S1 correspondence page navigation event capturing module;Step S2 correspondence multimedia resource replacement module;Step S20 is corresponding
Community/multimedia resource file generation module;Step S21 correspondence resource replacement policy control module;Multimedia money that step S4 is corresponding
Source recovery module;Step S211 correspondence page access frequency statistics module, step S212 correspondence resource Replacement Decision module.Step
S3 is corresponding aforesaid Step16.It will be appreciated by those skilled in the art that step S3 can also be real in multimedia resource recovery module
Existing.Because each step of the method is described in aforesaid modules, it is not repeated.
It should be noted that in aforesaid technical scheme, the present invention is used for solving Web application memory occupation problem.This area
Artisans understand that, it is suitable for solve Hybrid application memory occupation problem.Aforementioned invention problem to be solved
And technique effect have also been made corresponding description.Therefore the present invention is used for solving Hybrid application memory occupation problem and falls within
Protection scope of the present invention.