I have a C # application that uses a third-party DLL (closed source) via p / invoke.
During some of these calls, the DLL allocates memory using the new / operator new [] operator and returns a pointer used to read the results.
This memory is never freed by the DLL after it is allocated and returned. How can I execute the equivalent of my own delete / operator delete [] operator in C #?
. DLL , HeapCreate() . , , DLL. , DLL malloc .
, DLL, free(). DLL DLL- CRT, CRT, DLL CRT.
, GetProcessHeaps(). , , , . DLL, , , C ++. .NET, :)
::operator new, P/Invoke ::operator delete, (, , DLL CRT). - AClass *p = new AClass, delete p P/Invoke, , ( - , new/). ++/CLI, , (, , , delete P/Invoke, , , ++/CLI, ).
::operator new
::operator delete
AClass *p = new AClass
delete p
delete
, , DLL Managed ++/CLI, .
I don't know if you can do this with unmanaged code, but a separate application domain may be the answer. Download it in your own memory space and simply delete the entire application domain when done.
Source: https://habr.com/ru/post/1762566/More articles:Reading and displaying a text document - javascriptWhy is it so difficult to print a webpage correctly? - htmlDisable default click event (WinAPI) - c ++IE8 sets compatibility mode when inserting data into div - jqueryImprove mmap performance over memory cards - c ++You should consolidate these database tables. - databaseSelect only the fourth Sunday of each month - c #Problem with programming ... Digit Sums - algorithmDatasnap vs SoapServer - delphiPhp mysql, help help help help - sqlAll Articles