WO2020221068A1 - Resource management method, apparatus and device - Google Patents

Resource management method, apparatus and device Download PDF

Info

Publication number
WO2020221068A1
WO2020221068A1 PCT/CN2020/085949 CN2020085949W WO2020221068A1 WO 2020221068 A1 WO2020221068 A1 WO 2020221068A1 CN 2020085949 W CN2020085949 W CN 2020085949W WO 2020221068 A1 WO2020221068 A1 WO 2020221068A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
resource
cache
file
size
Prior art date
Application number
PCT/CN2020/085949
Other languages
French (fr)
Chinese (zh)
Inventor
殷昉
许虎
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2020221068A1 publication Critical patent/WO2020221068A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0893Caches characterised by their organisation or structure
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files

Definitions

  • This application relates to the storage field, and in particular to a resource management method, device and equipment.
  • Linux is a multi-user, multi-task, multi-thread and multi-central processing unit (CPU) operating system based on the Portable Operating System Interface of UNIX (Posix) and Unix. It can run major Unix tools, software, applications and network protocols, and supports 32-bit and 64-bit hardware. It is a multi-user network operating system with stable performance. Linux systems can be installed in various computer hardware devices, such as mobile phones, tablets, routers, video game consoles, desktop computers, mainframes, and supercomputers.
  • the file cache management algorithm used in the Linux system such as the least recently used (LRU) algorithm. It can be used as a page replacement algorithm.
  • LRU least recently used
  • the Linux system will try to identify which file cache data is rarely accessed recently, and speculate that it is unlikely to be used for a period of time in the future, so that its memory resources can be recycled first. Make room to load other more valuable data or files.
  • the smart phones applied to the Linux system for the early smart phones, due to limited hardware resources, they are generally a typical single-task system.
  • the user interacts with the mobile phone through the touch screen.
  • the size of the mobile phone screen is small, usually only enough to display an application window in full screen. Therefore, the application displayed on the mobile phone screen is usually the application currently used by the user, and the application is an application at the top ( Sometimes it is also called the foreground application).
  • the foreground application enjoys the highest priority privileges.
  • the Linux system will provide all the resources of the mobile terminal memory to the foreground application to ensure the foreground application Can bring users the smoothest experience.
  • the Linux system will automatically clean up the applications running in the background to free up resources for the foreground applications.
  • the file cache management algorithm (LRU-like algorithm) used by the current Linux system has the same rights in treating the file cache corresponding to the foreground application and the background application, that is, an application running in the background can obtain unlimited access Memory resources and network resources.
  • a background application continuously obtains large-size video file resources from the network and writes them into the memory of the phone, which in turn causes the background application to occupy and affect the operation of other applications, even the highest priority
  • the file cache resources of the foreground application are all occupied by the large-size background application video file, so that the performance of the foreground application and other background applications is degraded due to insufficient file cache resources.
  • an embodiment of the present application provides a resource management method, the method includes: an operating system configures a first resource, the first resource is used to read a file related to a first application, and the first resource Less than the total resources occupied by reading the related files of the first application; using the first resource to read the related files of the first application to obtain the first resource occupied when reading the related files of the first application Cache resource; if the size of the first cache resource exceeds the size of the first resource, determine a second resource, and clear the second resource in the first cache resource, so that the second resource is cleared The remaining resources after that continue to read the files related to the first file.
  • the method provided in this embodiment sets a threshold value for the first application that has been started, that is, the first resource size, and the threshold value is less than the total resources required by the first application to read related files, thereby controlling the reading of the first application.
  • the size of the first cache resource occupied by the related files of an application does not exceed the threshold, thereby preventing the first application from occupying the cache resources without limitation and affecting the operation and use of other applications.
  • This method effectively limits certain systems in the system.
  • An application such as the memory footprint of a foreground application or a background application, reasonably manages the file cache resources of each application in the system and improves the utilization rate of file cache resources.
  • the method further includes: an application scenario event triggered when the system acquires a user operation, where the application scenario event is the first When applying a scene event, determine at least one related file that has a corresponding relationship with the scene event of the first application; read the at least one related file by using the first resource.
  • This aspect uses the scene events of the first application to determine the relevant files needed to read the first application, and loads these relevant files in advance, so as to prepare in advance for starting the first application, so that when starting and running the first application, Quickly read related files in the file cache to improve reading speed and operating efficiency.
  • the configuring the first resource includes: parsing the configuration file after startup to obtain the quota ratio of the first application cache; according to the current free memory capacity and the first application cache; An application cached quota ratio calculates the absolute value of the quota of the first application; the absolute value of the quota is multiplied by a preset ratio to obtain the size of the first resource.
  • the cache quota ratio of each application can be determined and configured, and the size of the first resource can be determined, so as to limit the size of each application not to exceed the size of the first resource when reading related files.
  • Each application occupies unlimited file cache resources.
  • the method before the configuring the first resource, further includes: receiving, by the operating system, a request message sent by the first application, where the request message is used for Request to read the related file of the first application; determine whether the related file of the first application is stored in the memory RAM; if not, execute the step of configuring the first resource.
  • the first application is at least one of the following: a foreground application, a first type of service, a background application, and a second type of service; wherein the first application Class services are used to provide necessary services for the foreground application, and the second type of services are used to provide necessary services for the background application.
  • the certain background application can also be switched to the foreground application, and correspondingly, the foreground application displayed on the current terminal interface can also be switched to the background.
  • an embodiment of the present application provides a resource management device, the device includes a processing unit and an acquiring unit, and further, the processing unit is used to configure a first resource, and the first resource is used to read the first resource.
  • An application related file the obtaining unit is used to obtain the first cache resource occupied when reading the related file of the first application; the processing unit is also used to determine whether the size of the first cache resource exceeds In the case of the size of the first resource, determine a second resource, and clear the second resource in the first cache resource, so that the remaining resources after clearing the second resource can continue to read the first resource.
  • Application related files are used to configure a first resource, and the first resource is used to read the first resource.
  • the processing unit is specifically configured to respond to the size of the first cache resource, the size of the related file of the first application to be read, and the The first resource determines the second resource.
  • the acquiring unit is further configured to acquire an application scenario event triggered when the user operates after the first resource is configured; the processing unit is also configured to When the application scenario event is a scenario event of the first application, determining at least one related file that has a corresponding relationship with the scenario event of the first application, and reading the at least one related file by using the first resource.
  • the processing unit is specifically configured to parse the configuration file to obtain the quota ratio of the first application cache, according to the current free memory capacity and the first application cache
  • the quota ratio calculates the absolute value of the quota of the first application, and multiplies the absolute value of the quota by a preset ratio to obtain the size of the first resource.
  • the acquiring unit is further configured to receive a request message sent by the first application before configuring the first resource, where the request message is used to request Read the related file of the first application; the processing unit is also used to determine whether the related file of the first application is saved; if not, execute the step of configuring the first resource.
  • the first application is at least one of the following: a foreground application, a first type of service, a background application, and a second type of service; wherein the first type of service is used to provide necessary services for the foreground application, The second type of service is used to provide necessary services for the background application.
  • an embodiment of the present application also provides a terminal device, including a transceiver, a processor, and a memory, the processor is coupled to the memory, and the memory is used to store instructions; and the processor is used to call all The instructions enable the network device to execute the foregoing first aspect and the resource management methods in various implementation manners of the first aspect.
  • the embodiments of the present application also provide a computer-readable storage medium.
  • the storage medium stores instructions.
  • the instructions run on a computer or a processor, they are used to execute the aforementioned first aspect and the first aspect.
  • methods in various implementations are also provided.
  • the embodiments of the present application also provide a computer program product.
  • the computer program product includes computer instructions. When the instructions are executed by a computer or a processor, the foregoing first aspect and various aspects of the first aspect can be implemented. The method in the implementation mode.
  • an embodiment of the present application also provides a chip system, the chip system includes a processor and an interface circuit, the interface circuit is coupled with the processor, and the processor is used to execute a computer program or instruction to The foregoing first aspect and the methods in various implementation manners of the first aspect are implemented; wherein the interface circuit is used to communicate with other modules outside the chip system.
  • the resource management method, device, and device provided in this embodiment set a threshold value for the first application that has been started, that is, the first resource size, and the threshold value is less than the total resources required by the first application to read related files , So as to control the size of the first cache resource occupied by reading related files of the first application not to exceed the threshold, so as to prevent the first application from occupying the cache resource unlimitedly and affecting the operation and use of other applications.
  • This method is effective It limits the memory usage of a certain application in the system, such as the foreground application or the background application, reasonably manages the file cache resources of each application in the system, and improves the utilization rate of file cache resources.
  • this method performs active management of file cache in the mobile phone terminal, so as to give priority to ensuring the file cache resources used by the foreground application, and quickly restore the file cache required by the application when the background application is switched to the foreground, thereby improving application performance File input and output efficiency improves user experience.
  • FIG. 1 is a schematic structural diagram of a computer system provided by an embodiment of this application.
  • FIG. 3 is a schematic structural diagram of a configuration file caching apparatus provided by an embodiment of the application.
  • Figure 4 is a flowchart of another resource management method provided by an embodiment of the application.
  • FIG. 5 is a flowchart of configuring file cache quota according to an embodiment of the application.
  • FIG. 6 is a schematic structural diagram of another configuration file caching apparatus provided by an embodiment of this application.
  • FIG. 7 is a schematic structural diagram of a resource management device provided by an embodiment of the application.
  • FIG. 8 is a schematic structural diagram of a terminal device provided by an embodiment of the application.
  • the technical solution of the embodiment of the present application can be applied to a modern computer system.
  • the computer system mainly includes the following components: input device: such as keyboard and mouse, through which the user inputs data and programs; memory: such as Memory, hard disk, used to memorize programs, data, intermediate results, and final calculation results; arithmetic unit: usually integrated in the CPU, support various calculations, and can process data; controller: usually integrated in the CPU to control the program Execution; output devices: such as monitors and printers, which output data processing results to users.
  • the memory can be used to store a large amount of programs and data.
  • the memory can be divided into main memory and auxiliary memory.
  • the main storage is also called internal storage (referred to as memory), and the auxiliary storage is also called external storage (referred to as external storage).
  • the so-called “memory” and “external memory” are viewed from the perspective of the CPU.
  • the memory is close to the CPU and is connected by a dedicated high-speed channel. It is all integrated circuits and has a fast access speed. Therefore, the program code executed by the CPU and the target data of the operation are directly obtained from the memory. But the capacity of the memory is small and there is no data persistence. Once the power is turned off or there is a power failure, the programs and data in it will be lost.
  • external memory The characteristics of external memory are opposite to those of memory. It is far away from the CPU, generally connected by a low-speed channel, and can also include mechanical parts, and the access speed of the external memory is slow; but it has a large capacity and is not afraid of power failure, and can store information for a long time.
  • the external storage includes hard disk, magnetic tape, DVD, U disk, solid state disk, etc.
  • the external memory is used to store the user’s programs and data.
  • the operating system will first load the relevant files of the application from the external memory into the memory, and then use the CPU to carried out. Due to the low access speed of external memory, in order to reduce the number of accesses to external memory and improve input/output (Input/Output, I/O) efficiency, the operating system will allocate a batch of memory or memory resources specifically for storing accessed applications Related documents of the program. In this way, when the application program reads these files again, it can be directly obtained from the memory, avoiding reading from the external memory again, which is slow.
  • the memory or memory resources allocated in advance may be referred to as "file cache”, and optionally, it may also be referred to as "page cache” in Linux.
  • the file cache management algorithm adopted by the Linux system is the Least Recently Used (LRU) algorithm, or the least recently used algorithm, which instructs the operating system to delete data that is rarely accessed recently in the file cache.
  • LRU Least Recently Used
  • the memory resources can be recycled first to make room to load more valuable data.
  • This embodiment provides a file caching method, which can specifically adopt different resource guarantee strategies for foreground applications and multiple background applications, and improve the efficiency of file caching.
  • each third-party application has its own unique identifier, such as a user ID (user ID or uid), which can also be a traditional Unix user ID.
  • user ID user ID or uid
  • uid Unix user ID
  • the operating system allocates file cache, it needs to record and check the user ID that the memory page belongs to. If the file cache occupied by this user ID has reached the upper limit, it will no longer provide memory resources for the application, thereby avoiding unlimited application Occupies cache resources and affects the normal operation of other applications.
  • OS operating system
  • OS may be a Linux system for an Android system, and may be an IOS system for an Apple system.
  • IOS system for an Apple system.
  • it may also be other systems, which are not limited in this embodiment.
  • the method provided in this embodiment is based on the unique user identification of each application.
  • the system allocates and manages the file cache quota (set upper limit) for each application, so as to control the file cache resources used by each application to manage and limit each application.
  • the purpose of the application occupying cache resources.
  • this embodiment provides a resource management method, which may be executed by the system or operating system of the terminal. Specifically, the method includes:
  • Step 101 Receive a first request message sent by a first application, where the first request message is used to request to read related files of the first application.
  • the related files include: data files (pictures) or program files necessary to run the first application. Further, the data files include pictures, audio files, video files, etc., and the program files include code or computer to execute the program. program.
  • a user triggers or starts a first application, and the first application sends a first request message to the system; wherein the system includes a file cache and a file system, and further, the file cache is The system allocates a batch of memory or memory resources in advance to carry related files of the first application.
  • the first application may be at least one of the following: foreground application, first type of service, background application, second type of service, wherein the first type of service is used for foreground application Provide necessary services; the second type of service is used to provide necessary services for background applications.
  • the first type of service is a type A service (A_services)
  • the second type of service is a type B service (B_services).
  • the foreground application is an application currently displayed and running on the screen of the terminal device, that is, an interface of the application displayed to the user on the screen.
  • the background application is an application program running in the background of the system, and the interface of the application program is not displayed and presented to the user.
  • the background application may be an application previously used by the user and switched to the background, and may be switched to the foreground at any time, and displayed to the user through a screen interface.
  • the Type A service and Type B service do not have an interface. They are processes or threads that provide special services for front-end applications or back-end applications with interfaces, such as providing Global Positioning System (GPS) positioning services and audio playback. Service etc.
  • GPS Global Positioning System
  • the foreground application has a higher priority than the background application.
  • the priority of the A service is higher than the B service, so when the memory is insufficient, the background application and the B service are first recycled and cleaned.
  • File cache to ensure the normal operation of foreground applications and Class A services.
  • the system obtains the request message sent by the first application in real time, and the request message includes related information of the file to be read, such as the file name, file address, and file size.
  • Step 102 Determine whether relevant files of the first application are stored.
  • the system detects whether relevant files of the first application are stored in the internal memory (such as RAM).
  • the internal memory such as RAM
  • the judgment process in step 102 may be implemented by the quota management module shown in FIG. 3.
  • Step 103 If yes, send related files of the first application to the first application, so that the first application can be quickly started and run.
  • Step 104 If not, configure the first resource and use the first resource to read related files of the first application. Specifically, as shown in FIG. 4, step 104 specifically includes:
  • Step 1041 The system configures a first resource, and the first resource is used to read related files of the first application.
  • the size of the first resource is smaller than the total resource size occupied by the relevant file for reading the first application.
  • the first resource may also be referred to as a first file cache.
  • the process of configuring the first resource includes: first, after the system is started, the configuration file is parsed to obtain the cache quota ratio of the first application, and then the first application cache quota ratio is calculated according to the current free memory capacity and the first application cache quota ratio. An absolute value of an applied quota is finally multiplied by a preset ratio to obtain the size of the first resource.
  • the configuration file includes the correspondence between the user ID of each application and at least one cache quota ratio.
  • the cache quota ratio may be preset by the system, that is, the user ID of each application and a cache are established. Correspondence between quota ratios. For example, as shown in Figure 5, after the system is started, the configuration file is parsed and the cache quota ratio corresponding to the user ID of each application is configured.
  • the corresponding cache quota ratios of the foreground application, background application, type A service, and type B service are respectively: 60%, 10%, 20%, 10%.
  • the absolute value of the quota of each application is calculated according to the corresponding relationship, which are respectively: 600M, 100M, 200M, and 100M.
  • the preset ratio is 80%
  • the absolute value of the quota of each application is multiplied by the preset ratio to obtain the size of the first resource: 480M, 80M, 160M, and 80M.
  • the preset ratio may also be another ratio, which is not limited in this embodiment.
  • Step 1042 Obtain the first cache resource occupied when reading the related file of the first application.
  • the obtaining of the first cache resource is a process of obtaining the first cache resource dynamically by the system in real time, or the first cache resource is obtained once every time interval has elapsed.
  • the operating system kernel can control the usage of system resources, and the resources occupied by each application process are accounted for, including used memory resources, open files, and so on.
  • the "Memory Resource Controller" function when enabled, each application process will be recorded in the system when applying for or releasing the file cache, so the operating system can obtain each application process (including the first One application) The occupied value of the file cache, that is, the size of the first cache resource.
  • Step 1043 If the size of the first cache resource exceeds the size of the first resource, determine a second resource, and clear the second resource in the first cache resource, so that the second resource is cleared The remaining resources after that continue to read related files of the first application.
  • the exceeding of the first resource size may be understood as a resource currently occupied by reading related files of the first application greater than the size of the first resource.
  • the determining the second resource includes: determining the second resource according to the first cache resource, the size of the related file of the first application to be read, and the first resource.
  • the second resource size the first cache resource size+the size of the related file of the first application to be read-the first resource size, and the size of the resource cleared in step 1043 is not less than the The size of the second resource.
  • the size of the first resource is 80M
  • the currently detected size of the first cache resource is 100M
  • the size of the related file to be read is 5M
  • the size of the resource cleared in the first cache resource is at least 25M.
  • the size of the related file of the first application to be read may be determined through a first request message.
  • the system obtains the first request message sent by the first application in real time.
  • the first request message includes the file name, address, and file size of the file to be read.
  • the system receives the first request message, it determines according to the content contained therein.
  • the size of the file to be read is used to determine the size of the resources that are still needed.
  • the size of the file to be read can also be obtained in other ways, which is not limited in this embodiment.
  • the method further includes: if it is currently detected that the size of the first cache resource is less than or equal to the size of the first resource, that is, the resource currently occupied by reading related files of the first application is less than the configured first resource. Resource size, continue to use the first cache resource to read related files of the first application.
  • the threshold value that is, the first resource
  • the threshold value is set for the first application that has been started, and the threshold value is less than the total resources required by the first application to read related files, thereby controlling the reading of the first application.
  • the size of the first cache resource occupied by the related files of an application does not exceed the threshold, thereby preventing the first application from occupying the cache resources without limitation and affecting the operation and use of other applications.
  • This method effectively limits certain systems in the system.
  • An application such as the memory footprint of a foreground application or a background application, reasonably manages the file cache resources of each application in the system and improves the utilization rate of file cache resources.
  • this embodiment takes the first application as a background application, and the first resource as an example of the background application and type B service.
  • the cache quota ratios of back-end applications and class B services obtained by analyzing the configuration file are 10% and 10%, respectively. Then calculate the absolute value of the quota of the background application and the category B service according to the system's free content capacity of 1G to be 100M, and calculate the first resource size of the background application and the category B service to be 80M according to a preset ratio of 80%.
  • the system detects at a certain moment that the first cache resource occupied by the background application is 100M, and the first cache resource occupied by type B services is 200M, both of which exceed the first resource size (80M) configured respectively, so it is determined And clear the second resource.
  • the second resource may be the resource occupied by the file that was previously cached in the first cache resource, and the second resource is recycled.
  • the second resource is 80M.
  • the file cache occupied by the application is 20M
  • the file cache occupied by the B-type service is 30M, which is lower than the configured first resource size of 80M. Therefore, the background application and the B-type service can continue to use the file cache to read related files after recovery.
  • one way of recovering the file is to select the file loaded in the first cache resource, copy it to the external storage, and then delete the part of the file, so as to free up some resources for the first time.
  • a cache resource is smaller than the corresponding first resource size.
  • the method further includes: setting a timer to trigger periodic calculation of the quota, periodic detection and recycling of the file cache of each application. For example, when the timer reaches a predetermined time, the system calculates the absolute value of each application quota according to the current free memory size and allocates the updated first resource size; and detects that the current first cache resource size occupied by each application exceeds the updated first resource size The first resource is to recover the second resource occupied by the file previously loaded by the application. And after the recovery is complete, reset the timer.
  • the method further includes: the system determines whether the first cache resource occupied by the foreground application and the type A service each exceeds the corresponding first resource, because the first cache resource size currently detected by the foreground application and the type A service None of them exceed the size of the first resource, so you can continue to read related files of foreground applications and Class A services.
  • the specific detection and recovery method is the same as the foregoing background application and type B service recovery process, and will not be repeated here.
  • the method provided in this embodiment implements active file cache management in the mobile phone terminal, thereby prioritizing the file cache resources used by the foreground application, and quickly restores the file cache required by the application when the background application is switched to the foreground, thereby improving This improves the application’s file input and output efficiency and improves user experience.
  • the process of using the first resource to read the related file of the first application further includes the step of loading the related file in advance by the system, so that the first application can be It can read and run quickly, improving the startup speed and running fluency of the first application.
  • the system acquires application scenario events triggered when a user operates, where each application corresponds to an application scenario event in advance, and when the application scenario event is a scenario event of the first application, Determine at least one related file that has a corresponding relationship with the scene event of the first application, and use the first resource to read the at least one related file in advance.
  • the process of reading related files of the first application in advance by the system includes: the detection module of the system detects an application request triggered when the user operates the mobile phone terminal, and the application request is used to trigger the first application
  • the application scenario event of the first application includes: the user starts the first application for the first time, for example, opens a window of the first application.
  • the loading management module receives the application request sent by the detection module, and finds whether there is a file cache storing related files required by the first application; if not, the quota management module configures the first resource for the first application, and then
  • the related files of the first application are obtained from the external storage. In the process of obtaining the related files from the external storage,
  • the quota management module detects whether the first cache resource currently occupied by the relevant file of the first application exceeds a preset threshold (that is, the size of the first resource), and if it exceeds, it initiates an external memory reading to the file system. For the related file actions, after the file system obtains the related files from the external storage, these related files are stored in the file cache, so that when the first application starts, the system can directly cache the files of the first application in the file cache. Relevant files are provided to the first application to avoid obtaining them from the external memory. This method improves the reading speed and speeds up the operating efficiency of the first application due to the file cache in the internal memory.
  • a preset threshold that is, the size of the first resource
  • the method includes: when the user operates the mobile phone terminal, triggering a first application request, the first application requesting to start a file access requirement configuration file, and determining the application scenario event of the first application, and the application scenario At least one related file corresponding to the event.
  • the file access requirement configuration file includes at least one corresponding relationship, and the corresponding relationship is a corresponding relationship between an application scenario event and at least one related file.
  • the first application scenario event corresponds to related files a and b
  • the second application scenario event corresponds to related file c.
  • the related files a, b, or c are popular files that need to be read frequently when running a certain application, for example, when the first application is started for the first time, files a and b need to be read; when the second application is started, a certain window is opened In the interface, file c needs to be read.
  • the detection module of the system After detecting the first application request, the detection module of the system obtains the application scenario event of the first application associated with the first application, and then according to the application scenario event of the first application and the corresponding relationship in the file access requirement configuration file Determine its corresponding related documents. For example, the detection module determines that the current first application scenario event corresponds to related files a and b, and then sends first indication information to the load management module, where the first indication information is used to instruct to obtain related files a and b.
  • the loading management module receives the first instruction information and obtains the related files a and b from the file system. In the process of reading the related files a and b, the quota management module is used to detect in real time the first occupied files a and b. 1. Whether the cache resource exceeds the preset first resource (quota threshold), if it exceeds, the file cache recovery operation is performed to limit the size of the first cache resource and prevent reading related files a and b from occupying memory without limitation Resources.
  • the process of loading files in advance described in the foregoing embodiment may include the following steps:
  • the system determines whether to load the relevant files of the first application in advance according to the current free capacity
  • the system allocates and manages file cache quotas based on the unique user identification of the application, thereby setting the resource size of the file cache occupied by each application, so as to prevent each application from occupying memory resources unlimitedly when reading related files, which affects The operation of other applications.
  • the system configures the corresponding first resource for each application according to the role of the application (foreground application, background application, type A service, type B service), combined with the current free memory capacity of the system, so as to make the total memory resource of the system Reasonably allocate to different uses, for example, the cache resources enjoyed by foreground applications and type A services are higher than those of background applications and type B services, thereby improving user experience.
  • a resource management device provided by this embodiment is used to implement the method in the foregoing embodiment.
  • the device includes: an obtaining unit 701 and a processing unit 702.
  • the device may also include more units, such as a sending unit, a storage unit, etc., which are not limited in this embodiment.
  • the processing unit 702 is configured to configure a first resource, where the first resource is used to read related files of the first application, where the first resource is less than the total resources occupied by reading the related files of the first application;
  • the unit 701 is configured to obtain the first cache resource occupied when the related file of the first application is read;
  • the processing unit 701 is also configured to: when the size of the first cache resource exceeds the size of the first resource In the case of determining the second resource, and clearing the second resource in the first cache resource, so that the remaining resources after clearing the second resource can continue to read the first application related file.
  • the first application is at least one of the following: foreground application, first type service, background application, second type service.
  • the first type of service is used to provide necessary services for the foreground application
  • the second type of service is used to provide necessary services for the background application.
  • the first type of service is a type A service
  • the second type of service is a type B service.
  • the processing unit 702 is specifically configured to determine the size of the related file of the first application to be read according to the first cache resource, and the The first resource determines the second resource.
  • the acquiring unit 701 is further configured to acquire an application scenario event triggered when the user operates after the first resource is configured; the processing unit 702 is also configured to When the application scene event is a scene event of the first application, determine at least one read file that has a corresponding relationship with the scene event of the first application; and use the first resource to read the at least one Related documents.
  • the processing unit 702 is specifically configured to parse the configuration file when the operating system is started to obtain the quota ratio of the first application cache, according to the current free memory capacity and the The quota ratio cached by the first application calculates the absolute value of the quota of the first application, and multiplies the absolute value of the quota by a preset ratio to obtain the size of the first resource.
  • the preset ratio is 80%.
  • the acquiring unit 701 is further configured to receive a request message sent by the first application before configuring the first resource for the first application.
  • the request message It is used to request to load the first application; the processing unit 702 is also used to determine whether the relevant file of the first application is saved; if not, execute the step of configuring the first resource.
  • processing unit 702 is further configured to, if yes, directly send the related files of the first application cached in the internal memory RAM to the first application through the sending unit.
  • the receiving unit, the processing unit, and the sending unit in the device embodiment can be implemented by software, hardware, or a combination of software and hardware.
  • the software can be run on a computer or a processor.
  • the acquisition unit and the processing unit may be integrated in the processor of the terminal device or a software module required for processing operation or a combination of the two.
  • an embodiment of the present application also provides a terminal device for implementing part or all of the steps of the resource management method described in the foregoing embodiment.
  • the terminal device includes: a transceiver 801, a processor 802, and a memory 803.
  • the terminal device may also include more or fewer components, or a combination of some components, or different components. The arrangement of components is not limited in this application.
  • the transceiver 801 is used to establish a communication channel so that the terminal device can connect to a network, such as a WiFi network system or a cellular network, through the communication channel, so as to realize communication transmission between the terminal device and other network devices.
  • the transceiver 801 may include components such as a receiver, a transmitter and an antenna, or may also include radio frequency components such as a receiver and a transmitter, and further, the radio frequency components may include a wireless local area network (WLAN)
  • WLAN wireless local area network
  • At least part of the communication modules such as modules, Bluetooth modules, baseband modules, and radio frequency (RF) circuits corresponding to the communication modules are used for wireless local area network communication, Bluetooth communication, infrared communication and/or cellular Communication system, such as wideband code division multiple access (WCDMA) and/or high-speed downlink packet access (HSDPA).
  • WCDMA wideband code division multiple access
  • HSDPA high-speed downlink packet access
  • the transceiver is also used to control the communication between
  • the processor 802 is the control center of the terminal device, which uses various interfaces and lines to connect the various parts of the entire hardware device, runs or executes software programs and/or modules stored in the memory 803, and calls Data to perform various functions of the terminal device.
  • the processor 802 may include one or more integrated circuits (ICs) or chips, for example, may include a single packaged IC, or may include multiple packaged ICs connected with the same function or different functions.
  • the processor may only include a CPU, or may further include a combination of a GPU, a digital signal processor (digital signal processor, DSP), and a control chip in the transceiver module.
  • ICs integrated circuits
  • DSP digital signal processor
  • the memory 803 is used to store program codes for executing the technical solutions of the present application, and the processor 802 controls the execution. Further, the processor 802 is configured to execute the computer program code stored in the memory 803 to implement the resource management method in the foregoing embodiment.
  • the memory can be read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (RAM), or can store information and instructions
  • ROM read-only memory
  • RAM random access memory
  • Other types of dynamic storage devices can also be Electrically Erasable Programmable Read-Only Memory (EEPROM), Compact Disc Read-Only Memory, CD-ROM or other optical disk storage, Optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired program codes in the form of instructions or data structures and can Any other medium accessed by the computer, but not limited to this.
  • the memory can exist independently or integrated with the processor.
  • the function to be implemented by the obtaining unit 701 may be implemented by the transceiver 801 of the terminal device; the function to be implemented by the processing unit 702 may be implemented by the processor 802.
  • the functions of the detection module, quota management module, load management module, and file system in the system can all be implemented by the transceiver 801 and the processor 802 of the terminal device.
  • the functions of the internal memory and external memory can be implemented by the memory 803, and the application can be configured in an operating system, such as an Android system or an IOS system.
  • the terminal device described in this embodiment may be a mobile terminal, such as a mobile phone (or called a "cellular" phone) and a computer with a mobile terminal.
  • a mobile terminal such as a mobile phone (or called a "cellular" phone) and a computer with a mobile terminal.
  • it may be portable, pocket-sized, handheld, built-in computer, or vehicle-mounted.
  • Mobile devices which exchange language and/or data with the wireless access network.
  • PCS personal communication service
  • SIP Session Initiation Protocol
  • WLL wireless local loop
  • PDAs personal digital assistants
  • the wireless terminal may also be a subscriber unit (subscriber unit), subscriber station (subscriber station), mobile station (mobile station), mobile station (mobile), remote station (remote station), access point (access point), remote station Terminal (remote terminal), access terminal (access terminal), user terminal (user terminal), user agent (user agent), user equipment (user device) or user equipment (user equipment, UE), etc., embodiments of this application
  • subscriber unit subscriber unit
  • subscriber station subscriber station
  • mobile station mobile station
  • mobile station mobile station
  • remote station remote station
  • access point access point
  • remote station Terminal remote station
  • access terminal access terminal
  • user terminal user terminal
  • user agent user agent
  • user equipment user device
  • user equipment user equipment
  • the present application also provides a computer storage medium, where the computer storage medium may store a program, and the program may include some or all of the steps in each embodiment of the antenna selection method provided in the present application when the program is executed.
  • the storage medium can be a magnetic disk, an optical disk, ROM or RAM, etc.
  • all or part of it may be implemented by software, hardware, firmware or any combination thereof.
  • When implemented by software it can be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions, such as an antenna selection instruction or an antenna avoidance instruction.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a network node, computer, server, or data center. Transmission to another site, computer or server via wired or wireless means.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a storage device such as a server or data center integrated with one or more available media.
  • the usable medium may be a magnetic medium, such as a floppy disk, a hard disk, a magnetic tape, an optical medium (such as a DVD), or a semiconductor medium, such as a solid-state hard disk (SSD).
  • the technology in the embodiments of the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solutions in the embodiments of the present application can be embodied in the form of a software product in essence or a part that contributes to the prior art.
  • the computer software product can be stored in a storage medium, such as ROM/RAM , Magnetic disks, optical disks, etc., including a number of instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments of the present invention.

