Patent Publication Number: US-2013247063-A1

Title: Computing device and method for managing memory of virtual machines

Description:
BACKGROUND 
     1. Technical Field 
     Embodiments of the present disclosure relate to virtual machine technology, and particularly to a computing device and method for managing memory of virtual machines in the computing device. 
     2. Description of Related Art 
     In virtual machine technology, a plurality of virtual machines (VMs) may be installed in a computing device. Each virtual machine is allocated a certain amount of memory of the computing device based on the projected requirements of the VM. As such, the number of VMs is limited by the sum of total memory allocated to each installed VM and the minimum memory for the computing device. However, memory requirements for VMs may change, for example, a VM may need less memory to handle less users or applications, etc., and this situation may allow more VMs to be added to the computing device. However, to make adjustment to the memory allocated to each VM, the VMs must be shut-down and changes made through the virtualization application. This is tedious and inconvenient. 
     Therefore, there is room for improvement in the art. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG. 1  is one embodiment of an application of a computing device. 
         FIG. 2  is a block diagram of one embodiment of function modules of a memory management system in  FIG. 1 . 
         FIG. 3  is a flowchart of one embodiment of a method for managing memory of virtual machines in the computing device of  FIG. 1 . 
     
    
    
     DETAILED DESCRIPTION 
     The disclosure is illustrated by way of example and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean “at least one.” 
     In general, the word “module”, as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as, Java, C, or assembly. One or more software instructions in the modules may be embedded in firmware, such as in an erasable programmable read only memory (EPROM). The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of non-transitory computer-readable medium or other storage device. Some non-limiting examples of non-transitory computer-readable media include CDs, DVDs, BLU-RAY, flash memory, and hard disk drives. 
       FIG. 1  is one embodiment of an application of a computing device  10  including a memory management system  11 . A plurality of virtual machines  12  are installed in the computing device  10  to provide services (e.g., computing services) to users. The computing device  10  further includes a storage system  13  and at least one processor  14 . The storage system  13  includes memory (e.g., dynamic random access memory) and secondary storage (e.g., hard disk drive). Each virtual machine occupies some amount of the memory of the computing device  10 . The memory management system  11  is used to release idle memory of the virtual machines  12  when available memory of the computing device  10  is insufficient. 
       FIG. 2  is a block diagram of one embodiment of function modules of the memory management system  11  in  FIG. 1 . The memory management system  11  includes a receipt module  200 , a calculation module  210 , a tag module  220 , a release module  230 , and a removal module  240 . The modules  200 - 240  may comprise computerized code in the form of one or more programs that are stored in the storage system  13 . The computerized code includes instructions that are executed by the at least one processor  14 , to provide the aforementioned functions of the memory management system  11 . A detailed description of the functions of the modules  200 - 240  is given in reference to  FIG. 3 . 
       FIG. 3  is a flowchart of one embodiment of a memory release method for managing memory of the virtual machines  12  using the computing device  10  of  FIG. 1 . Depending on the embodiment, additional steps may be added, others removed, and the ordering of the steps may be changed. 
     In step S 301 , the receipt module  200  receives a user request for allocating a specified amount of memory of the computing device  10  to a virtual machine  12 . The virtual machine  12  may be a new virtual machine to be installed in the computing device  10  or an existing virtual machine in the computing device  10 . In one example, three virtual machines  12  denoted as VM 1 , and VM 2 , VM 3  are installed in the computing device  10 . When a new virtual machine VM 4  is required to be installed in the computing device  10 , a specified amount of memory (e.g., 3 GB) is specified to VM 4 . The user request may be submitted from a client computer connected to the computing device  10 . 
     If available memory of the computing device  10  is less than the specified amount of memory, in step S 302 , the calculation module  210  calculates total idle memory of all the virtual machines  12  in the computing device  10 , and determines whether the total idle memory is less than the specified amount of memory. In one example, 3 GB memory is specified to allocate to VM 4 , and VM 1  includes 1 GB idle memory, VM 2  includes 2 GB idle memory, and VM 3  includes 1 GB idle memory. Therefore, total idle memory of VM 1 , VM 2 , and VM 3  is 4 GB, which is greater than the specified amount of memory. If the total idle memory of the virtual machines  12  is less than the specified amount of memory, the process ends. In one embodiment, each virtual machine  12  in the computing device  10  includes a memory monitor, which detects idle memory of the virtual machine  12 . 
     If the total idle memory of the virtual machines  12  is equal to or greater than the specified amount of memory, in step S 303 , the tag module  220  adds tags to the idle memory of the virtual machines  12 , to prevent subsequent access to the idle memory by the virtual machine  12  which possesses the idle memory. In one embodiment, memory of each virtual machine  12  in the computing device  10  consists of fixed-length blocks. The tag module  220  attaches the tags to idle blocks of the virtual machine  12 . 
     In step S 304 , the release module  230  calculates an average release memory of the virtual machines  12  in the computing device  10 , and releases the idle memory of the virtual machines  12  according to the average release memory. The average release memory of the virtual machines  12  is calculated by dividing the specified amount of memory by the number of the virtual machines  12 . As mentioned above, VM 1 , VM 2  and VM 3  are installed in the computing device  10  and VM 1  includes 1 GB idle memory, VM 2  includes 2 GB idle memory, and VM 3  includes 1 GB idle memory. 3 GB memory is required to be allocated to the new virtual machine VM 4 . Therefore, the average release memory of the three virtual machines  12  is 1 GB (i.e., 3 GB/3). The release module  230  releases 1 GB idle memory from each of VM 1 , VM 2 , and VM 3 . If a first virtual machine includes less idle memory than the average release memory while a second virtual machine includes more idle memory than the average release memory, the release module  230  may release less idle memory than the average release memory from the first virtual machine, and release more idle memory than the average release memory from the second virtual machine. For example, if VM  1  includes 0.5 GB idle memory and VM  2  includes 2 GB idle memory, the release module  230  releases 0.5 GB idle memory from VM 1  and releases 1.5 GB idle memory from VM 2 . 
     In step S 305 , the removal module  240  removes the tags from the idle memory of the virtual machines  12  in the computing device  10 . After the tags of the idle memory have been removed, remaining idle memory is accessible for the virtual machines  12 . 
     Although certain inventive embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.