How Should Object Memory be Freed Inside an Intel® Software Guard Extensions (Intel® SGX) Enclave?
Content Type: Product Information & Documentation | Article ID: 000059846 | Last Reviewed: 08/10/2021
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.