Refer to the Enclave Memory Measurement Tool section in the SGX Developer Reference for Linux* (available in Intel® SGX Linux Latest Docs) for 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:
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.
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