Abstract

A resource management method, apparatus and device. The method comprises: configuring a first resource which is used for reading a related file of a first application (1041); obtaining a first cache resource occupied when the related file of the first application is read (1042); and if the size of the first cache resource exceeds the size of the first resource, determining a second resource, and clearing the second resource from the first cache resource so that the remaining resources after the second resource is cleared continue to read the related file of the first application (1043). According to the method, a threshold value, i.e., the size of the first resource, is set to control the size of the first cache resource occupied by reading the related file of the first application not to exceed the threshold value, so that the situation that the operation and use of other applications are affected due to unlimited occupy of cache resources by the first application is avoided, and the utilization rate of file cache resources is increased.

Description

一种资源管理方法、装置和设备Resource management method, device and equipment
本申请要求在2019年4月30日提交中国国家知识产权局、申请号为201910362513.X的中国专利申请的优先权,发明名称为“一种资源管理方法、装置和设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the State Intellectual Property Office of China with an application number of 201910362513.X on April 30, 2019, and a Chinese patent application with the title of "a resource management method, device and equipment" Priority, the entire content of which is incorporated in this application by reference.
技术领域Technical field
本申请涉及存储领域,尤其是涉及一种资源管理方法、装置和设备。This application relates to the storage field, and in particular to a resource management method, device and equipment.
背景技术Background technique
Linux是一个基于可移植操作系统接口(Portable Operating System Interface of UNIX,Posix)和Unix的多用户、多任务、支持多线程和多中央处理器(Central Processing Unit,CPU)的操作系统。它能运行主要的Unix工具软件、应用程序和网络协议,并且支持32位和64位硬件,是一个性能稳定的多用户网络操作系统。Linux系统可安装在各种计算机硬件设备中,比如手机、平板电脑、路由器、视频游戏控制台、台式计算机、大型机和超级计算机等。Linux is a multi-user, multi-task, multi-thread and multi-central processing unit (CPU) operating system based on the Portable Operating System Interface of UNIX (Posix) and Unix. It can run major Unix tools, software, applications and network protocols, and supports 32-bit and 64-bit hardware. It is a multi-user network operating system with stable performance. Linux systems can be installed in various computer hardware devices, such as mobile phones, tablets, routers, video game consoles, desktop computers, mainframes, and supercomputers.
Linux系统中采用的文件缓存管理算法,例如类最近最少使用(least recently used,LRU)算法。它可作为一种页面置换算法,Linux系统会尝试识别哪些文件缓存数据是最近很少访问的数据,并推测将来一段时间内也不太可能会用到它们,从而可以优先回收其内存资源,腾出空间来加载其他更有价值的数据或文件。The file cache management algorithm used in the Linux system, such as the least recently used (LRU) algorithm. It can be used as a page replacement algorithm. The Linux system will try to identify which file cache data is rarely accessed recently, and speculate that it is unlikely to be used for a period of time in the future, so that its memory resources can be recycled first. Make room to load other more valuable data or files.
目前,在应用于Linux系统的智能手机中,对于早期的智能手机,由于硬件资源有限,一般是典型单任务系统。用户通过触摸屏与手机交互,手机屏幕尺寸小,通常只够全屏显示一个应用的窗口,因此在手机屏幕显示的通常是用户当前操作使用的应用程序,且该应用程序是位于顶层的一个应用程序(有时也称其为前台应用程序)。在用户操作前台应用程序的这段时间内,该前台应用程序享有最高优先级的特权,换句话说,Linux系统会将手机终端内存的全部资源提供给该前台应用程序,以保证该前台应用程序能带给用户最流畅的体验。可是一旦系统的内存资源不足时,Linux系统会自动清理后台运行的应用程序,以便腾出资源来给前台应用。At present, among the smart phones applied to the Linux system, for the early smart phones, due to limited hardware resources, they are generally a typical single-task system. The user interacts with the mobile phone through the touch screen. The size of the mobile phone screen is small, usually only enough to display an application window in full screen. Therefore, the application displayed on the mobile phone screen is usually the application currently used by the user, and the application is an application at the top ( Sometimes it is also called the foreground application). During the period when the user is operating the foreground application, the foreground application enjoys the highest priority privileges. In other words, the Linux system will provide all the resources of the mobile terminal memory to the foreground application to ensure the foreground application Can bring users the smoothest experience. However, once the system's memory resources are insufficient, the Linux system will automatically clean up the applications running in the background to free up resources for the foreground applications.
随着智能手机的演进,硬件资源变得越来越丰富,系统在保障前台应用程序所需资源的同时,还需兼顾几个到几十个在后台运行的应用程序,因为用户在使用手机时,随时可以通过按Home键,将某个后台应用的程序切换到前台,将当前应用程序切换到后台。如果该新切换到前台的后台应用是用户早前启动过的,并且留存在后台运行,则切换时就可以直接启动该后台应用,省去了启动前加载相关文件的资源开销,提高切换效率,从而使得用户体验变得流畅。因此智能手机的操作系统,除了要全力为前台应用程序提供足够的内存资源以外,还需要给处于后台的多个应用程序提供最基础的硬件资源供应,以便为这些后台应用随时可能切换成前台应用做准备。With the evolution of smart phones, hardware resources have become more and more abundant. While ensuring the resources required by foreground applications, the system also needs to take into account several to dozens of applications running in the background, because users are using mobile phones. , You can switch to the foreground and the current application to the background by pressing the Home button at any time. If the new background application that is switched to the foreground was previously started by the user and left in the background to run, the background application can be started directly when switching, eliminating the resource overhead of loading related files before starting, and improving switching efficiency. This makes the user experience smooth. Therefore, in addition to providing sufficient memory resources for foreground applications, the operating system of smartphones also needs to provide the most basic hardware resource supply for multiple applications in the background, so that these background applications may switch to foreground applications at any time. prepare for.
但是,目前的Linux系统所采用的文件缓存管理算法(类LRU算法)在对待前台应用和后台应用程序所对应的文件缓存上是同等权利的,即正在后台运行的一个应用程序可以无限 制地获取内存资源和网络资源,比如一个后台应用不断地从网络获取大尺寸的视频文件资源,并写入手机的内存中,进而导致该后台应用程序占用和影响其他应用程序的运行,甚至最高优先级的前台应用的文件缓存资源都被该大尺寸的后台应用视频文件占据,从而使得前台应用和其他后台应用由于所需的文件缓存资源不足而导致性能劣化。However, the file cache management algorithm (LRU-like algorithm) used by the current Linux system has the same rights in treating the file cache corresponding to the foreground application and the background application, that is, an application running in the background can obtain unlimited access Memory resources and network resources. For example, a background application continuously obtains large-size video file resources from the network and writes them into the memory of the phone, which in turn causes the background application to occupy and affect the operation of other applications, even the highest priority The file cache resources of the foreground application are all occupied by the large-size background application video file, so that the performance of the foreground application and other background applications is degraded due to insufficient file cache resources.
发明内容Summary of the invention
为了解决上述问题,本申请实施例具体公开了如下技术方案:In order to solve the foregoing problems, the embodiments of the present application specifically disclose the following technical solutions:
第一方面,本申请实施例提供了一种资源管理方法,所述方法包括:操作系统配置第一资源,所述第一资源用于读取第一应用的相关文件,且所述第一资源小于读取第一应用的相关文件所占用的总资源;利用所述第一资源读取所述第一应用的相关文件,获取在读取所述第一应用的相关文件时所占用的第一缓存资源;如果所述第一缓存资源的大小超过所述第一资源的大小,则确定第二资源,并在所述第一缓存资源中清除所述第二资源,使得清除所述第二资源后的剩余资源继续读取所述第一文件相关文件。In the first aspect, an embodiment of the present application provides a resource management method, the method includes: an operating system configures a first resource, the first resource is used to read a file related to a first application, and the first resource Less than the total resources occupied by reading the related files of the first application; using the first resource to read the related files of the first application to obtain the first resource occupied when reading the related files of the first application Cache resource; if the size of the first cache resource exceeds the size of the first resource, determine a second resource, and clear the second resource in the first cache resource, so that the second resource is cleared The remaining resources after that continue to read the files related to the first file.
本实施例提供的方法,通过对已经启动的第一应用设置门限值,即第一资源大小,且该门限值小于第一应用读取相关文件所需的总资源,进而控制读取第一应用的相关文件所占用的第一缓存资源大小不超过该门限值,从而避免第一应用无限制地占用缓存资源而影响其他应用程序的运行使用,本方法有效地限制了系统中的某一应用,比如前台应用或后台应用的内存占用大小,合理地管理了系统中各个应用的文件缓存资源,并提高文件缓存资源的使用率。The method provided in this embodiment sets a threshold value for the first application that has been started, that is, the first resource size, and the threshold value is less than the total resources required by the first application to read related files, thereby controlling the reading of the first application. The size of the first cache resource occupied by the related files of an application does not exceed the threshold, thereby preventing the first application from occupying the cache resources without limitation and affecting the operation and use of other applications. This method effectively limits certain systems in the system. An application, such as the memory footprint of a foreground application or a background application, reasonably manages the file cache resources of each application in the system and improves the utilization rate of file cache resources.
结合第一方面,在第一方面的一种可能的实现中,所述确定第二资源,包括:根据所述第一缓存资源、待读取的所述第一应用的相关文件的大小和所述第一资源确定所述第二资源。进一步地,所述第二资源大小=第一缓存资源大小+待读取的所述第一应用的相关文件的大小-第一资源大小。其中,所述待读取的所述第一应用的相关文件的大小可以通过请求消息中携带的内容确定,所述请求消息中包括读取的文件的名称、地址、大小等信息。With reference to the first aspect, in a possible implementation of the first aspect, the determining the second resource includes: according to the first cache resource, the size of the related file of the first application to be read, and all The first resource determines the second resource. Further, the second resource size=the first cache resource size+the size of the related file of the first application to be read-the first resource size. Wherein, the size of the related file of the first application to be read may be determined by content carried in a request message, and the request message includes information such as the name, address, and size of the read file.
结合第一方面,在第一方面的一种可能的实现中,所述在配置第一资源之后还包括:系统获取用户操作时触发的应用场景事件,在所述应用场景事件为所述第一应用的场景事件时,确定与所述第一应用的场景事件具有对应关系的至少一个相关文件;利用所述第一资源读取所述至少一个相关文件。本方面利用第一应用的场景事件确定读取第一应用所需要的相关文件,并提前加载这些相关文件,从而为启动该第一应用提前做准备,以便在启动和运行第一应用时,可以快速度读取文件缓存的相关文件,提高读取速度和运行效率。With reference to the first aspect, in a possible implementation of the first aspect, after configuring the first resource, the method further includes: an application scenario event triggered when the system acquires a user operation, where the application scenario event is the first When applying a scene event, determine at least one related file that has a corresponding relationship with the scene event of the first application; read the at least one related file by using the first resource. This aspect uses the scene events of the first application to determine the relevant files needed to read the first application, and loads these relevant files in advance, so as to prepare in advance for starting the first application, so that when starting and running the first application, Quickly read related files in the file cache to improve reading speed and operating efficiency.
结合第一方面,在第一方面的另一种可能的实现中,所述配置第一资源,包括:启动后解析配置文件得到第一应用缓存的配额比例;根据当前空闲内存容量和所述第一应用缓存的配额比例计算所述第一应用的配额绝对值;将所述配额绝对值乘以预设比例得到所述第一资源的大小。本方面通过每个应用的用户标识,可以确定和配置各个应用的缓存配额比例,进而确定第一资源的大小,以便限制各个应用在读取相关文件时不超过该第一资源的大小,避免了各个应用无限制地占用文件缓存资源。With reference to the first aspect, in another possible implementation of the first aspect, the configuring the first resource includes: parsing the configuration file after startup to obtain the quota ratio of the first application cache; according to the current free memory capacity and the first application cache; An application cached quota ratio calculates the absolute value of the quota of the first application; the absolute value of the quota is multiplied by a preset ratio to obtain the size of the first resource. In this aspect, through the user identification of each application, the cache quota ratio of each application can be determined and configured, and the size of the first resource can be determined, so as to limit the size of each application not to exceed the size of the first resource when reading related files. Each application occupies unlimited file cache resources.
结合第一方面,在第一方面的又一种可能的实现中,在所述配置第一资源之前还包括:所述操作系统接收所述第一应用发送的请求消息,所述请求消息用于请求读取所述第一应用的相关文件;判断存储器RAM中是否保存有所述第一应用的相关文件;如果否,则执行所述配置所述第一资源的步骤。With reference to the first aspect, in another possible implementation of the first aspect, before the configuring the first resource, the method further includes: receiving, by the operating system, a request message sent by the first application, where the request message is used for Request to read the related file of the first application; determine whether the related file of the first application is stored in the memory RAM; if not, execute the step of configuring the first resource.
结合第一方面,在第一方面的又一种可能的实现中,所述第一应用为以下至少一种:前 台应用、第一类服务、后台应用、第二类服务;其中所述第一类服务用于为所述前台应用提供必要的服务,所述第二类服务用于为所述后台应用提供必要的服务。With reference to the first aspect, in another possible implementation of the first aspect, the first application is at least one of the following: a foreground application, a first type of service, a background application, and a second type of service; wherein the first application Class services are used to provide necessary services for the foreground application, and the second type of services are used to provide necessary services for the background application.
其中,所述某一后台应用也可以切换成前台应用,对应地,当前终端界面显示的前台应用也可以切换到后台。Wherein, the certain background application can also be switched to the foreground application, and correspondingly, the foreground application displayed on the current terminal interface can also be switched to the background.
第二方面,本申请实施例提供了一种资源管理装置,所述装置包括处理单元和获取单元,进一步地,所述处理单元用于配置第一资源,所述第一资源用于读取第一应用的相关文件,获取单元用于获取在读取所述第一应用的相关文件时所占用的第一缓存资源;所述处理单元,还用于在所述第一缓存资源的大小是否超过所述第一资源的大小情况下,确定第二资源,并在所述第一缓存资源中清除所述第二资源,使得清除所述第二资源后的剩余资源能够继续读取所述第一应用的相关文件。In a second aspect, an embodiment of the present application provides a resource management device, the device includes a processing unit and an acquiring unit, and further, the processing unit is used to configure a first resource, and the first resource is used to read the first resource. An application related file, the obtaining unit is used to obtain the first cache resource occupied when reading the related file of the first application; the processing unit is also used to determine whether the size of the first cache resource exceeds In the case of the size of the first resource, determine a second resource, and clear the second resource in the first cache resource, so that the remaining resources after clearing the second resource can continue to read the first resource. Application related files.
结合第二方面,在第二方面的一种可能的实现中,所述处理单元,具体用于根据所述第一缓存资源、待读取的所述第一应用的相关文件的大小和所述第一资源确定所述第二资源。With reference to the second aspect, in a possible implementation of the second aspect, the processing unit is specifically configured to respond to the size of the first cache resource, the size of the related file of the first application to be read, and the The first resource determines the second resource.
结合第二方面,在第二方面的一种可能的实现中,所述获取单元还用于在配置第一资源之后,获取用户操作时触发的应用场景事件;所述处理单元还用于在所述应用场景事件为所述第一应用的场景事件时,确定与所述第一应用的场景事件具有对应关系的至少一个相关文件,以及利用所述第一资源读取所述至少一个相关文件。With reference to the second aspect, in a possible implementation of the second aspect, the acquiring unit is further configured to acquire an application scenario event triggered when the user operates after the first resource is configured; the processing unit is also configured to When the application scenario event is a scenario event of the first application, determining at least one related file that has a corresponding relationship with the scenario event of the first application, and reading the at least one related file by using the first resource.
结合第二方面,在第二方面的另一种可能的实现中,所述处理单元具体用于解析配置文件得到第一应用缓存的配额比例,根据当前空闲内存容量和所述第一应用缓存的配额比例计算所述第一应用的配额绝对值,将所述配额绝对值乘以预设比例得到所述第一资源的大小。With reference to the second aspect, in another possible implementation of the second aspect, the processing unit is specifically configured to parse the configuration file to obtain the quota ratio of the first application cache, according to the current free memory capacity and the first application cache The quota ratio calculates the absolute value of the quota of the first application, and multiplies the absolute value of the quota by a preset ratio to obtain the size of the first resource.
结合第二方面,在第二方面的又一种可能的实现中,所述获取单元还用于在配置第一资源之前,接收所述第一应用发送的请求消息,所述请求消息用于请求读取所述第一应用的相关文件;所述处理单元还用于判断是否保存有所述第一应用的相关文件;如果否,则执行所述配置第一资源的步骤。With reference to the second aspect, in another possible implementation of the second aspect, the acquiring unit is further configured to receive a request message sent by the first application before configuring the first resource, where the request message is used to request Read the related file of the first application; the processing unit is also used to determine whether the related file of the first application is saved; if not, execute the step of configuring the first resource.
可选的,所述第一应用为以下至少一种:前台应用、第一类服务、后台应用、第二类服务;其中所述第一类服务用于为所述前台应用提供必要的服务,所述第二类服务用于为所述后台应用提供必要的服务。Optionally, the first application is at least one of the following: a foreground application, a first type of service, a background application, and a second type of service; wherein the first type of service is used to provide necessary services for the foreground application, The second type of service is used to provide necessary services for the background application.
第三方面,本申请实施例还提供了一种终端设备,包括收发器、处理器和存储器,所述处理器与所述存储器耦合,所述存储器用于存储指令;所述处理器用于调用所述指令使得所述网络设备执行前述第一方面以及第一方面各种实现方式中的资源管理方法。In a third aspect, an embodiment of the present application also provides a terminal device, including a transceiver, a processor, and a memory, the processor is coupled to the memory, and the memory is used to store instructions; and the processor is used to call all The instructions enable the network device to execute the foregoing first aspect and the resource management methods in various implementation manners of the first aspect.
第四方面,本申请实施例还提供了一种计算机可读存储介质,所述存储介质中存储有指令,当所述指令在计算机或处理器上运行时,用于执行前述第一方面以及第一方面各种实现方式中的方法。In a fourth aspect, the embodiments of the present application also provide a computer-readable storage medium. The storage medium stores instructions. When the instructions run on a computer or a processor, they are used to execute the aforementioned first aspect and the first aspect. On the one hand, methods in various implementations.
第五方面,本申请实施例还提供了一种计算机程序产品,所述计算机程序产品包括计算机指令,当所述指令被计算机或处理器执行时,可实现前述第一方面和第一方面各种实现方式中的方法。In the fifth aspect, the embodiments of the present application also provide a computer program product. The computer program product includes computer instructions. When the instructions are executed by a computer or a processor, the foregoing first aspect and various aspects of the first aspect can be implemented. The method in the implementation mode.
第六方面,本申请实施例还提供了一种芯片系统,所述芯片系统包括处理器和接口电路,所述接口电路与所述处理器耦合,所述处理器用于执行计算机程序或指令,以实现前述第一方面以及第一方面各种实现方式中的方法;其中所述接口电路用于与所述芯片系统之外的其它模块进行通信。In a sixth aspect, an embodiment of the present application also provides a chip system, the chip system includes a processor and an interface circuit, the interface circuit is coupled with the processor, and the processor is used to execute a computer program or instruction to The foregoing first aspect and the methods in various implementation manners of the first aspect are implemented; wherein the interface circuit is used to communicate with other modules outside the chip system.
本实施例提供的资源管理方法、装置和设备,通过对已经启动的第一应用设置门限值,即第一资源大小,且该门限值小于第一应用读取相关文件所需的总资源,进而来控制读取第 一应用的相关文件所占用的第一缓存资源大小不超过该门限值,从而避免第一应用无限制地占用缓存资源而影响其他应用程序的运行使用,本方法有效地限制了系统中的某一应用,比如前台应用或后台应用的内存占用大小,合理地管理了系统中各个应用的文件缓存资源,并提高文件缓存资源的使用率。The resource management method, device, and device provided in this embodiment set a threshold value for the first application that has been started, that is, the first resource size, and the threshold value is less than the total resources required by the first application to read related files , So as to control the size of the first cache resource occupied by reading related files of the first application not to exceed the threshold, so as to prevent the first application from occupying the cache resource unlimitedly and affecting the operation and use of other applications. This method is effective It limits the memory usage of a certain application in the system, such as the foreground application or the background application, reasonably manages the file cache resources of each application in the system, and improves the utilization rate of file cache resources.
另外,本方法在手机终端中进行文件缓存主动式管理,从而优先保证前台应用所使用的文件缓存资源,并在后台应用切换到前台时,快速恢复应用所需的文件缓存,从而提高了应用的文件输入输出效率,提高了用户体验。In addition, this method performs active management of file cache in the mobile phone terminal, so as to give priority to ensuring the file cache resources used by the foreground application, and quickly restore the file cache required by the application when the background application is switched to the foreground, thereby improving application performance File input and output efficiency improves user experience.
附图说明Description of the drawings
图1为本申请实施例提供的一种计算机系统的结构示意图;FIG. 1 is a schematic structural diagram of a computer system provided by an embodiment of this application;
图2为本申请实施例提供的一种资源管理方法的流程图;2 is a flowchart of a resource management method provided by an embodiment of the application;
图3为本申请实施例提供的一种配置文件缓存的装置结构示意图;3 is a schematic structural diagram of a configuration file caching apparatus provided by an embodiment of the application;
图4为本申请实施例提供的另一种资源管理方法的流程图;Figure 4 is a flowchart of another resource management method provided by an embodiment of the application;
图5为本申请实施例提供的一种配置文件缓存配额的流程图;FIG. 5 is a flowchart of configuring file cache quota according to an embodiment of the application;
图6为本申请实施例提供的另一种配置文件缓存的装置结构示意图;FIG. 6 is a schematic structural diagram of another configuration file caching apparatus provided by an embodiment of this application;
图7为本申请实施例提供的一种资源管理装置的结构示意图;FIG. 7 is a schematic structural diagram of a resource management device provided by an embodiment of the application;
图8为本申请实施例提供的一种终端设备的结构示意图。FIG. 8 is a schematic structural diagram of a terminal device provided by an embodiment of the application.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本申请实施例中的技术方案,并使本申请实施例的上述目的、特征和优点能够更加明显易懂,对本申请实施例中的技术方案作详细的说明。In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, and to make the above objectives, features, and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are described in detail Description.
在对本申请的技术方案进行说明之前,首先对本申请实施例中技术方案应用的技术场景和相关技术术语进行介绍。Before describing the technical solution of the present application, the technical scenarios and related technical terms applied in the embodiments of the present application are first introduced.
如图1所示,本申请实施例的技术方案可应用于现代计算机系统,所述计算机系统主要包括以下组成部分:输入设备:如键盘、鼠标,用户通过该设备输入数据和程序;存储器:如内存、硬盘,用于记忆程序、数据、中间结果及最终运算结果;运算器:通常集成在CPU中,支持各种计算,可以对数据进行加工处理;控制器:通常集成在CPU中,控制程序执行;输出设备:如显示器、打印机,将数据的处理结果输出给用户。As shown in Figure 1, the technical solution of the embodiment of the present application can be applied to a modern computer system. The computer system mainly includes the following components: input device: such as keyboard and mouse, through which the user inputs data and programs; memory: such as Memory, hard disk, used to memorize programs, data, intermediate results, and final calculation results; arithmetic unit: usually integrated in the CPU, support various calculations, and can process data; controller: usually integrated in the CPU to control the program Execution; output devices: such as monitors and printers, which output data processing results to users.
其中,存储器可用于保存着海量的程序和数据。存储器可分为主存储器和辅助存储器。主存储器又称内存储器(简称内存),辅助存储器又称外存储器(简称外存)。进一步地,所谓的“内存”和“外存”是从CPU角度来看的。具体地,内存离CPU的距离近,由专用高速通道连接,全部是集成电路、访问速度快,所以CPU所执行的程序代码以及操作的目标数据都是直接从内存中获取的。但内存的容量小且没有数据持久性,一旦关闭电源或发生断电,其中的程序和数据就会丢失。Among them, the memory can be used to store a large amount of programs and data. The memory can be divided into main memory and auxiliary memory. The main storage is also called internal storage (referred to as memory), and the auxiliary storage is also called external storage (referred to as external storage). Furthermore, the so-called "memory" and "external memory" are viewed from the perspective of the CPU. Specifically, the memory is close to the CPU and is connected by a dedicated high-speed channel. It is all integrated circuits and has a fast access speed. Therefore, the program code executed by the CPU and the target data of the operation are directly obtained from the memory. But the capacity of the memory is small and there is no data persistence. Once the power is turned off or there is a power failure, the programs and data in it will be lost.
外存的特点与内存相反。它与CPU的距离较远,一般由低速通道连接,另外还可以包括机械部件,外存的访问速度缓慢;但是容量大并且不怕断电,能长期保存信息。可选的,所述外存包括硬盘、磁带、DVD、U盘、固态盘等。The characteristics of external memory are opposite to those of memory. It is far away from the CPU, generally connected by a low-speed channel, and can also include mechanical parts, and the access speed of the external memory is slow; but it has a large capacity and is not afraid of power failure, and can store information for a long time. Optionally, the external storage includes hard disk, magnetic tape, DVD, U disk, solid state disk, etc.
一般地,所述外存用于存储用户的程序和数据,当用户启动执行某个应用程序时,操作系统会先将该应用程序的相关文件从外存装载到内存中,然后再通过CPU来执行。由于外存的访问速度低,所以为了减少访问外存的次数,提高输入/输出(Input/Output,I/O)效率,操作系统会分配一批内存或内存资源,专门用于存储访问过应用程序的相关文件。这样当应 用程序再次读取这些文件时,就可以从内存中直接获取,避免再从外存中读取,速度慢。其中,所述提前分配的内存或内存资源可称为“文件缓存”,可选的,在Linux中也可称为“页面缓存”(page cache)。Generally, the external memory is used to store the user’s programs and data. When the user starts to execute an application, the operating system will first load the relevant files of the application from the external memory into the memory, and then use the CPU to carried out. Due to the low access speed of external memory, in order to reduce the number of accesses to external memory and improve input/output (Input/Output, I/O) efficiency, the operating system will allocate a batch of memory or memory resources specifically for storing accessed applications Related documents of the program. In this way, when the application program reads these files again, it can be directly obtained from the memory, avoiding reading from the external memory again, which is slow. Wherein, the memory or memory resources allocated in advance may be referred to as "file cache", and optionally, it may also be referred to as "page cache" in Linux.
由于内存的容量资源有限,除了存储相关文件之外,还要存储操作系统以及应用程序的数据,不可能装下外存中的所有文件,因此需要对文件缓存进行管理,当操作系统在检测到内存资源不足时,会进行文件回收,从而淘汰掉一些文件缓存,腾出部分空间。目前,Linux系统采用的文件缓存管理算法是类最近最少使用(Least Recently Used,LRU)算法,或者称为最近最少使用算法,该算法指示操作系统将文件缓存中最近很少访问的数据删除,从而可以优先回收其内存资源,腾出空间来加载更有价值的数据。Due to the limited capacity of memory resources, in addition to storing related files, it also stores operating system and application data. It is impossible to install all the files in the external memory. Therefore, the file cache needs to be managed. When the operating system detects When memory resources are insufficient, file recycling will be performed, thereby eliminating some file caches and freeing up some space. At present, the file cache management algorithm adopted by the Linux system is the Least Recently Used (LRU) algorithm, or the least recently used algorithm, which instructs the operating system to delete data that is rarely accessed recently in the file cache. The memory resources can be recycled first to make room to load more valuable data.
但是,当前的Linux文件缓存策略,前台应用和后台应用程序在文件缓存的使用上享有同等权利。即一个后台应用程序在下载文件时会无限制地从网络中获取网络资源,并占用手机的内存资源,甚至可能会导致整个系统的文件缓存中只剩下这个应用相关文件,影响其它的应用程序使用,比如前台应用程序的文件加载,影响用户体验。However, with the current Linux file caching strategy, foreground applications and background applications have equal rights in the use of file caching. That is to say, when a background application downloads files, it will obtain network resources from the network without restrictions, and occupy the memory resources of the phone. It may even cause only the application-related files in the file cache of the entire system to affect other applications. Use, such as loading files of foreground applications, affects user experience.
本实施例提供了一种文件缓存方法,该方法可以针对性地对前台应用和多个后台应用程序采取不同的资源保障策略,提高文件缓存的使用效率。例如,在安卓(Android)系统中,每个第三方应用都具有自己唯一的标识,例如用户ID(user ID或uid),该用户ID也可以是传统Unix的用户标识。当操作系统分配文件缓存时,需要记录并检查该内存页面所归属用户ID,如果此用户ID占用的文件缓存已经达到上限,则不再为该应用提供内存资源,从而避免某个应用程序无限制地占用缓存资源而影响其他应用程序的正常运行。This embodiment provides a file caching method, which can specifically adopt different resource guarantee strategies for foreground applications and multiple background applications, and improve the efficiency of file caching. For example, in the Android system, each third-party application has its own unique identifier, such as a user ID (user ID or uid), which can also be a traditional Unix user ID. When the operating system allocates file cache, it needs to record and check the user ID that the memory page belongs to. If the file cache occupied by this user ID has reached the upper limit, it will no longer provide memory resources for the application, thereby avoiding unlimited application Occupies cache resources and affects the normal operation of other applications.
需要说明的是,本实施例所述的系统或者操作系统(operatiing system,OS),对于安卓系统而言,可以是Linux系统;对于苹果系统而言,则可以是IOS系统。另外,还可以是其他的系统,本实施例对此不予限制。It should be noted that the system or operating system (OS) described in this embodiment may be a Linux system for an Android system, and may be an IOS system for an Apple system. In addition, it may also be other systems, which are not limited in this embodiment.
本实施例提供的方法,是基于每个应用的唯一用户标识,系统来为每个应用分配和管理文件缓存的配额(设置上限),从而控制各个应用所用的文件缓存资源,达到管理和限制各个应用占用缓存资源的目的。The method provided in this embodiment is based on the unique user identification of each application. The system allocates and manages the file cache quota (set upper limit) for each application, so as to control the file cache resources used by each application to manage and limit each application. The purpose of the application occupying cache resources.
下面对本申请提供的方法进行详细地介绍。The method provided in this application is described in detail below.
参见图2,本实施例提供了一种资源管理方法,该方法可以由终端的系统或操作系统执行,具体地,所述方法包括:Referring to FIG. 2, this embodiment provides a resource management method, which may be executed by the system or operating system of the terminal. Specifically, the method includes:
步骤101:接收第一应用发送的第一请求消息,所述第一请求消息用于请求读取第一应用的相关文件。所述相关文件包括:运行第一应用必要的数据文件(图片)或程序文件,进一步地,所述数据文件包括图片、音频文件、视频文件等,所述程序文件包括执行该程序的代码或计算机程序。Step 101: Receive a first request message sent by a first application, where the first request message is used to request to read related files of the first application. The related files include: data files (pictures) or program files necessary to run the first application. Further, the data files include pictures, audio files, video files, etc., and the program files include code or computer to execute the program. program.
具体地,如图3所示,用户触发或启动第一应用,所述第一应用发送第一请求消息给系统;其中所述系统中包括文件缓存和文件系统,进一步地,所述文件缓存为系统预先分配一批内存或内存资源,用于承载第一应用的相关文件。Specifically, as shown in FIG. 3, a user triggers or starts a first application, and the first application sends a first request message to the system; wherein the system includes a file cache and a file system, and further, the file cache is The system allocates a batch of memory or memory resources in advance to carry related files of the first application.
其中,所述第一应用可以是以下至少一种:前台应用(foreground application)、第一类服务、后台应用(background application)、第二类服务,其中所述第一类服务用于为前台应用提供必要的服务;所述第二类服务用于为后台应用提供必要的服务。可选的,所述第一类服务为A类服务(A_services),所述第二类服务为B类服务(B_services)。Wherein, the first application may be at least one of the following: foreground application, first type of service, background application, second type of service, wherein the first type of service is used for foreground application Provide necessary services; the second type of service is used to provide necessary services for background applications. Optionally, the first type of service is a type A service (A_services), and the second type of service is a type B service (B_services).
进一步地,所述前台应用是终端设备的屏幕当前显示并运行的应用程序,即所述屏幕显示给用户的应用的界面。所述后台应用是在系统后台运行的应用程序,该应用程序的界面不 显示和呈现给用户。其中,所述后台应用可以是用户之前使用的应用并切换到了后台,并且随时可能被切换到前台,通过屏幕界面显示给用户。另外,所述A类服务和B类服务没有界面,它们是为有界面的前台应用或后台应用提供专项服务的进程或者线程,比如提供全球定位系统(Global Positioning System,GPS)定位服务、音频播放服务等。Further, the foreground application is an application currently displayed and running on the screen of the terminal device, that is, an interface of the application displayed to the user on the screen. The background application is an application program running in the background of the system, and the interface of the application program is not displayed and presented to the user. Wherein, the background application may be an application previously used by the user and switched to the background, and may be switched to the foreground at any time, and displayed to the user through a screen interface. In addition, the Type A service and Type B service do not have an interface. They are processes or threads that provide special services for front-end applications or back-end applications with interfaces, such as providing Global Positioning System (GPS) positioning services and audio playback. Service etc.
在这些应用的优先级中,前台应用的优先级高于后台应用,对应地,A类服务的优先级高于B类服务,所以在当内存不足时,优先回收和清理后台应用和B类服务的文件缓存,保证前台应用和A类服务的正常运行。Among the priorities of these applications, the foreground application has a higher priority than the background application. Correspondingly, the priority of the A service is higher than the B service, so when the memory is insufficient, the background application and the B service are first recycled and cleaned. File cache to ensure the normal operation of foreground applications and Class A services.
另外,还包括:系统实时地获取第一应用发送的请求消息,所述请求消息中包括待读取的文件的相关信息,例如包括文件名、文件地址和文件大小等。In addition, it also includes: the system obtains the request message sent by the first application in real time, and the request message includes related information of the file to be read, such as the file name, file address, and file size.
步骤102:判断是否保存有所述第一应用的相关文件。Step 102: Determine whether relevant files of the first application are stored.
进一步地,系统在内存储器(比如RAM)中检测是否保存有第一应用的相关文件。Further, the system detects whether relevant files of the first application are stored in the internal memory (such as RAM).
可选的,步骤102中的判断过程可以由图3所示的配额管理模块来实现。Optionally, the judgment process in step 102 may be implemented by the quota management module shown in FIG. 3.
步骤103:如果是,则将所述第一应用的相关文件发送给第一应用,使得所述第一应用可以快速启动和运行。Step 103: If yes, send related files of the first application to the first application, so that the first application can be quickly started and run.
步骤104:如果否,则配置第一资源及利用第一资源读取所述第一应用的相关文件。具体地,如图4所示,步骤104具体包括:Step 104: If not, configure the first resource and use the first resource to read related files of the first application. Specifically, as shown in FIG. 4, step 104 specifically includes:
步骤1041:系统配置第一资源,所述第一资源用于读取第一应用的相关文件。Step 1041: The system configures a first resource, and the first resource is used to read related files of the first application.
并且所述第一资源的大小小于用于读取第一应用的相关文件所占用的总资源大小。In addition, the size of the first resource is smaller than the total resource size occupied by the relevant file for reading the first application.
可选的,所述第一资源又可称为第一文件缓存。Optionally, the first resource may also be referred to as a first file cache.
具体地,配置所述第一资源的过程包括:首先,系统启动后解析配置文件得到第一应用的缓存配额比例,然后根据当前空闲内存容量和所述第一应用缓存的配额比例计算所述第一应用的配额绝对值,最后将所述配额绝对值乘以预设比例得到所述第一资源的大小。Specifically, the process of configuring the first resource includes: first, after the system is started, the configuration file is parsed to obtain the cache quota ratio of the first application, and then the first application cache quota ratio is calculated according to the current free memory capacity and the first application cache quota ratio. An absolute value of an applied quota is finally multiplied by a preset ratio to obtain the size of the first resource.
其中,所述配置文件中包括每个应用的用户ID与至少一个缓存配额比例之间的对应关系,所述缓存配额比例可以是系统预先设置好的,即建立每个应用的用户ID与一个缓存配额比例之间的对应关系。例如图5所示,系统启动后解析配置文件,配置每个应用的用户ID所对应的缓存配额比例为,前台应用、后台应用、A类服务、B类服务各自对应的缓存配额比例分别是:60%、10%、20%、10%。假设所述系统当前空闲(可用)内存大小为1G(本实施例以1G=1000M为例),根据所述对应关系计算各个应用的配额绝对值,分别是:600M、100M、200M、100M。设所述预设比例为80%,则每个应用的配额绝对值乘以所述预设比例后得到第一资源的大小分别是:480M、80M、160M、80M。Wherein, the configuration file includes the correspondence between the user ID of each application and at least one cache quota ratio. The cache quota ratio may be preset by the system, that is, the user ID of each application and a cache are established. Correspondence between quota ratios. For example, as shown in Figure 5, after the system is started, the configuration file is parsed and the cache quota ratio corresponding to the user ID of each application is configured. The corresponding cache quota ratios of the foreground application, background application, type A service, and type B service are respectively: 60%, 10%, 20%, 10%. Assuming that the current free (available) memory size of the system is 1G (in this embodiment, 1G=1000M is taken as an example), the absolute value of the quota of each application is calculated according to the corresponding relationship, which are respectively: 600M, 100M, 200M, and 100M. Assuming that the preset ratio is 80%, the absolute value of the quota of each application is multiplied by the preset ratio to obtain the size of the first resource: 480M, 80M, 160M, and 80M.
可选的,所述预设比例还可以是其他比值,本实施例对此不进行限定。Optionally, the preset ratio may also be another ratio, which is not limited in this embodiment.
步骤1042:获取在读取所述第一应用的相关文件时所占用的第一缓存资源。Step 1042: Obtain the first cache resource occupied when reading the related file of the first application.
其中,所述获取所述第一缓存资源是系统动态实时地获取过程,或者每经过一个时间间隔获取一次第一缓存资源。Wherein, the obtaining of the first cache resource is a process of obtaining the first cache resource dynamically by the system in real time, or the first cache resource is obtained once every time interval has elapsed.
进一步地,操作系统内核可以掌控系统资源的使用情况,并每个应用进程占用的资源都进行了记账,包括使用的内存资源、打开的文件等。以Linux系统为例,当开启“内存资源控制(Memory Resource Controller)”功能时,各应用进程在申请或释放文件缓存时,都会记录在系统中,因此操作系统可随时获取各应用进程(包括第一应用)对文件缓存的占用值,即所述第一缓存资源的大小。Further, the operating system kernel can control the usage of system resources, and the resources occupied by each application process are accounted for, including used memory resources, open files, and so on. Taking the Linux system as an example, when the "Memory Resource Controller" function is enabled, each application process will be recorded in the system when applying for or releasing the file cache, so the operating system can obtain each application process (including the first One application) The occupied value of the file cache, that is, the size of the first cache resource.
步骤1043:如果所述第一缓存资源的大小超过所述第一资源的大小,则确定第二资源,并在所述第一缓存资源中清除所述第二资源,使得清除所述第二资源后的剩余资源继续读取 第一应用的相关文件。Step 1043: If the size of the first cache resource exceeds the size of the first resource, determine a second resource, and clear the second resource in the first cache resource, so that the second resource is cleared The remaining resources after that continue to read related files of the first application.
所述超过第一资源大小可理解为,当前读取第一应用的相关文件所占用的资源大于所述第一资源的大小。The exceeding of the first resource size may be understood as a resource currently occupied by reading related files of the first application greater than the size of the first resource.
此外,所述确定第二资源,包括:根据所述第一缓存资源、待读取的所述第一应用的相关文件的大小和所述第一资源确定所述第二资源。进一步地,所述第二资源大小=第一缓存资源大小+待读取的所述第一应用的相关文件的大小-第一资源大小,并且步骤1043中所述清除的资源大小不小于所述第二资源的大小。例如第一资源的大小为80M,当前检测的第一缓存资源大小为100M,且待读取的相关文件大小为5M,则确定所述第二资源的大小为25M。(100+5-80=25M),则在第一缓存资源中清除的资源大小至少为25M。In addition, the determining the second resource includes: determining the second resource according to the first cache resource, the size of the related file of the first application to be read, and the first resource. Further, the second resource size=the first cache resource size+the size of the related file of the first application to be read-the first resource size, and the size of the resource cleared in step 1043 is not less than the The size of the second resource. For example, the size of the first resource is 80M, the currently detected size of the first cache resource is 100M, and the size of the related file to be read is 5M, it is determined that the size of the second resource is 25M. (100+5-80=25M), the size of the resource cleared in the first cache resource is at least 25M.
进一步地,所述待读取的所述第一应用的相关文件的大小可以通过第一请求消息来确定。比如系统实时地获取第一应用发送的第一请求消息,所述第一请求消息中包括待读取文件的文件名、地址和文件大小,系统接收该第一请求消息之后根据其中包括的内容确定待读取文件的大小,进而确定还需要的占用的资源大小。另外,还可以通过其他方式获取待读取文件的大小,本实施例对此不予限制。Further, the size of the related file of the first application to be read may be determined through a first request message. For example, the system obtains the first request message sent by the first application in real time. The first request message includes the file name, address, and file size of the file to be read. After the system receives the first request message, it determines according to the content contained therein. The size of the file to be read is used to determine the size of the resources that are still needed. In addition, the size of the file to be read can also be obtained in other ways, which is not limited in this embodiment.
可选的,方法还包括:如果当前检测所述第一缓存资源的大小小于等于所述第一资源的大小,即当前读取第一应用的相关文件所占用的资源小于所述配置的第一资源大小,则继续利用第一缓存资源读取第一应用的相关文件。Optionally, the method further includes: if it is currently detected that the size of the first cache resource is less than or equal to the size of the first resource, that is, the resource currently occupied by reading related files of the first application is less than the configured first resource. Resource size, continue to use the first cache resource to read related files of the first application.
本实施例提供的方法,通过对已经启动的第一应用设置门限值,即第一资源,且该门限值小于第一应用读取相关文件所需的总资源,进而来控制读取第一应用的相关文件所占用的第一缓存资源大小不超过该门限值,从而避免第一应用无限制地占用缓存资源而影响其他应用程序的运行使用,本方法有效地限制了系统中的某一应用,比如前台应用或后台应用的内存占用大小,合理地管理了系统中各个应用的文件缓存资源,并提高文件缓存资源的使用率。In the method provided in this embodiment, the threshold value, that is, the first resource, is set for the first application that has been started, and the threshold value is less than the total resources required by the first application to read related files, thereby controlling the reading of the first application. The size of the first cache resource occupied by the related files of an application does not exceed the threshold, thereby preventing the first application from occupying the cache resources without limitation and affecting the operation and use of other applications. This method effectively limits certain systems in the system. An application, such as the memory footprint of a foreground application or a background application, reasonably manages the file cache resources of each application in the system and improves the utilization rate of file cache resources.
在具体的实现中,本实施例以第一应用为后台应用,所述第一资源为该后台应用和B类服务为例进行说明。如图5所示,系统启动后解析配置文件得到后台应用和B类服务的缓存配额比例分别是10%、10%。然后根据系统空闲内容容量1G计算后台应用和B类服务的配额绝对值的大小均为100M,按照预设比例80%计算该后台应用和B类服务的第一资源大小均为80M。系统在某一时刻检测该后台应用所占用的第一缓存资源为100M,B类服务所占用的第一缓存资源为200M,两者均超过个各自配置的第一资源大小(80M),所以确定并清除第二资源,所述第二资源可以是在第一缓存资源中在先缓存的文件所占的资源,并对该第二资源进行回收,比如第二资源为80M,回收后使得该后台应用占用的文件缓存为20M,该B类服务占用的文件缓存为30M,均低于配置的第一资源大小80M,所以回收后该后台应用和B类服务可以继续使用文件缓存读取相关文件。In a specific implementation, this embodiment takes the first application as a background application, and the first resource as an example of the background application and type B service. As shown in Figure 5, after the system is started, the cache quota ratios of back-end applications and class B services obtained by analyzing the configuration file are 10% and 10%, respectively. Then calculate the absolute value of the quota of the background application and the category B service according to the system's free content capacity of 1G to be 100M, and calculate the first resource size of the background application and the category B service to be 80M according to a preset ratio of 80%. The system detects at a certain moment that the first cache resource occupied by the background application is 100M, and the first cache resource occupied by type B services is 200M, both of which exceed the first resource size (80M) configured respectively, so it is determined And clear the second resource. The second resource may be the resource occupied by the file that was previously cached in the first cache resource, and the second resource is recycled. For example, the second resource is 80M. The file cache occupied by the application is 20M, and the file cache occupied by the B-type service is 30M, which is lower than the configured first resource size of 80M. Therefore, the background application and the B-type service can continue to use the file cache to read related files after recovery.
具体地,一种对所述对文件进行回收的方式是,选择第一缓存资源中在前加载的文件,将其拷贝到外存储器中,然后再删除该部分文件,以便腾出部分资源使第一缓存资源小于对应的第一资源大小。Specifically, one way of recovering the file is to select the file loaded in the first cache resource, copy it to the external storage, and then delete the part of the file, so as to free up some resources for the first time. A cache resource is smaller than the corresponding first resource size.
可选的,该方法还包括:设置定时器,以触发配额的周期计算、各个应用的文件缓存的周期性检测和回收。例如当定时器达到预定时刻时,系统根据当前空闲内存大小,计算各个应用的配额绝对值,以及分配更新的第一资源大小;并且检测当前各个应用所占的第一缓存资源大小超过该更新的第一资源,则对该应用在前加载的文件所占的第二资源进行回收。并且在回收完成之后,重新设置定时器。Optionally, the method further includes: setting a timer to trigger periodic calculation of the quota, periodic detection and recycling of the file cache of each application. For example, when the timer reaches a predetermined time, the system calculates the absolute value of each application quota according to the current free memory size and allocates the updated first resource size; and detects that the current first cache resource size occupied by each application exceeds the updated first resource size The first resource is to recover the second resource occupied by the file previously loaded by the application. And after the recovery is complete, reset the timer.
另外,本实施例中,方法还包括:系统判断前台应用和A类服务各自占用的第一缓存资 源是否超过对应的第一资源,由于该前台应用和A类服务当前检测的第一缓存资源大小均未超过第一资源大小,所以还可以继续读取前台应用和A类服务的相关文件。具体地检测和回收方法与前述后台应用和B类服务回收过程相同,此处不再赘述。In addition, in this embodiment, the method further includes: the system determines whether the first cache resource occupied by the foreground application and the type A service each exceeds the corresponding first resource, because the first cache resource size currently detected by the foreground application and the type A service None of them exceed the size of the first resource, so you can continue to read related files of foreground applications and Class A services. The specific detection and recovery method is the same as the foregoing background application and type B service recovery process, and will not be repeated here.
本实施例提供的方法,在手机终端中进行文件缓存主动式管理,从而优先保证前台应用所使用的文件缓存资源,并在后台应用切换到前台时,快速恢复应用所需的文件缓存,从而提高了应用的文件输入输出效率,提高了用户体验。The method provided in this embodiment implements active file cache management in the mobile phone terminal, thereby prioritizing the file cache resources used by the foreground application, and quickly restores the file cache required by the application when the background application is switched to the foreground, thereby improving This improves the application’s file input and output efficiency and improves user experience.
可选的,在上述步骤1042,利用所述第一资源读取所述第一应用的相关文件的过程中,还包括系统提前加载所述相关文件的步骤,从而使得该第一应用在启动时能够快速地读取和运行,提高第一应用的启动速度和运行流畅度。具体地,一种可能的实现是,系统获取用户操作时触发的应用场景事件,其中预先每个应用都对应一个应用场景事件,在所述应用场景事件为所述第一应用的场景事件时,确定与所述第一应用的场景事件具有对应关系的至少一个相关文件,利用所述第一资源提前读取所述至少一个相关文件。Optionally, in the above step 1042, the process of using the first resource to read the related file of the first application further includes the step of loading the related file in advance by the system, so that the first application can be It can read and run quickly, improving the startup speed and running fluency of the first application. Specifically, one possible implementation is that the system acquires application scenario events triggered when a user operates, where each application corresponds to an application scenario event in advance, and when the application scenario event is a scenario event of the first application, Determine at least one related file that has a corresponding relationship with the scene event of the first application, and use the first resource to read the at least one related file in advance.
进一步地,如图6所示,系统提前读取第一应用的相关文件的过程包括:系统的检测模块检测用户操作手机终端时触发的应用请求,所述应用请求用于触发所述第一应用的应用场景事件,所述第一应用的应用场景事件包括:用户初次启动第一应用程序、例如打开第一应用的某个窗口等。装载管理模块接收所述检测模块发送的应用请求,并查找是否有存储该第一应用所需的相关文件的文件缓存;如果否,则配额管理模块对该第一应用配置第一资源,并从外存储器中获取该第一应用的相关文件,在从外存储器中获取该相关文件的过程中,Further, as shown in FIG. 6, the process of reading related files of the first application in advance by the system includes: the detection module of the system detects an application request triggered when the user operates the mobile phone terminal, and the application request is used to trigger the first application The application scenario event of the first application includes: the user starts the first application for the first time, for example, opens a window of the first application. The loading management module receives the application request sent by the detection module, and finds whether there is a file cache storing related files required by the first application; if not, the quota management module configures the first resource for the first application, and then The related files of the first application are obtained from the external storage. In the process of obtaining the related files from the external storage,
配额管理模块检测当前获取所述第一应用的相关文件所占用的第一缓存资源是否超过预设门限值(即第一资源大小),如果超过,则向文件系统发起对外存储器的读取所述相关文件动作,所述文件系统从外存储器获取所述相关文件之后,将这些相关文件存储在文件缓存中,以便当第一应用启动时,系统可以直接将该文件缓存中的第一应用的相关文件提供给第一应用,避免再从外存储器中获取,本方法由于文件缓存在内存储器,所有提高了读取速度,加快第一应用的运行效率。The quota management module detects whether the first cache resource currently occupied by the relevant file of the first application exceeds a preset threshold (that is, the size of the first resource), and if it exceeds, it initiates an external memory reading to the file system. For the related file actions, after the file system obtains the related files from the external storage, these related files are stored in the file cache, so that when the first application starts, the system can directly cache the files of the first application in the file cache. Relevant files are provided to the first application to avoid obtaining them from the external memory. This method improves the reading speed and speeds up the operating efficiency of the first application due to the file cache in the internal memory.
更进一步地,所述方法包括:当用户操作手机终端时,触发第一应用请求,所述第一应用请求启动文件访问需求配置文件,并确定第一应用的应用场景事件,以及所述应用场景事件所对应的至少一个相关文件。Further, the method includes: when the user operates the mobile phone terminal, triggering a first application request, the first application requesting to start a file access requirement configuration file, and determining the application scenario event of the first application, and the application scenario At least one related file corresponding to the event.
其中,所述文件访问需求配置文件中包括至少一个对应关系,所述对应关系为应用场景事件与至少一个相关文件之间的对应关系。例如第一应用场景事件对应相关文件a、b,第二应用场景事件对应相关文件c。所述相关文件a、b或c为运行某一应用时需要频繁读取的热门文件,例如,当第一应用初次启动时,需要读取文件a和b;当第二应用启动打开某一窗口界面时,需要读取文件c。Wherein, the file access requirement configuration file includes at least one corresponding relationship, and the corresponding relationship is a corresponding relationship between an application scenario event and at least one related file. For example, the first application scenario event corresponds to related files a and b, and the second application scenario event corresponds to related file c. The related files a, b, or c are popular files that need to be read frequently when running a certain application, for example, when the first application is started for the first time, files a and b need to be read; when the second application is started, a certain window is opened In the interface, file c needs to be read.
系统的检测模块在检测到第一应用请求后,得到第一应用所关联的第一应用的应用场景事件,然后根据该第一应用的应用场景事件和所述文件访问需求配置文件中的对应关系确定其对应的相关文件。例如所述检测模块确定当前第一应用场景事件所对应的是相关文件a和b,则发送第一指示信息给装载管理模块,所述第一指示信息用于指示获取相关文件a和b。After detecting the first application request, the detection module of the system obtains the application scenario event of the first application associated with the first application, and then according to the application scenario event of the first application and the corresponding relationship in the file access requirement configuration file Determine its corresponding related documents. For example, the detection module determines that the current first application scenario event corresponds to related files a and b, and then sends first indication information to the load management module, where the first indication information is used to instruct to obtain related files a and b.
装载管理模块接收所述第一指示信息并从文件系统中获取该相关文件a和b,在读取相关文件a和b的过程中,利用配额管理模块实时检测相关文件a和b所占用的第一缓存资源是否超过预设的第一资源(配额门限值),如果超过则进行文件缓存的回收操作,以便限制第一缓存资源的大小,防止读取相关文件a和b无限制地占用内存资源。The loading management module receives the first instruction information and obtains the related files a and b from the file system. In the process of reading the related files a and b, the quota management module is used to detect in real time the first occupied files a and b. 1. Whether the cache resource exceeds the preset first resource (quota threshold), if it exceeds, the file cache recovery operation is performed to limit the size of the first cache resource and prevent reading related files a and b from occupying memory without limitation Resources.
可选的,上述实施例所述提前加载文件的过程,可以包括为以下步骤:Optionally, the process of loading files in advance described in the foregoing embodiment may include the following steps:
1、系统启动后设置定时器,以定期的加载第一应用的配置文件;1. Set a timer after the system is started to periodically load the configuration file of the first application;
2、定时器到达预设时刻时,系统根据当前空闲容量大小确定是否对第一应用的相关文件进行提前加载;2. When the timer reaches the preset time, the system determines whether to load the relevant files of the first application in advance according to the current free capacity;
3、如果是,则确定需要提前加载的第一应用的应用场景事件;3. If yes, determine the application scenario event of the first application that needs to be loaded in advance;
4、解析文件访问需求配置文件,例如Android Manifest.xml中的配置文件信息,获取第一应用关联的至少一个相关文件,所述至少一个相关文件以文件列表的形式展示;4. Parse the file access requirement configuration file, such as the configuration file information in Android Manifest.xml, to obtain at least one related file associated with the first application, and the at least one related file is displayed in the form of a file list;
5、将所述文件列表中至少一个相关文件加载到文件缓存(内存RAM中)。5. Load at least one related file in the file list into the file cache (in the memory RAM).
另外,当所述文件列表中的所有文件都加载完成后,重新设置定时器。In addition, after all files in the file list are loaded, the timer is reset.
本实施例提供的方法包括以下有益效果:The method provided in this embodiment includes the following beneficial effects:
第一、系统基于应用的唯一用户标识来分配和管理文件缓存配额,从而设置每个应用占用的文件缓存的资源大小,从而避免每个应用在读取相关文件时无限制地占用内存资源,影响其他应用的运行。First, the system allocates and manages file cache quotas based on the unique user identification of the application, thereby setting the resource size of the file cache occupied by each application, so as to prevent each application from occupying memory resources unlimitedly when reading related files, which affects The operation of other applications.
第二、系统根据应用的角色(前台应用、后台应用、A类服务、B类服务),结合系统当前空闲的内存容量,为每个应用配置相应的第一资源,从而使得系统的总内存资源合理地分配给不同的利用,例如对于前台应用和A类服务享有的缓存资源高于后台应用和B类服务,从而提高用户体验。Second, the system configures the corresponding first resource for each application according to the role of the application (foreground application, background application, type A service, type B service), combined with the current free memory capacity of the system, so as to make the total memory resource of the system Reasonably allocate to different uses, for example, the cache resources enjoyed by foreground applications and type A services are higher than those of background applications and type B services, thereby improving user experience.
参见图7,为本实施例提供的一种资源管理装置,该装置用于实现前述实施例中的方法。具体地,所述装置包括:获取单元701和处理单元702,此外,所述装置还可以包括更多单元,例如发送单元、存储单元等,本实施例对此不予限制。Referring to FIG. 7, a resource management device provided by this embodiment is used to implement the method in the foregoing embodiment. Specifically, the device includes: an obtaining unit 701 and a processing unit 702. In addition, the device may also include more units, such as a sending unit, a storage unit, etc., which are not limited in this embodiment.
具体地,处理单元702用于配置第一资源,所述第一资源用于读取第一应用的相关文件,其中所述第一资源小于读取第一应用相关文件所占用的总资源;获取单元701用于获取在读取所述第一应用的相关文件时所占用的第一缓存资源;所述处理单元701还用于在所述第一缓存资源的大小超过所述第一资源的大小的情况下,确定第二资源,并在所述第一缓存资源中清除所述第二资源,使得清除所述第二资源后的剩余资源能够继续读取第一应用相关文件。Specifically, the processing unit 702 is configured to configure a first resource, where the first resource is used to read related files of the first application, where the first resource is less than the total resources occupied by reading the related files of the first application; The unit 701 is configured to obtain the first cache resource occupied when the related file of the first application is read; the processing unit 701 is also configured to: when the size of the first cache resource exceeds the size of the first resource In the case of determining the second resource, and clearing the second resource in the first cache resource, so that the remaining resources after clearing the second resource can continue to read the first application related file.
其中,所述第一应用为以下至少一种:前台应用、第一类服务、后台应用、第二类服务。其中所述第一类服务用于为所述前台应用提供必要的服务,所述第二类服务用于为所述后台应用提供必要的服务。可选的,所述第一类服务为A类服务,所述第二类服务为B类服务。Wherein, the first application is at least one of the following: foreground application, first type service, background application, second type service. The first type of service is used to provide necessary services for the foreground application, and the second type of service is used to provide necessary services for the background application. Optionally, the first type of service is a type A service, and the second type of service is a type B service.
可选的,在本实施例的一种具体的实现方式中,所述处理单元702具体用于根据所述第一缓存资源、待读取的所述第一应用的相关文件的大小和所述第一资源确定所述第二资源。Optionally, in a specific implementation manner of this embodiment, the processing unit 702 is specifically configured to determine the size of the related file of the first application to be read according to the first cache resource, and the The first resource determines the second resource.
可选的,在本实施例的一种具体的实现方式中,所述获取单元701还用于在配置第一资源之后,获取用户操作时触发的应用场景事件;所述处理单元702还用于在所述应用场景事件为所述第一应用的场景事件时,确定与所述第一应用的场景事件具有对应关系的至少一个读取文件;以及利用所述第一资源读取所述至少一个相关文件。Optionally, in a specific implementation manner of this embodiment, the acquiring unit 701 is further configured to acquire an application scenario event triggered when the user operates after the first resource is configured; the processing unit 702 is also configured to When the application scene event is a scene event of the first application, determine at least one read file that has a corresponding relationship with the scene event of the first application; and use the first resource to read the at least one Related documents.
可选的,在本实施例的另一种具体的实现方式中,所述处理单元702具体用于操作系统启动时解析配置文件得到第一应用缓存的配额比例,根据当前空闲内存容量和所述第一应用缓存的配额比例计算所述第一应用的配额绝对值,将所述配额绝对值乘以预设比例得到所述第一资源的大小。Optionally, in another specific implementation manner of this embodiment, the processing unit 702 is specifically configured to parse the configuration file when the operating system is started to obtain the quota ratio of the first application cache, according to the current free memory capacity and the The quota ratio cached by the first application calculates the absolute value of the quota of the first application, and multiplies the absolute value of the quota by a preset ratio to obtain the size of the first resource.
可选的,所述预设比例为80%。Optionally, the preset ratio is 80%.
可选的,在本实施例的又一种具体的实现方式中,获取单元701还用于在为第一应用配置第一资源之前,接收所述第一应用发送的请求消息,所述请求消息用于请求加载所述第一应用;所述处理单元702还用于判断是否保存有所述第一应用的相关文件;如果否,则执行 所述配置第一资源的步骤。Optionally, in another specific implementation manner of this embodiment, the acquiring unit 701 is further configured to receive a request message sent by the first application before configuring the first resource for the first application. The request message It is used to request to load the first application; the processing unit 702 is also used to determine whether the relevant file of the first application is saved; if not, execute the step of configuring the first resource.
对应地,所述处理单元702还用于如果是,则直接将所述内存储器RAM中缓存的第一应用的相关文件通过发送单元发送给所述第一应用。Correspondingly, the processing unit 702 is further configured to, if yes, directly send the related files of the first application cached in the internal memory RAM to the first application through the sending unit.
可以理解地,所述装置实施例中的接收单元、处理单元和发送单元可以由软件、硬件或软件与硬件结合实现。所述软件可运行于计算机或处理器上。例如,所述获取单元和处理单元可以是集成在终端设备的处理器内部或者是处理运行所需的软件模块或者是二者的结合。It is understandable that the receiving unit, the processing unit, and the sending unit in the device embodiment can be implemented by software, hardware, or a combination of software and hardware. The software can be run on a computer or a processor. For example, the acquisition unit and the processing unit may be integrated in the processor of the terminal device or a software module required for processing operation or a combination of the two.
进一步地,在具体硬件实现层面上,本申请实施例还提供了一种终端设备,用于实现前述实施例所述的资源管理方法的部分或全部步骤。Further, at the level of specific hardware implementation, an embodiment of the present application also provides a terminal device for implementing part or all of the steps of the resource management method described in the foregoing embodiment.
具体地,如图8所示,该终端设备包括:收发器801、处理器802和存储器803,此外,该终端设备中还可以包括更多或更少的部件,或者组合某些部件,或者不同的部件布置,本申请对此不进行限定。Specifically, as shown in FIG. 8, the terminal device includes: a transceiver 801, a processor 802, and a memory 803. In addition, the terminal device may also include more or fewer components, or a combination of some components, or different components. The arrangement of components is not limited in this application.
其中,收发器801用于建立通信信道,使终端设备能够通过所述通信信道连接至网络,比如WiFi网络系统或蜂窝网络,从而实现终端设备与其他网络设备之间的通信传输。进一步地,收发器801可以包括接收机、发射机与天线等部件,或者还可以包括接收机和发射机等射频部件,进一步地,所述射频部件可以包括无线局域网(wireless local area network,WLAN)模块、蓝牙模块、基带(base band)模块等至少部分通信模块,以及所述通信模块对应的射频(radio frequency,RF)电路,用于进行无线局域网络通信、蓝牙通信、红外线通信及/或蜂窝式通信系统通信,例如宽带码分多重接入(wideband code division multiple access,WCDMA)及/或高速下行封包存取(high speed downlink packet access,HSDPA)。此外,所述收发器还用于控制终端设备中的各组件间的通信,并且可以支持直接内存存取(direct memory access)。The transceiver 801 is used to establish a communication channel so that the terminal device can connect to a network, such as a WiFi network system or a cellular network, through the communication channel, so as to realize communication transmission between the terminal device and other network devices. Further, the transceiver 801 may include components such as a receiver, a transmitter and an antenna, or may also include radio frequency components such as a receiver and a transmitter, and further, the radio frequency components may include a wireless local area network (WLAN) At least part of the communication modules such as modules, Bluetooth modules, baseband modules, and radio frequency (RF) circuits corresponding to the communication modules are used for wireless local area network communication, Bluetooth communication, infrared communication and/or cellular Communication system, such as wideband code division multiple access (WCDMA) and/or high-speed downlink packet access (HSDPA). In addition, the transceiver is also used to control the communication between various components in the terminal device, and can support direct memory access (direct memory access).
所述处理器802为终端设备的控制中心,利用各种接口和线路连接整个硬件设备的各个部分,通过运行或执行存储在存储器803内的软件程序和/或模块,以及调用存储在存储器内的数据,以执行所述终端设备的各种功能。The processor 802 is the control center of the terminal device, which uses various interfaces and lines to connect the various parts of the entire hardware device, runs or executes software programs and/or modules stored in the memory 803, and calls Data to perform various functions of the terminal device.
进一步地,处理器802可以包括一个或多个集成电路(integrated circuit,IC)或芯片,例如可以包括单颗封装的IC,也可以包括连接多颗相同功能或不同功能的封装IC。举例来说,处理器可以仅包括CPU,也可以是进一步包括GPU、数字信号处理器(digital signal processor,DSP)、及收发模块中的控制芯片的组合。Further, the processor 802 may include one or more integrated circuits (ICs) or chips, for example, may include a single packaged IC, or may include multiple packaged ICs connected with the same function or different functions. For example, the processor may only include a CPU, or may further include a combination of a GPU, a digital signal processor (digital signal processor, DSP), and a control chip in the transceiver module.
所述存储器803用于存储执行本申请技术方案的程序代码,并由处理器802来控制执行。进一步地,所述处理器802用于执行存储器803中存储的计算机程序代码,实现上述实施例中的资源管理方法。The memory 803 is used to store program codes for executing the technical solutions of the present application, and the processor 802 controls the execution. Further, the processor 802 is configured to execute the computer program code stored in the memory 803 to implement the resource management method in the foregoing embodiment.
进一步地,存储器可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、只读光盘(Compact Disc Read-Only Memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,也可以和处理器集成在一起。Further, the memory can be read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (RAM), or can store information and instructions Other types of dynamic storage devices can also be Electrically Erasable Programmable Read-Only Memory (EEPROM), Compact Disc Read-Only Memory, CD-ROM or other optical disk storage, Optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired program codes in the form of instructions or data structures and can Any other medium accessed by the computer, but not limited to this. The memory can exist independently or integrated with the processor.
另外,在本申请上述图7所示的实施例中,获取单元701所要实现的功能可以由该终端设备的收发器801来实现;处理单元702所要实现的功能则可以由处理器802来实现。In addition, in the above-mentioned embodiment shown in FIG. 7 of the present application, the function to be implemented by the obtaining unit 701 may be implemented by the transceiver 801 of the terminal device; the function to be implemented by the processing unit 702 may be implemented by the processor 802.
此外,同理地,在图6所述的装置中,所述系统中的检测模块、配额管理模块、装载管理模块和文件系统的功能都可以由终端设备的收发器801和处理器802来实现,所述内存储器和外存储器的功能可以由存储器803实现,所述应用可以配置在操作系统,比如安卓系统或IOS系统。In addition, similarly, in the device described in FIG. 6, the functions of the detection module, quota management module, load management module, and file system in the system can all be implemented by the transceiver 801 and the processor 802 of the terminal device. The functions of the internal memory and external memory can be implemented by the memory 803, and the application can be configured in an operating system, such as an Android system or an IOS system.
本实施例所述的终端设备可以是移动终端,如移动电话(或称为“蜂窝”电话)和具有移动终端的计算机,例如,可以是便携式、袖珍式、手持式、计算机内置的或者车载的移动装置,它们与无线接入网交换语言和/或数据。例如,个人通信业务(personal communication service,PCS)电话、无绳电话、会话发起协议(SIP)话机、无线本地环路(wireless local loop,WLL)站、个人数字助理(personal digital assistant,PDA)等设备。所述无线终端也可以为订户单元(subscriber unit)、订户站(subscriber station),移动站(mobile station)、移动台(mobile)、远程站(remote station)、接入点(access point)、远程终端(remote terminal)、接入终端(access terminal)、用户终端(user terminal)、用户代理(user agent)、用户设备(user device)或用户设备(user equipment,UE)等,本申请的实施例对终端设备所采用的具体技术和具体设备形态不做限定。The terminal device described in this embodiment may be a mobile terminal, such as a mobile phone (or called a "cellular" phone) and a computer with a mobile terminal. For example, it may be portable, pocket-sized, handheld, built-in computer, or vehicle-mounted. Mobile devices, which exchange language and/or data with the wireless access network. For example, personal communication service (PCS) phones, cordless phones, Session Initiation Protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (personal digital assistants, PDAs) and other equipment . The wireless terminal may also be a subscriber unit (subscriber unit), subscriber station (subscriber station), mobile station (mobile station), mobile station (mobile), remote station (remote station), access point (access point), remote station Terminal (remote terminal), access terminal (access terminal), user terminal (user terminal), user agent (user agent), user equipment (user device) or user equipment (user equipment, UE), etc., embodiments of this application The specific technology and specific device form adopted by the terminal device are not limited.
此外,本申请还提供一种计算机存储介质,其中,该计算机存储介质可存储有程序,该程序执行时可包括本申请提供的天线选择方法的各实施例中的部分或全部步骤。所述的存储介质可为磁碟、光盘、ROM或RAM等。在上述实施例中,可以全部或部分通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令,例如天线选择指令、或天线避让指令,在计算机加载和执行所述计算机程序时,全部或部分地产生按照本申请上述各个实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络或者其他可编程装置。In addition, the present application also provides a computer storage medium, where the computer storage medium may store a program, and the program may include some or all of the steps in each embodiment of the antenna selection method provided in the present application when the program is executed. The storage medium can be a magnetic disk, an optical disk, ROM or RAM, etc. In the above-mentioned embodiments, all or part of it may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in the form of a computer program product in whole or in part. The computer program product includes one or more computer instructions, such as an antenna selection instruction or an antenna avoidance instruction. When the computer program is loaded and executed by the computer, the process according to the foregoing embodiments of the present application is generated in whole or in part. Or function. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网络节点、计算机、服务器或数据中心通过有线或无线方式向另一个站点、计算机或服务器进行传输。The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a network node, computer, server, or data center. Transmission to another site, computer or server via wired or wireless means.
所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等存储设备。所述可用介质可以是磁性介质,例如软盘、硬盘、磁带、光介质(例如DVD)、或半导体介质,例如固态硬盘SSD等。The computer-readable storage medium may be any available medium that can be accessed by a computer or a storage device such as a server or data center integrated with one or more available media. The usable medium may be a magnetic medium, such as a floppy disk, a hard disk, a magnetic tape, an optical medium (such as a DVD), or a semiconductor medium, such as a solid-state hard disk (SSD).
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", etc. in the description and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments described herein can be implemented in an order other than the content illustrated or described herein. In addition, the terms "including" and "having" and any variations of them are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to the clearly listed Those steps or units may include other steps or units that are not clearly listed or are inherent to these processes, methods, products, or equipment.
本领域的技术人员可以清楚地了解到本申请实施例中的技术可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本申请实施例中的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例或者实施例的某些部分所述的方法。Those skilled in the art can clearly understand that the technology in the embodiments of the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solutions in the embodiments of the present application can be embodied in the form of a software product in essence or a part that contributes to the prior art. The computer software product can be stored in a storage medium, such as ROM/RAM , Magnetic disks, optical disks, etc., including a number of instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments of the present invention.
本说明书中各个实施例之间相同相似的部分互相参见即可。尤其,对于终端设备而言, 由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例中的说明即可。The same or similar parts in the various embodiments in this specification can be referred to each other. In particular, for the terminal device, since it is basically similar to the method embodiment, the description is relatively simple, and for related parts, please refer to the description in the method embodiment.
以上所述的本申请实施方式并不构成对本申请保护范围的限定。The implementations of the application described above do not constitute a limitation on the protection scope of the application.

Claims (14)

  1. 一种资源管理方法,其特征在于,所述方法包括:A resource management method, characterized in that the method includes:
    配置第一资源,所述第一资源用于读取第一应用的相关文件;Configure a first resource, where the first resource is used to read related files of the first application;
    获取在读取所述第一应用的相关文件时所占用的第一缓存资源;Acquiring the first cache resource occupied when reading related files of the first application;
    如果所述第一缓存资源的大小超过所述第一资源的大小,则确定第二资源,并在所述第一缓存资源中清除所述第二资源,使得清除所述第二资源后的剩余资源继续读取所述第一应用的相关文件。If the size of the first cache resource exceeds the size of the first resource, determine a second resource, and clear the second resource in the first cache resource, so that the remaining after clearing the second resource The resource continues to read related files of the first application.
  2. 根据权利要求1所述的方法,其特征在于,所述确定第二资源,包括:The method according to claim 1, wherein the determining the second resource comprises:
    根据所述第一缓存资源、待读取的所述第一应用的相关文件的大小和所述第一资源确定所述第二资源。The second resource is determined according to the first cache resource, the size of the related file of the first application to be read, and the first resource.
  3. 根据权利要求1或2所述的方法,其特征在于,在所述配置第一资源之后还包括:The method according to claim 1 or 2, wherein after the configuring the first resource, the method further comprises:
    获取用户操作时触发的应用场景事件;Obtain application scenario events triggered by user operations;
    在所述应用场景事件为所述第一应用的场景事件时,确定与所述第一应用的场景事件具有对应关系的至少一个相关文件;When the application scene event is a scene event of the first application, determining at least one related file that has a corresponding relationship with the scene event of the first application;
    利用所述第一资源读取所述至少一个相关文件。Reading the at least one related file by using the first resource.
  4. 根据权利要求1-3任一项所述的方法,其特征在于,所述配置第一资源,包括:The method according to any one of claims 1-3, wherein the configuring the first resource comprises:
    启动后解析配置文件得到第一应用缓存的配额比例;Parse the configuration file after startup to obtain the quota ratio of the first application cache;
    根据当前空闲内存容量和所述第一应用缓存的配额比例计算所述第一应用的配额绝对值;Calculating the absolute value of the quota of the first application according to the current free memory capacity and the quota ratio of the first application cache;
    将所述配额绝对值乘以预设比例得到所述第一资源的大小。Multiply the absolute value of the quota by a preset ratio to obtain the size of the first resource.
  5. 根据权利要求1-4任一项所述的方法,其特征在于,在所述配置第一资源之前还包括:The method according to any one of claims 1-4, wherein before the configuring the first resource, the method further comprises:
    接收所述第一应用发送的请求消息,所述请求消息用于请求读取所述第一应用的相关文件;Receiving a request message sent by the first application, where the request message is used to request to read related files of the first application;
    判断是否保存有所述第一应用的相关文件;Judging whether relevant files of the first application are saved;
    如果否,则执行所述配置第一资源的步骤。If not, execute the step of configuring the first resource.
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述第一应用为以下至少一种:The method according to any one of claims 1-5, wherein the first application is at least one of the following:
    前台应用、第一类服务、后台应用、第二类服务;Front-end application, first-class service, back-end application, second-class service;
    其中,所述第一类服务用于为所述前台应用提供必要的服务,所述第二类服务用于为所述后台应用提供必要的服务。Wherein, the first type of service is used to provide necessary services for the foreground application, and the second type of service is used to provide necessary services for the background application.
  7. 一种资源管理装置,其特征在于,包括:A resource management device, characterized by comprising:
    处理单元,用于配置第一资源,所述第一资源用于读取第一应用的相关文件;A processing unit, configured to configure a first resource, where the first resource is used to read related files of the first application;
    获取单元,用于获取在读取所述第一应用的相关文件时所占用的第一缓存资源;An acquiring unit, configured to acquire the first cache resource occupied when reading related files of the first application;
    所述处理单元,还用于在所述第一缓存资源的大小超过所述第一资源的大小的情况下,确定第二资源,并在所述第一缓存资源中清除所述第二资源,使得清除所述第二资源后的剩余资源继续读取所述第一应用的相关文件。The processing unit is further configured to determine a second resource when the size of the first cache resource exceeds the size of the first resource, and clear the second resource in the first cache resource, The remaining resources after clearing the second resource continue to read related files of the first application.
  8. 根据权利要求7所述的装置,其特征在于,The device according to claim 7, wherein:
    所述处理单元,具体用于根据所述第一缓存资源、待读取的所述第一应用的相关文件的大小和所述第一资源确定所述第二资源。The processing unit is specifically configured to determine the second resource according to the first cache resource, the size of the related file of the first application to be read, and the first resource.
  9. 根据权利要求7或8所述的装置,其特征在于,The device according to claim 7 or 8, wherein:
    所述获取单元,还用于在配置第一资源之后,获取用户操作时触发的应用场景事件;The acquiring unit is further configured to acquire an application scenario event triggered when the user operates after the first resource is configured;
    所述处理单元,还用于在所述应用场景事件为所述第一应用的场景事件时,确定与所述第一应用的场景事件具有对应关系的至少一个相关文件,以及利用所述第一资源读取所述至少一个相关文件。The processing unit is further configured to determine at least one related file that has a corresponding relationship with the scene event of the first application when the application scene event is the scene event of the first application, and use the first application The resource reads the at least one related file.
  10. 根据权利要求7-9任一项所述的装置,其特征在于,The device according to any one of claims 7-9, wherein:
    所述处理单元,具体用于解析配置文件得到第一应用缓存的配额比例,根据当前空闲内存容量和所述第一应用缓存的配额比例计算所述第一应用的配额绝对值,将所述配额绝对值乘以预设比例得到所述第一资源的大小。The processing unit is specifically configured to parse the configuration file to obtain the quota ratio of the first application cache, calculate the absolute value of the quota of the first application according to the current free memory capacity and the quota ratio of the first application cache, and set the quota The absolute value is multiplied by the preset ratio to obtain the size of the first resource.
  11. 根据权利要求7-10任一项所述的装置,其特征在于,The device according to any one of claims 7-10, wherein:
    所述获取单元,还用于在配置第一资源之前,接收所述第一应用发送的请求消息,所述请求消息用于请求读取所述第一应用的相关文件;The acquiring unit is further configured to receive a request message sent by the first application before configuring the first resource, where the request message is used to request to read related files of the first application;
    所述处理单元,还用于判断是否保存有所述第一应用的相关文件;如果否,则执行所述配置第一资源的步骤。The processing unit is also used to determine whether the relevant file of the first application is saved; if not, execute the step of configuring the first resource.
  12. 根据权利要求7-11任一项所述的装置,其特征在于,所述第一应用为以下至少一种:The device according to any one of claims 7-11, wherein the first application is at least one of the following:
    前台应用、第一类服务、后台应用、第二类服务;Front-end application, first-class service, back-end application, second-class service;
    其中,所述第一类服务用于为所述前台应用提供必要的服务,所述第二类服务用于为所述后台应用提供必要的服务。Wherein, the first type of service is used to provide necessary services for the foreground application, and the second type of service is used to provide necessary services for the background application.
  13. 一种终端设备,包括处理器,所述处理器与存储器耦合,其特征在于,A terminal device includes a processor, the processor is coupled with a memory, and is characterized in that:
    所述存储器,用于存储指令;The memory is used to store instructions;
    所述处理器,用于执行所述存储器中的指令,使得所述设备执行如权利要求1至6中任一项所述的方法。The processor is configured to execute instructions in the memory, so that the device executes the method according to any one of claims 1 to 6.
  14. 一种计算机可读存储介质,所述存储介质中存储有指令,其特征在于,A computer-readable storage medium having instructions stored in the storage medium, characterized in that:
    当所述指令被运行时,实现如权利要求1至6中任一项所述的方法。When the instructions are executed, the method according to any one of claims 1 to 6 is realized.
PCT/CN2020/085949 2019-04-30 2020-04-21 Resource management method, apparatus and device WO2020221068A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910362513.XA CN110134655A (en) 2019-04-30 2019-04-30 A kind of method for managing resource, device and equipment
CN201910362513.X 2019-04-30

Publications (1)

Publication Number Publication Date
WO2020221068A1 true WO2020221068A1 (en) 2020-11-05

Family

ID=67575997

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/085949 WO2020221068A1 (en) 2019-04-30 2020-04-21 Resource management method, apparatus and device

Country Status (2)

Country Link
CN (1) CN110134655A (en)
WO (1) WO2020221068A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134655A (en) * 2019-04-30 2019-08-16 华为技术有限公司 A kind of method for managing resource, device and equipment
CN111104180B (en) * 2019-12-11 2021-08-03 惠州Tcl移动通信有限公司 Application program optimization method and device, storage medium and electronic equipment
CN113076194A (en) * 2021-03-29 2021-07-06 Oppo广东移动通信有限公司 Memory resource allocation method, device, terminal and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105740078A (en) * 2016-01-29 2016-07-06 华为技术有限公司 Memory management method and apparatus, and terminal
CN105824702A (en) * 2016-03-22 2016-08-03 乐视云计算有限公司 Method and terminal for managing program memory footprint
CN106776368A (en) * 2016-11-29 2017-05-31 郑州云海信息技术有限公司 Buffer memory management method, apparatus and system during a kind of digital independent
US20170177255A1 (en) * 2015-12-17 2017-06-22 Le Holdings (Beijing) Co., Ltd. Method and electronic device for allocating dynamic memory resources
CN108073520A (en) * 2016-11-10 2018-05-25 腾讯科技(深圳)有限公司 A kind of internal memory control method and device
CN110134655A (en) * 2019-04-30 2019-08-16 华为技术有限公司 A kind of method for managing resource, device and equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003288266A (en) * 2002-03-28 2003-10-10 Fujitsu Ltd Memory allocation method and its program
CN107145392A (en) * 2017-04-26 2017-09-08 努比亚技术有限公司 A kind of method and apparatus of memory optimization
CN108920271A (en) * 2018-05-17 2018-11-30 广州优视网络科技有限公司 Application cache method for cleaning, device, storage medium and terminal

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170177255A1 (en) * 2015-12-17 2017-06-22 Le Holdings (Beijing) Co., Ltd. Method and electronic device for allocating dynamic memory resources
CN105740078A (en) * 2016-01-29 2016-07-06 华为技术有限公司 Memory management method and apparatus, and terminal
CN105824702A (en) * 2016-03-22 2016-08-03 乐视云计算有限公司 Method and terminal for managing program memory footprint
CN108073520A (en) * 2016-11-10 2018-05-25 腾讯科技(深圳)有限公司 A kind of internal memory control method and device
CN106776368A (en) * 2016-11-29 2017-05-31 郑州云海信息技术有限公司 Buffer memory management method, apparatus and system during a kind of digital independent
CN110134655A (en) * 2019-04-30 2019-08-16 华为技术有限公司 A kind of method for managing resource, device and equipment

Also Published As

Publication number Publication date
CN110134655A (en) 2019-08-16

Similar Documents

Publication Publication Date Title
EP3851956B1 (en) Method and apparatus for accelerating cold-starting of application
WO2020221068A1 (en) Resource management method, apparatus and device
EP3506106B1 (en) Method for processing application, electronic device, and computer-readable storage medium
EP3506105B1 (en) Method and device for processing a memory and storage medium
US11586544B2 (en) Data prefetching method and terminal device
US11627486B2 (en) Data sending method and apparatus, and device
EP1725944A2 (en) Power management system and method for a wireless communications device
EP3506114B1 (en) Memory processing method and device and storage medium
US11096177B2 (en) Operation mode switching method and user equipment
CN106897299B (en) Database access method and device
US10719351B2 (en) Method for controlling states of processes and related device
US20180034894A1 (en) Data Transmission Method, and Terminal
JP2020511819A (en) Network connection method and device
EP3793176A1 (en) Data processing method, device and apparatus
US10575365B2 (en) PDN connection release method and apparatus, and user equipment
JP2015127869A (en) Electronic apparatus, control method, and program
US20100251251A1 (en) Apparatus and method for cpu load control in multitasking environment
WO2023246756A1 (en) Computing power service method and apparatus, terminal, and core network device
KR101471538B1 (en) Wireless communiation device and control method for controlling network connection thereof
CN111901897A (en) Data downloading method and device, storage medium and terminal
US20210212019A1 (en) Indication Method for Context Identification, Acquisition Method, User Equipment and Base Station
CN114424611A (en) Control of network functions

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20798885

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20798885

Country of ref document: EP

Kind code of ref document: A1