Sign in

docs ILE Concepts

User-Created Heaps

User-Created Heaps

User-Created Heaps

You can explicitly create and discard one or more heaps by using ILE bindable APIs. This gives you the capability of managing the heaps and the dynamic storage that is allocated from those heaps.

For example, the system may or may not share dynamic storage that is allocated in user-created heaps for programs within an activation group. The sharing of dynamic storage depends on the heap identifier that is referred to by the programs. You can use more than one heap to avoid automatic sharing of dynamic storage. In this way you can isolate logical groups of data. Following are some additional reasons for using one or more user-created heaps:

  • You can group certain storage objects together to meet a one-time requirement. Once you meet that requirement, you can free the dynamic storage that was allocated by a single call to the Discard Heap (CEEDSHP) bindable API. This operation frees the dynamic storage and discards the heap. In this way, dynamic storage is available to meet other requests.
  • You can free multiple dynamic storage that is allocated at once by using the Mark Heap (CEEMKHP) and Release Heap (CEERLHP) bindable APIs. The CEEMKHP bindable API allows you to mark a heap. When you are ready to free the group of allocations that were made since the heap was marked, use the CEERLHP bindable API. Using the mark and release functions leaves the heap intact, but frees the dynamic storage that is allocated from it. In this way, you can avoid the system overhead that is associated with heap creation by re-using existing heaps to meet dynamic storage requirements.
  • Your storage requirements may not match the storage attributes that define the default heap. For example, the initial size of the default heap is 4K bytes. However, you require a number of dynamic storage allocations that together exceed 4K bytes. You can create a heap with a larger initial size than 4K bytes. This reduces the system overhead which would otherwise occur both when implicitly extending the heap and subsequently accessing the heap extensions. Similarly, you can have heap extensions larger than 4K bytes. For information about defining heap sizes, see Heap Allocation Strategy and the discussion of heap attributes.

You might have other reasons for using multiple heaps rather than the default heap. The storage management-bindable APIs give you the capability to manage the heaps that you create and the dynamic storage that is allocated in those heaps. For information about the storage management APIs, see the API topic collection in the Programming category of the IBM® i Information Center.