Skip to content

How can I correctly free a pointer in unmanaged memory from managed code? #8526

Answered by ankofl
ankofl asked this question in Q&A
Discussion options

You must be logged in to vote

I apologize for the ambiguity

I write in C# NET.9 and I call C++ libraries compiled using header libraries via DllImport .h-files of CGAL. I am interested in the question: when I created a Mesh object (Polyhedron_3) in C++ code and sent a pointer to this object to C# code, how would it be correct to free memory from C# inside the unmanaged C++ code in which the Mesh object was created?

I tried to do it via:

delete mesh;
mesh = null ptr;

But I am not sure that this will be correct.

Maybe Polyhedron_3 and Surface_Mesh objects have specialized methods to free up the memory they occupy?

Thanks!

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ankofl
Comment options

Answer selected by lrineau
@lrineau
Comment options

@ankofl
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants