# “Reaching heap limit”, what can I do?

The Java language (in which YAAC is written) works on the concept of a “heap” of available memory that can be doled out in pieces and the individual pieces returned to the heap when done using them. However, if a large amount of memory is allocated from the heap and not returned, the program can become extremely slow or even freeze up entirely when trying to allocate more memory for even simple operations (such as executing menu commands).

YAAC uses heap memory long-term to:

- keep copies of received messages for a specified retention interval
- render terrain (elevation) maps and raster overlays

Other uses of the heap are short-term and should not cause a strain on the available memory.

If you are seeing the “Reaching heap limit, lowering message retention limit” dialog, it means that the heap is running out of available memory. Prior to the introduction of this error message, YAAC would simply crawl to a halt and freeze; now, YAAC will attempt to protect itself by adjusting the one parameter under YAAC's control, which is how long to keep old message traffic in memory before deleting those messages as obsolete.

However, if you are:

- receiving traffic from a large number of stations or at a high message rate,
- are using high-resolution (1-arc-second) terrain data, or
- are using large raster map overlay images,

you may need more memory than merely lowering the message retention limit will give you. In that case, you need to change the way you start YAAC to allocate more memory to it. The Java runtime has a “reasonable” default heap limit (typically around 256 megabytes of memory, but varying depending on the version of the Java runtime you are using and the operating system). If this default is not sufficient, Java allows you to specify a larger heap limit with the `-Xmx` command-line option, for example `java -Xmx512m -jar YAAC.jar`

would start YAAC with a heap limit of 512 megabytes. You can specify any number here, but do not specify less than the system default, and it is recommended not to specify more than half the total physical memory in your computer (to allow some memory for your operating system and the parts of the Java runtime that are not counted against the heap limit).

If you have been starting YAAC by double-clicking on the YAAC.jar file in your system's file explorer, you will need to set up a desktop shortcut where you can explicitly specify the java invocation command to include the memory limit option, using the `javaw` command to invoke the Java runtime for a windowed desktop program.