Use the C++ operator "delete" to free object memory inside an enclave.
- Enclave includes C++ objects like classes and unique_ptrs.
- Unable to determine how to free the memory for C++ objects in the enclave.
Within enclaves, use the C++ delete operator to free memory that was previously allocated to classes, unique_ptrs, and other objects using the new operator. The operators new and delete behave the same within enclaves as they do in regular C++ applications.
Sample Code:
test.h:
class{
private:
ClassA* ca;
unique_ptr<ClassB> cb;
}
test.cpp:
//Use new to instantiate the class and unique_ptr objects
ca = new ClassA*(...);
cb = make_unique<ClassB>(function(...));
//Use delete to free the memory previously allocated with new
delete ClassA;
delete cb;
Refer to the C++ Language Support section in the Intel® Software Guard Extensions (Intel® SGX) SDK Developer Reference Guide for your operating system for more information.
- Intel SGX SDK Developer Reference Guide for Windows*
- The Intel SGX Developer Reference for Linux is in the Documentation folder of the latest release of the Intel® Software Guard Extensions SDK for Linux*.