Article ID: 000088062 Content Type: Troubleshooting Last Reviewed: 02/08/2022

How Do I Set the Stack and Heap in the Enclave Configuration File to Allocate Sufficient Memory for Enclaves?


Use the "sgx_emmt" tool to determine the amount of stack and heap memory to allocate for an enclave in the enclave configuration file.

  • In the enclave configuration file, specified the StackMaxSize and HeapMaxSize to 32 GB each to ensure enough memory is allocated for the enclave.
  • Compilation failed because the requested memory is too large.

Refer to the Enclave Memory Measurement Tool section in the SGX Developer Reference for Linux* (available in Intel® SGX Linux Latest Docsfor details on using sgx_emmt to measure the real usage of protected memory by the enclave at runtime.

Currently, the enclave memory measurement tool provides the following functions:

  1. Get the stack peak usage value for the enclave.
  2. Get the heap peak usage value for the enclave.
  3. Get the reserved memory peak usage value for the enclave.

The tool reports the size of the memory usage in KB. After you get accurate memory usage information for your enclaves, edit the enclave configuration file based on this information to make full use of the protected memory.

Additional information

If the StackMaxSize and HeapMaxSize in the enclave configuration file are more than the available memory in the system, compilation or runtime memory errors may occur.

The latest SGX Developer Reference for Linux is in Intel® SGX Linux Latest Docs