Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

Free memory inside the enclave

DylanWang
Novice
834 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
816 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

0 Kudos
3 Replies
JesusG_Intel
Moderator
817 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

 

0 Kudos
DylanWang
Novice
777 Views
0 Kudos
JesusG_Intel
Moderator
803 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.


0 Kudos
Reply