The present invention is directed to memory used to implement virtual memory, and particularly to predictive allocation of the memory space required by computer applications running on a computer which may require iterative allocations of memory space.
Virtual memory is an abstract concept of memory which a computer system uses when it references memory. Virtual memory consists of the computer system's main memory (RAM), its file systems, and paging space. At different points in time, a virtual memory address referenced by an application may be in any of these locations. The application does not need to know which location, as the computer system's virtual memory manager (MM) will transparently move blocks of data around as needed. These blocks of data are of fixed size, typically 4K or 64K. While the sizes of these pages in the file system and in paging space remain constant, there is a VMM mechanism in place to convert pages in RAM from one size to the other as a demand for a size increases.
Virtual memory is extension of the computer system's main memory (RAM) or shared memories such as shared memory libraries via a virtual address space. The virtual address space which may include the computer's disk drive, and other mass storage facilities. In such virtual memory systems, virtual memory addresses of blocks of data in the form of Pages are translated into addresses of pages into allocated i.e. mad available in the much smaller physical memories under the control of virtual memory manager. This translation involves a conversion of the blocks or memory pages from a secondary source, e.g. disk drive, to the primary memory, e.g. RAM, whenever the execution of a running application program requires the pages that are transferred in a sequence of invocations from paging space. It is a goal of virtual memory management to permit several running application programs to run seamlessly with respect to the operating system so that a relatively large virtual address range may run on a relatively small amount of physical memory with little reduction in computer speed. Representative paged memory systems are described in U.S. Pat. No. 5,706,461 and in the IBM Journal of Research and Development article: Multiple Page Sizing and Modeling and Optimization, Vol 50, pp. 238-248, March 1960.
In order to achieve smooth and seamless effects when running one or more application programs, methods (algorithms) for allocating page space (pages), virtual memory systems strive for fast and effective allocations in response to each sequential invocation by the application for paging space pages to physical memory pages. Over the years, many schemes have been tried and used for such allocations. These include:
Early paging space allocation (e.g. represented by the Environment Variable, PSALLOC-early); this sets aside all requested (malloc'd) page space, irrespective of how much memory space is actually used in virtual memory. This could potentially dissipate a lot of space, which, in turn, could lead to a page-space low scenario.
Deferred paging space allocation (e.g. represented by the Environment Variable, PSALLOC=deferred); this waits to assign paging space until a page is going to be paged out of RAM and may risk the situation wherein page space is not available when actually needed.
Late paging space allocation (e.g. represented by the Environment Variable, SALLOC=late); this waits to assign page space until a page is touched and also may risk the situation wherein page space is not available when actually needed.
In view of this background, it is desirable to seek an algorithm that would predict the amount of memory required for a subsequent allocation in response to a subsequent invocation by a running application program.
The present invention improves upon the prior art situation in the allocation of paging space through a predictive allocation (e.g. represented by the Environment Variable, PSALLOC-predictive) that provides for the prediction of the amount of paging space that is predicted to actually be used. The algorithm for this predictive allocation is continuously heuristically updated based upon the paging space actually used for an invoked sequential allocation that has been predicted.
In its broadest aspects, the present invention provides a virtual memory method for allocating page space required by an application that comprises tracking the page space used in each of a sequence of invocations by an application requesting memory space, keeping count of the number of said invocations and determining the average paging space used for each of the invocations from the count and total paging space used. Then, this average paging space is reserved as a predicted allocation for the next invocation. This reserved paging space is used for the next invocation. If there is any additional paging space required by said next invocation, this paging space may be accessed through any conventional default memory space allocation. Finally, whether or not additional default memory is needed, the actual paging space used in the next invocation is tracked and used to update the average paging space used. The method of the present is applicable in systems wherein a single application program or multiple application programs are running and each requires a sequence of invocations for pacing space. The described predictive page allocation is also applicable wherein the application uses space in shared libraries.
The primary aspect of the present invention is in the predicted allocations of space in computer memory. In a further aspect of the present invention, in a paged virtual memory in which the physical memory space is divided into pages of different sizes, a conventional threshold may be predetermined wherein the RAM to be used by said application will require a conversion of pages of one different size to another. Then, when this determined average memory space reaches the threshold, the conversion of the pages in said reserved RAM may be commenced. This conversion is particularly advantageous when the threshold requires a promotion, i.e. a conversion from smaller to larger pages.
The method described for predetermining a threshold, wherein the RAM to be used by the application will require a conversion of pages of one different size to another is likewise applicable where the application uses space in shared libraries.
The present invention will be better understood and its numerous objects and advantages will become more apparent to those skilled in the art by reference to the following drawings, in conjunction with the accompanying specification, in which:
Referring to
In the predicted allocation algorithm of the present invention, the paging space pages arc reserved for the invocation from the requesting application program. The examples for memory allocations described with respect to
The following is an example of a simplified set of program instructions of the process of
The updating of the averages may be illustrated as follows:
Assume the following values: cnt=3, data bytes−100, and shlib bytes=50.
A next invocation uses 500 bytes in local memory and 70 bytes in the shared library.
Thus, before this next invocation cnt*databytes=300; the next invocation adds 500 bytes. Then total=80C divided by a cnt=4. New average data bytes=200.
Before this next invocation cnt*databytes=150; the next invocation 70 bytes. Then total=220 divided by a cnt=4. New average shlib bytes=55.
Store the new averages: data bytes=200, shlib bytes=55 and increment counter to cnt=4.
A flowchart of an illustrative run of the program set up in
Now with respect to
Although certain preferred embodiments have been shown and described, it will be understood that many changes and modifications may be made therein without departing from the scope and intent of the appended claims.