Browse Prior Art Database

Fixed-Size Dynamic Memory Allocation and Deallocation

IP.com Disclosure Number: IPCOM000110888D
Original Publication Date: 1994-Jan-01
Included in the Prior Art Database: 2005-Mar-26
Document File: 2 page(s) / 74K

Publishing Venue

IBM

Related People

Chen, C: AUTHOR [+2]

Abstract

A method for improving the performance of fixed-size dynamic memory allocation and deallocation is disclosed. Allocation performance is improved by using constant expression evaluation at compile time to determine the proper allocation request size. Deallocation is improved by storing the memory pool size identifier in the address of the memory block rather than within the memory block itself.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 53% of the total text.

Fixed-Size Dynamic Memory Allocation and Deallocation

      A method for improving the performance of fixed-size dynamic
memory allocation and deallocation is disclosed.  Allocation
performance is improved by using constant expression evaluation at
compile time to determine the proper allocation request size.
Deallocation is improved by storing the memory pool size identifier
in the address of the memory block rather than within the memory
block itself.

      When a block of memory is to be allocated, a mechanism must be
provided to determine the proper fixed memory allocation size for the
request.  The size of the data structure that will reside in the
block must be compared with the fixed allocation sizes.  The smallest
fixed allocation size that will contain the data structure is then
selected.  Thus memory allocation involves the following steps:

1.  Determine fixed allocation size based on requestor's data
    structure size.

2.  Find the next free block of the proper fixed allocation size.

3.  Return the address of the free block to the requestor.

      An array of addresses to free blocks is maintained for each
allocation size.  The first step determines which array of addresses
needs to be used.  In C this step can be done by the compiler with
the following code:

#define SIZE_MEM_TYPE_0 2

#define SIZE_MEM_TYPE_1 7

#define SIZE_MEM_TYPE_2 8

#define SIZE_MEM_TYPE_3 10

#define SIZE_MEM_TYPE_4 12

#define SIZE_MEM_TYPE_5 14

#define SIZE_MEM_TYPE_6 20

#define SIZE_MEM_TYPE_7 26

#define SIZE_MEM_TYPE_8 32

#define SIZE_MEM_TYPE_9 40

#define SIZE_MEM_TYPE_A 50

#define SIZE_MEM_TYPE_B 64

#define SIZE_MEM_TYPE_C 128

#define SIZE_MEM_TYPE_D 256

#define SIZE_MEM_TYPE_E 1024

#define SIZE_MEM_TYPE_F 2048

#define S(obj) \

        (sizeof(obj)>>2)

#define SIZEOF(mem_request) \

          S(mem_request) <= SIZE_MEM_TYPE_0 ?  0 : \

          S(mem_request) <= SIZE_MEM_TYPE_1 ?  1 : \

          S(mem_request) <= SIZE_MEM_TYPE_2 ?  2 : \

          S(mem_request) <= SIZE_MEM_TYPE_3 ?  3 : \

          S(mem_request) <= SIZE_MEM_TYPE_4 ?  4 : \

          S(mem_request) <= SIZE_MEM_TYPE_5 ?  5 : \

          S(mem_request) <= SIZE_MEM_TYPE_6 ?  6 : \

          S(mem_request) <= SIZE...