Heap memory

The section titled “Heap memory” in Chapter 11, “Configuring Memory” should include the following:

The syntax for heap memory per user is:

sp_configure 'heap memory per user', amount_of_memory

By default, the amount of memory is in 2K pages. This example specifies 10 2K pages of heap memory per user:

sp_configure 'heap memory per user', 10

You can also specify the amount of memory in the number of bytes per user. For example, the following example specifies that each user connection is allocated 4K bytes of heap memory:

sp_configure 'heap memory per user', 0, "4K"

At the initial Adaptive Server configuration, 1MB is set aside for heap memory. Additional heap memory is allocated for all the user connections and worker processes for which the server is configured, so the following configuration parameters affect the amount of heap memory available when the server starts:

The global variable @@heapmemsize reports the size of the heap memory pool, in bytes.


Calculating heap memory

To calculate how much heap memory Adaptive Server sets aside, perform the following:

((1024 * 1024) + (heap memory in bytes)* (number of user connections + number of worker processes) ) * 1.05

The initial value of (1024 * 1024) is the 1MB initial size of the heap memory pool. The final multiplier of 1.05 accounts for an approximate 5 percent overhead for internal structures.

For example, if your server is configured for:

@@heapmemsize reports 1378304 bytes.

And the estimated value using the formula above, is:((1024 X 1024) + (4 * 1024 * 50)) X 1.05 = 1316044.80

Now, if you increase the number of user connections, the size of the heap memory pool increases accordingly:

sp_configure 'user connections', 100

@@heapmemsize reports 1716224 bytes.The estimated value in this case comes out to be:((1024 * 1024) + (4 * 1024 * (100 + 25) ) * 1.05 = 1638604.80

If your applications were to fail with the following error message:

There is insufficient heap memory to allocate %ld bytes. Please increase configuration parameter 'heap memory per user' or try again when there is less activity on the system.

You can increase the heap memory available to the server by increasing one of:

Sybase recommends that you first try to increase the heap memory per user configuration option before you increase number of user connections or number of worker processes. Increasing the number of user connections and number of worker processes first consumes system memory for other resources, which may cause you to increase the server’s max memory.See Chapter 5, “Setting Configuration Parameters” in the System Administration Guide for more information on how to make memory related configuration option changes.