Memory Requirements For Your Title
An AMT title requires a certain amount of memory to operate. Memory allocated
to a given title is broken down internally by AMT into the following
components:
- C stack
- C heap
- AML stack
- AML heap
- AML code
- C code
Figure 1 shows how the various components of a title are stored in memory.

Figure 1 Memory components of an AMT title
C stack
The C stack is an area of memory that holds temporary information used while
your title is running. The C function calling chain (and some associated data)
and any local variables are kept here. Its size is dependent on the particular
system configuration. There is no way for either the end user or the developer
to change the amount of memory allocated to the C stack.
C heap
The C heap is the standard C heap from which memory can be allocated using
system calls such as NewPtr, NewHandle (under Mac OS) and GlobalAlloc (under
Windows). When your title loads a media item, it allocates a block of memory
from the C heap to hold that item.
Under Mac OS, the size of the C heap can be calculated by totaling the sizes of
the other memory areas, and subtracting this total from the overall amount of
memory allocated to the title. For example, if you allocate 5 MB to your title,
and 3 MB is required for the other memory areas, then 2 MB is allocated to the
C heap.
Under Windows, the size of the C heap is the amount of free memory available to
Windows, minus the sizes of the other memory areas. For example, if you have 8
MB free on your Windows machine, and the other memory areas of your title use 3
MB, then 5 MB is allocated to the C heap. Because the total amount of free
memory will vary, depending on the number of other Windows applications that
are running when your title is launched, the size of the C heap will vary each
time you run your Windows titles.
This means that you can change the size of the C heap by changing the sizes of
the other memory areas. Methods to change the sizes of other memory areas are
discussed later in this Technote.
AML stack
The AML stack is an area of memory that holds temporary information used while
your title is running . The AML calling chain and any local variables are kept
here.
For titles built with RuntimeMaker or AMTPE, the AML stack default size is 1K.
For titles built with AMT, the Macintosh AML stack default size is 128K, and
for a Windows title the AML stack default size is 64K.
There is usually no need to change this value for titles built with either the
minimal or standard AMT engines. If there is a lot of recursion in your code,
or for titles built using a custom engine, it may be helpful to increase this
value.
Methods to change the size of this component are discussed later in this
Technote.
AML heap
The AML heap is an area used to load any static or dynamically created objects
for your title (see pages 4-26 through 4-28 of the AMTPE User's Guide
for more details on static and dynamic objects). For titles built with Runtime
Maker or AMTPE, the default size is 640K. For AMT 2.0 titles, a minimum value
of 256K must be allocated to this component (this can be changed - see the
section "How Do I Change AML Heap/Stack Memory Allocated To My Title").
This value should be increased or decreased depending on the number of objects
the title is using. Because it is not easy to estimate ahead of time how much
space a title will need, there are ways (discussed below) to calculate an
approximate value.
The default AML heap size for the AMT application is 2048K.
AML code
The AML code memory area contains all the compiled AML source code for your
title. The size of this area is dependent on how much AML code a title
contains. There is no way for the end user to change the size of this. AMTPE
developers will often be able to optimize the number of AML objects in a
project, and thus reduce the amount of AML code generated. Techniques for
achieving this can be found, among other places, in Chapter Three of the AMTPE
User's Guide, and on
Marc van Olmen's web site.
C code
The C code component contains all the C code for your title. Its size will
depend, of course, on how much C code the title contains.
A Note about Screen Bit Depths
When you load media items that have a visible component, in particular PICT
images, the amount of external memory that they require depends on the bit
depth of the screen on which the title is executing. The exact amount of
external memory required to store a PICT file can be calculated by the
formula:
image width x image height x screen bit depth
Therefore, to display an image which is 320 x 480 pixels in size on an 8-bit
screen, your title will need 320 x 480 x 8 = 1,228,800 bits of memory, which is
153,600 bytes, which is 150K. To display the same 320x480 pixel image on a
16-bit screen requires 300K of external memory. It is important to note that
the amount of external memory is dependent on the bit depth of the screen that
the title is running on, and not the bit depth of the original PICT image. A
detailed explanation of why this is can be found in
Marc van Olmen's web paper.
- Note:
- When your title runs under Mac OS, the total amount of external memory
available is fixed. Under Windows, the size of the external memory pool will
vary, depending on the amount of free memory available to Windows when the
title is launched.