Intel® Software Guard Extensions (Intel® SGX)
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

Free memory inside the enclave

DylanWang
Novice
361 Views

Hi, Team.

I'm new to SGX.

I'm not that familiar with the memory management inside the enclave.

Since I use the C++11 feature (like unique_ptr) and class objects in my sample code, how should I free memory? For class objects, some other objects are embedded.

Sample code:

test.h

class{
private:
  ClassA* ca;
  unique_ptr<ClassB> cb;
  unique_ptr<ClassC> cc;
}
 
test.cpp
ca = new ClassA*(...); // delete?
cb = make_unique<ClassB>(function(...));
cc = make_unique<ClassC>(function(...)); // Do I need to do something for this smart pointer?

 

0 Kudos
1 Solution
JesusG_Intel
Moderator
343 Views

Hello DylanWang,

 

You can use delete to free up memory from the class and unique_ptrs just as you would in non-enclave code.

 

Refer to the SGX SDK Developer Reference Guide for your OS, section C++ Language Support, for more information.

 

Sincerely,

Jesus G.

Intel Customer Support

 

View solution in original post

3 Replies
JesusG_Intel
Moderator
344 Views

Hello DylanWang,

 

You can use delete to free up memory from the class and unique_ptrs just as you would in non-enclave code.

 

Refer to the SGX SDK Developer Reference Guide for your OS, section C++ Language Support, for more information.

 

Sincerely,

Jesus G.

Intel Customer Support

 

DylanWang
Novice
304 Views
JesusG_Intel
Moderator
330 Views

This thread has been marked as answered and Intel will no longer monitor this thread. If you want a response from Intel in a follow-up question, please open a new thread.


Reply