Memory allocation maintaining ordering across multiple heaps

Abstract: A method and apparatus for adding and deleting data in a plurality of heaps stored in memory (104), where the ordering of the data in the heaps is maintained across the heaps as the additions and deletions are performed. Not all entries in the heaps have a corresponding entry in all of the other heaps, but the ordering of the data in the heaps is in accordance with an order dependent list stored in memory (104). Such ordered heaps are useful for example, in an incremental linker software program (108).

Description: This invention relates to memory management in a data processing system and, more specifically, to adding and deleting data in a plurality of heaps, where the ordering of the data is maintained across the heaps. Various types of software programs store information in memory in the form of "heaps." A heap is a collection of data. Heaps can be implemented as arrays, as linked lists, or as any other appropriate data structure known to persons of ordinary skill in the art. Many conventional software programs create heaps to store data needed by the software program. Usually, an empty heap is created at the beginning of execution of the software program and data is added to the heap as execution of the software program progresses. A "linker" software program combines one or more "object files" into a single "executable file." Conventional linker-software creates a plurality of lists during its execution, where each list contains a certain type of data from the object files being linked. The linker takes the segments from each object file, in input order, and appends them to the end of each appropriate list. Each time a new re-link is performed, a conventional linker creates a completely new executable file. The creation of completely new executable files is inefficient because only some of the object files will have been modified since the last time the linking operation was performed. In WO-A-94/02898 an heap manager for allocating and freeing memory in an heap is disclosed which document includes background information usefull for the understanding of the invention. The present invention provides a method according to claim 5 and apparatus according to claim 1 for maintaining ordering across a plurality of heaps when data are deleted from and added to the heaps. In certain applications, it is desirable to maintain the ordering of the heaps as data is deleted and added. A "segment" is a block of data in a heap. Each segment on a heap has associated with it zero or one other related segments on each of the other heaps. The ordering constraint ensures that if, on one heap, segment [i] precedes segment [i+1], then on all heaps that contain segments associated with segment [i] and segment [i+1], the segment associated with segment [i] will proceed the segment associated with segment [i+1]. It is often desirable that a plurality of related data segments must be inserted into respective ones of the plurality of heaps. The requirement that data in the heaps remain ordered means that a data segment can be inserted in the middle of one heap only if there is also room to insert the other related data segments into a corresponding location in each of the other heaps. The present invention is described hereby in terms of heaps in an incremental linker software program. It will be understood by persons in ordinary skill in the art, however, that the present invention also may have applicability in other areas where maintaining ordering across heaps is valuable. The present invention uses the concept of "significant segment" to manipulate a plurality of pointers associated with ones of the plurality of heaps so that ordering is maintained across the heaps as data is added to and removed from the heaps. In accordance with the purpose of the present invention, as broadly described hereby, the present invention is an apparatus for manipulating entries in a plurality of heaps stored in a memory of a data processing system, comprising: means for determining respective amounts of required free space in each of the plurality of heaps and means for allocating the respective amounts of required free space in each of the plurality of heaps, so that the entries in the heaps remain ordered across the heaps. In further accordance with the purpose of the invention, as broadly described hereby, the invention is a method for finding a predetermined amount of free space in each of a plurality of heaps stored in a memory of a data processing system, the method comprising: the steps, performed by the data processing system, of: establishing a hi pointer and a lo pointer for each of the plurality of heaps, so that each heap has an associated lo pointer and an associated hi pointer; advancing at least one of the lo pointers to be equal to its corresponding hi pointer; advancing the corresponding at least one hi pointer to point to a next significant segment for the at least one hi pointer in the plurality of heaps; and determining whether the predetermined amount of free space exists in each of the heaps between each associated lo pointer and associated hi pointer. In further accordance with the purpose of the present invention, as broadly described hereby, the invention is an article of manufacture, comprising: a computer readable program means for receiving a plurality of predetermined values indicating a respective amount of space to be allocated in each of a plurality of heaps; and a computer readable program means for determining respective locations in the plurality of heaps having each respective amount of space; and a computer readable program means for allocating the respective locations, wherein the allocated locations maintain an ordering across the plurality of heaps. Advantages of the present invention will become more fully apparent when the following detailed descriptions of the invention are read in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS The invention will now be described with reference to the accompanying drawings, wherein: Fig. 1 is a block diagram of a data processing system in accordance with a preferred embodiment of the present invention. Figs. 2(a), 2(b), and 2(c) are block diagrams showing input to and output from an incremental linker software program. Fig. 3 is a flow chart showing steps performed to remove a plurality of segments from a plurality of heaps. Fig. 4 is a flow chart showing steps performed to add a plurality of segments to the plurality of heaps, while maintaining the ordering of the data across the corresponding heaps. Fig. 5 is an initial state of a data structure in a computer memory of Fig. 1 after a plurality of segments have been added to the plurality of heaps. Fig. 6 is an example of the data structure of Fig. 5 after deletion of segments from the plurality of heaps. Fig. 7 is an example of the data structure of Fig. 6 showing addition of segments to the plurality of heaps. Fig. 8 is a further example of the data structure of Fig. 7 showing addition of the segments to the plurality of heaps. Fig. 9 is a further example of the data structure of Fig. 8 showing addition of the segments to the plurality of heaps. Fig. 10 is a further example of the data structure of Fig. 9 showing addition of the segments to the plurality of heaps. Fig. 11 is a further example of the data structure of Fig. 10 showing addition of the segments to the plurality of heaps. Fig. 12 is a further example of the data structure of Fig. 11 showing addition of the segments to the plurality of heaps. Fig. 13 is a further example of the data structure of Fig. 12 showing addition of the segments to the plurality of heaps. Fig. 14 is a further example of the data structure of Fig. 13 showing addition of the segments to the plurality of heaps. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The following description is of the best presently contemplated mode of carrying out the invention. This description is made for the purpose of illustrating the general principles of the invention and is not to be taken in a limiting sense. Fig. 1 shows a data processing system 100, including a CPU 102 and a memory 104 connected to CPU 102. It will be understood by persons of ordinary skill in the art that data processing system 100 may also include various input/output devices, peripherals, network connections, memories, CPUs, etc., which are not shown in the figure for the sake of clarity. Memory 104 includes an incremental linker software program 108, which preferably is an incremental linker running under the UNIX operating system. UNIX is a registered trademark in the United States and other countries exclusively licensed through X/OPEN, Ltd. Sun Microsystems, Inc. manufactures a version of UNIX called Solaris, which is a registered trademark of Sun Microsystems, Inc. Memory 104 also includes one or more object files 110 and one or more incrementally linked executable files 112. An incrementally linked executable file 112 further includes various data structures, such as heaps, free segment lists, and an order dependent list, which are discussed below in more detail. As shown in Figs. 2(a)-2(c), object files 110 are input to incremental linker 108, which modifies executable file 112. Incremental linker 108 differs from a conventional linker because it does not relink every object file 110 each time linkage between object files is performed. Incremental linker 108 saves all of its old data from previous link operations in executable file 112 and generates new data only for those object files that have been modified since a previous link operation. The format of files 110 and 112 input to and output from incremental linker 108 is known to persons of ordinary skill in the art and is discussed in more detail in "System V Application Binary Interface," Prentice-Hall, Copyright 1990 by AT&T and "System V Application Binary Interface -- SPARC Processor Supplement," Prentice-Hall, Copyright 1990 by AT&T. In a preferred embodiment, where the present invention is used in incremental linker 108, each heap in executable file 112 and each segment in each object file corresponds to an ELF (Executable and Linking Format) section. In general, each object file 110 has a plurality of ELF sections (along with a size of each ELF section.) These are merged during linking (along with previous file 112) to form the ELF sections of incrementally linked file 112 (see Fig. 2(c)). Fig. 2(a) is a block diagram showing input and output of incremental linker 108. As show in the figure, incremental linker 108 has as initial inputs object files a.o, e.o, b.o, d.o, and c.o. Fig. 2(b) further shows that a first version of the object file e.o 202 is modified to yield a newer version of the object file e.o 204. As shown in Fig. 2(c), after e.o. is modified, the object files are relinked. During relinking, all data for e.o. 202 will be deleted from executable file 112 and new data for e.o. 204 will be added to executable file 112. Fig. 3 is a flow chart showing steps performed to delete segments corresponding to object file e.o 202 from a plurality of heaps in memory 104. Fig. 4 is a flow chart showing steps performed to add segments corresponding to object file e.o 204 to the plurality of heaps in memory 104. Both Figs. 3 and 4 will be discussed below in detail in connection with the examples of Figs. 5-14. It will be understood by persons of ordinary skill in the art that the steps in Figs. 3 and 4 are performed by CPU 102 executing instructions of incremental linker program 108 and using data structures stored in memory 104. The following paragraphs discuss the examples of Figs. 5-14 in conjunction with the flow charts of Figs. 3 and 4. Fig. 5 shows three heaps 502, 504, and 506. It will be understood by persons of ordinary skill in the art that the present invention will work with an arbitrary number of heaps.) Figs. 5 and 6 show an example of deleting segments of object file e.o 202 from the plurality of heaps. Figs. 6-14 show an example of adding segments of object file e.o 204 to the plurality of heaps, while maintaining the ordering of segments in the heaps. In the example, heap 502 corresponds to a symbol (.symbols) section for the object files a.o, e.o, b.o, and c.o. Similarly, heap 504 corresponds to a debugging information section (.stabs) for object files a.o, e.o, b.o, and c.o. Lastly, heap 506 corresponds to a debugging information string table section (.stabstr) for object files a.o, e.o, d.o, and c.o. Entries in each heap (ELF section) are called "segments." It should be noted that there is no segment for object file d.o in either heap 502 or heap 504. Similarly, there is no segment for object file b.o in heap 506. In spite of the fact that the heaps do not contain data for the same object files, the segments in each of the heaps are ordered in accordance with an order dependent list 508. As shown in Fig. 5, order dependent list 508 contains five entries: a first entry 510, which acts as the head of the list; an entry 512 for object file a.o, which contains pointers into heaps 502, 504, and 506; an entry 513 for object file e.o, which contains pointers into heaps 502, 504, and 506; an entry 514 for object file b.o, which contains pointers into heaps 502 and 504, hut does not contain a pointer into heap 506; an entry 516 for object file d.o, which contains only a pointer into heap 506; and an entry 518 for object file c.o, which contains pointers to each of heaps 502, 504, and 506. Thus, Fig. 5 represents data structures in incremental linker 108 after linkage of object files a.o, e.o (a first version 202), b.o, d.o and c.o. Each heap 502, 504, and 506 contains a plurality of segments, e.g., segment 520, which preferably are separated by one or more free bytes of padding, e.g., padding 522. In Fig. 5, a number following the word "pad" represents a number of bytes of a padding area. The padding areas in each heap are connected in a linked list called a "free list" 530, 532, and 534. Fig. 5 also shows a number of bytes in the segments for e.o. 202 (i.e., "2", "10", and "20") in each heap. In a preferred implementation of the present invention, the allocated segments in each heap are also connected in a linked list, although this is not necessary and other implementation may use other appropriate data structures to represent the heaps, free lists and order dependent list. The linked list of allocated segments is not shown in the figures in order to enhance the clarity of the example. Fig. 3 is a flow chart showing steps performed to delete segments corresponding to object file e.o 202 from the plurality of heaps. In the example, segments corresponding to object file e.o 202 are removed, so that a new version of e.o 204 may he added (see Figs. 4 and 6-14). First, in step 302, CPU 102 locates the entry 513 for object file e.o 202 in order dependent list 508 and accesses pointers into each of heaps 502, 504 and 506. (Some of these pointers could be NULL.) In step 302, the space in .symbols heap 502 previously reserved for e.o 202 is returned to free list 530. In step 304, the space in .stabs heap 504 previously reserved for e.o 202 is returned to the free list 532. In step 306, the space in .stabstr heap 506 previously reserved for e.o 202 is returned to free list 534. In step 307, the space in any other heaps (not shown) previously reserved for e.o 202 is returned to corresponding free lists. (It will be understood by persons of ordinary skill in the art that steps 302-307 may be implemented as a loop). Lastly, in step 308, the entry 513 for e.o 202 in order dependent list 508 is removed from list 508. Fig. 6 shows an example of the heaps and order dependent list after the segments of file e.o 202 have been removed. Note that in Fig. 6, (in heap 502) "pad 3", the space reserved for the symbols of e.o, and the space reserved for "pad 5" have been combined to form "pad 10". Similar changes have made to heaps 504 and 506. Furthermore, entry 513 for e.o has been deleted from order dependent list 508. Fig. 4 shows steps performed by CPU 102 to add segments for the new version of e.o 204 into the already existing heaps. As shown in the example Figs. 7 - 14, each heap has five associated variables, which are stored in memory 104. They are: lo: points to the segment in order dependent list 508 at the beginning of a range of free space, hi: points to the segment in order dependent list 508 at the end of the range of free space, first_free: points to the first free segment in a heap that has an address that is greater than lo but still less than hi, last_free: points to the last free segment in a heap that has an address that is greater than lo but still less than hi, and max_free: the greatest size of any free block in the range first_free through last_free. In the example of Figs 6-14, the lo and hi variables are distinguished by prefixing the variable name with the heap name. For example, the lo and hi pointers of the .stabs heap 502 will be shown in the diagram as "stabs:lo" and "stabs:hi", respectively. In the figures, first_free and last_free are abbreviated "ff" and "lf", respectively. In step 402, CPU 102 inputs the sizes of the new segments to be allocated in each heap. As shown in Figs. 2(a)-2(c), the segment sizes are a part of the object file 204. The example of Figs. 6-14 shows allocations of segments for a new file e.o 204 that has a .symbols segment of 15 bytes, a .stabs segment of 10 bytes, and a .stabstr segment of 30 bytes. In step 404, as shown in Fig. 7, the max_free variable for each heap is set to "0". The hi pointers for each heap are initialized to point to the start of order dependent list 508. In step 407, a minimum hi pointer is defined as all hi pointers that point to the earliest entry in order dependent list 508. In Fig. 7, all of the hi pointers are members of the minimum hi pointer set because they all point to the same entry of order dependent list 508 (i.e., the beginning of the list). In step 408 all of the lo pointers are set equal to the value of their corresponding hi pointers. In step 410 (see Fig. 8), CPU 102 advances each of the hi pointers as far as possible without traversing any "significant segments." A significant segment is defined as a segment whose entry in order dependent list 508 contains a non-NULL pointer into the hi pointer's corresponding heap and a non-NULL pointer into at least one other heap for which the segment that is currently being placed also has a non-NULL pointer. Thus, the entry 512 for a.o in order dependent list 508 is a significant segment for each of the three hi pointers. In step 410, as shown in Fig. 8, the hi pointer for each of the three heaps is advanced to the entry for a.o in order dependent list 508. In step 412, as also shown in Fig. 8, each first_free (ff) variable is set to the beginning of the free list for its corresponding heap. In step 414 (see Fig. 9), each last_free (If) variable is set to its corresponding first_free variable. In steps 416 and 418, CPU 102 advances each last_free variable down its free list as far as it will go while still keeping the address of the free segment less than the address of its corresponding hi pointer in order dependent list 508. Thus, in the example, none of the last_free variables are advanced, and the last_free variables remain at the beginning of the free list as shown in Fig. 9. Steps 416 and 418 search for a location before the a.o segment (pointed to by the hi pointers) to place the new segment, but since there is no padding before a.o in any of the heaps, no free space is found. In step 420, CPU 102 updates max_free for each heap (in this case all of the max_free variable still equal "0"). In step 422, CPU 102 examines all free space between first_free and last_free (in this case none) and determines whether there is a fit for the predetermined amount of free space being sought. In the example, no fit is found at step 424, so control returns to step 407. Repeating step 407 (see Fig. 10), CPU 102 determines which hi pointers need to be updated. Again, all hi pointers need to be updated. In step 408, each lo pointer is set to its corresponding hi pointer and, in step 410 (see Fig. 11), the hi pointers are advanced as far as possible without traversing a significant segment for the pointer. In Fig. 11, the hi pointers for heaps 502 and 504 (symbols:hi and stabs:hi) have been advanced to the entry 514 of order dependent list 508 for file b.o. Entry 514 represents a significant segment for the hi pointer for heap 502 because the entry contains a non-NULL pointer into heap 502 and into at least one other heap (heap 504). Entry 514 represents a significant segment for the hi variable for heap 504 because it contains a non-NULL pointer into heap 504 and into at least one other heap (heap 502). In Fig. 11 the hi pointer for heap 506 has been advanced to the entry 518 in order dependent list 508 for file c.o. The entry 514 for file b.o in list 508 is not a significant segment because it has a NULL pointer into heap 506. Similarly, the entry 516 for file d.o is not a significant segment for heap 506 because, although it has a non-NULL pointer into heap 506, it does not have a non-NULL pointer into any other heap. The entry 518 for c.o is a significant segment for heap 506 because it has a non-NULL pointer into heap 506 and a non-NULL pointer into at least one other heap (heaps 504 and 506). In step 412 (see Fig. 11), the first_free variables for heaps 502 and 504 are advanced to above the lo pointer for the corresponding heap. In step 414, (see Fig. 12), each last_free variable is set to its corresponding first_free variable. In steps 416 and 418, each last_free variable is advanced to the highest entry in its free list that is less than the segment referenced by the corresponding hi pointer. Thus, in Fig. 12, the last_free variable for heap 502 remains at "pad 10" (less than b.o), the last_free variable for heap 504 remains at "pad 20" (less than b.o), and the last_free variable for heap 506 points to "pad 5" (less than c.o). In step 420, max_free for heap 502 is updated to "10", max_free for heap 504 is updated to "20", and max_free for heap 506 is updated to "60" (the maximum of 60 and 5). CPU 102 cannot place the segments for file e.o between first_free and last_free in heap 502 in Fig. 12 because the symbols segment for file e.o requires 15 bytes and only 10 bytes are available. Because, in steps 422 and 424, the max_free variables indicate that there is not enough free space in the windows formed by the first_free and last_free variables in each heap, control passes to step 407. During the third iteration, steps 408-420 are performed only for those variables corresponding to heaps 502 and 504 (see Fig. 12). The variables corresponding to heap 506 remain unaffected. In step 408 (see Fig. 13), the lo pointers for heaps 502 and 504 are set to the value of the hi pointers for those heaps (b.o). In step 410, the first_free variables for heaps 502 and 504 are advanced to above the lo pointer for the corresponding heap. In step 412, the hi pointers for heaps 502 and 504 are advanced to the entry for file c.o, which is a significant segment for both hi pointers. In step 414, the last_free variables are set to the first-free variables. In steps 416 and 418, the last_free variables are incremented so that they are as high as possible while still being less than the hi pointer. In this example, the last_free variables do not change value. In step 420, the max_free variables for heaps 502 and 504 are updated to "20" and "15", respectively. Following the execution of step 420, the maximum free space in each of respective heaps 502, 504, and 506 are: symbols: max_free = 20 stabs: max_free = 15 stabstr: max_free = 60 (the greater of 5 and 60). Thus, since the objective is to find 15 bytes, 10 bytes, and 30 bytes, respectively, in heaps 502, 504, and 506, the determination of steps 422 and 424 is "YES" and the symbols segment, the stabs segment, and the stabstr segment for file e.o 204 are added to their respective heaps in step 426 at the locations 1302, 1304 and 1306. Fig. 14 shows the heaps 502, 504 and 508 after step 426. An entry 520 for object file e.o 204 is added to order dependent list 508. It should he noted that new entry 520 occupies a different location in list 508 than did old entry 513. It should be understood that the steps of Figs. 3 and 4 are repeated for each modified object file that is relinked by incremental linker 108. In the embodiment of Fig. 4, CPU 102 chooses a first fit found in steps 422, 424. Other embodiments of the present invention may attempt to find all possible fits and then select an optimal fit. See "Operating System Concepts 2e" by Peterson and Silberschatz, Addison-Wesley Publishing, Copyright 1985. In addition, although it is not shown in the Figures for the sake of clarity, at least one implementation of the present invention includes an end-of-list entry in order dependent list 508. This entry allows allocation of any padding after a last section in a heap (e.g., after c.o in heap 502 (not shown)). It is important to understand that the present invention maintains the ordering of the segments across the heaps in accordance with order dependent list 508. Thus, as shown in Fig. 14, after segments for the new version of e.o 204 are added to the heaps, all heaps correspond to the ordering: a.o, b.o, e.o, d.o, and c.o. Segments for certain of the files may not be present in some heaps (e.g., the stabstr segment for b.o is not present in heap 506), but the segments in the heaps are never out of order. Although not shown in Fig. 14, a person of ordinary skill in the art will recognize that the newly added segments in heaps 502, 504 and 506 have been filled by incremental linker 108 with data from file e.o 204, necessary for the correct linking of executable file 112. The present invention further incorporates an article of manufacture, which is a computer-readable medium such as a floppy disk, optical disk, or hard drive, etc. storing computer instructions of a sort executable by a CPU to perform the steps of Figs. 3 and 4. In summary, the present invention allows for deletion from and addition to a plurality of heaps, where an ordering of data is maintained across the heaps. A preferred embodiment has been described in which segments are deleted and added to sections (heaps) in an incremental linker software program. The present invention, however, can be used in any circumstances where it is desirable to maintain ordering across heaps where data are added to and/or deleted from the heaps. In describing the preferred embodiments, a number of specific technologies used to implement the embodiments of various aspects of the invention were identified and related to more general terms in which the invention was described. However, it should be understood that such specificity is not intended to limit the scope of the claimed invention.

Claims: An apparatus for allocating free space in each of a plurality of heaps (502, 504, 506), stored in a memory (104) of a data processing system (100) while maintaining segment order across segments in the plurality of heaps (502, 504, 506), the apparatus comprising means for manipulating pointers associated with respective ones of the plurality of heaps and pointing to segment entries in an order dependent list; means for determining whether a respective amount of required free space exists in each of the plurality of heaps (502, 504,506); and means for allocating the respective amounts of required free space in each of the plurality of heaps (502, 504, 506), comprising means for maintaining the order of the segments in the heaps (502, 504, 506) in accordance with the order dependent list. The apparatus of claim 1, further comprising: means for taking the allocated respective amounts of free space from respective free lists (530, 532, 534) stored in the memory (164) and associated with respective ones cf the plurality of heaps (502, 504, 506). The apparatus of claim 1, further comprising: means for deallocating respective amounts of space, wherein each deallocated amount of space is in a same relative ordering in the plurality of heaps (502, 504, 506). The apparatus of claim 3, further including: means for returning the deallocated space to respective free lists (530, 532, 534) stored in the memory (104) and associated with respective ones of the plurality of heaps (502, 504, 506). A method for allocating a predetermined amount of free space in each of a plurality of heaps (502, 504, 506) stored in a memory (104) of a data processing system (100), the method comprising the steps, performed by the data processing system, of: establishing a hi pointer and a lo pointer for each of the plurality of heaps, which pointers are pointing to the beginning segment entries in an order dependent list; advancing at least one of the lo pointers to be equal to its corresponding hi pointer (408); advancing (410) the corresponding at least one hi pointer to point to a first next significant segment (520) entry in the order dependent list whose segment entry contains a non-null pointer into the hi pointers' corresponding heap and into at least one other heap; and determining (422) whether the predetermined amount of free space exists in each of the heaps between each associated lo pointer and associated hi pointer, allocating the predetermines amount of free space in each cf the plurality of heaps while maintaining segment order across segments in the plurality of heaps (502, 504, 506), wherein a segment is a block of data in a heap and the order dependent list contains segments entries to which are pointing the hi and lo pointers associated with each heap. The method of claim 5, further comprising the step of: when the predetermined amount of free space is found between all of the hi pointers and the lo pointers, adding (426) a segment to at least one of the heaps (502, 504, 506) in the found free space. The method of claim 5, further comprising the step of: repeating (424) the establishing, advancing and determining steps until the predetermined amount of free space is found or until reaching the end of the order dependent list for each respective heap (502, 504, 506). The method of claim 5, further comprising the step of: advancing at least one of the hi pointers to point to a seccnd next significant segment entry in the order dependent list whose segment entry contains a null-pointer into the hi pointers' corresponding heap and into at least one other heap, and where the second next significant segment is associated with one of the plurality of heaps (502, 504, 506), wherein the second next significant segment is at a higher location in the order dependent list that is associated with one of the plurality of heaps (502, 504, 506) than the location of the first next significant segment. The method of claim 5, wherein the step of advancing (408) the at least one lo pointer, includes the step of advancing at least one lo pointer corresponding to at least one minimum hi pointer to be equal to its corresponding minimum hi pointer; and wherein the step of advancing (410) the at least one hi pointer includes the step of advancing, for the at least one minimum high pointer in the plurality of heaps (502, 504, 506), at least one corresponding minimum hi pointer to point to a first next significant segment entry whose segment entry contain a non-null pointer into the hi pointer's corresponding heap and into at least one other heap (502, 504, 506). The method of claim 9, further comprising the step of: when the predetermined amount of free space is not found between all of the hi pointers and the lo pointers, keeping an existing value in the lo pointers associated with heaps (502, 504, 506) that do not have a corresponding minimum hi pointer, and keeping an existing value in the corresponding hi pointer that is not a minimum hi pointer. The method of claim 5, wherein free space in each of the plurality of heaps (502, 504, 506) is connected in a linked list (530, 532, 534). The method of claim 5, wherein the predetermined amount of free space is the same for each heap (502, 504, 506). The method of claim 5, wherein the predetermined amount of free space is different for each heap (502, 504, 506). The method of claim 13, wherein the determining step includes the steps of: checking each block of the free space between an associated lo pointer and associated hi pointer in ordering from largest to smallest; and using the first block of free space that is as large as the predetermined amount of free space. The method of claim 13, wherein the determining step includes the steps of: checking each block of the free space between an associated lo pointer and associated hi pointer in ordering from largest to smallest; and using the largest block of free space that is as large as the predetermined amount of free space. The method of claim 5, wherein at least two of the plurality of heaps (502, 504, 506) are of different sizes. The method of claim 5, further comprising the step of: receiving a sequence of inputs of the form: "alloc (V)" where "V" is a vector of integers, each representing the amount of space that needs to be allocated in the corresponding heap (502, 504, 506). The method of claim 17, further comprising the step of: interspersing the inputs with commands of "free (i)" where "i" is a sequence number referring to the i'th alloc in the input stream and meaning that the memory associated with that "alloc" should be freed.

Inventors: QUENELLE CHRISTOPHER D, SMITHLINE NEIL G, QUENELLE, CHRISTOPHER D., SMITHLINE, NEIL G.
Applicants: SUN MICROSYSTEMS INC, SUN MICROSYSTEMS, INC.
Application year: 1996
Main classification: G06F12
IPC codes: G06F9, G06F12