Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

managed and unmanaged

if a .net dll contains both managed and unmanaged code , how does the code will be converted to CIL and how CLR allocate and manages the memory

like image 539
Raghav Avatar asked Aug 24 '26 00:08

Raghav


1 Answers

The unmanaged code is by definition not managed by the CLR. It will not be converted to CIL, and the CLR will neither allocate nor manage memory for it. That only happens for the managed code.

When you write unmanaged code in a .NET assembly, you're instructing the compiler and the run-time that you want to take matters into your own hands. You become responsible for memory management, just as if you were writing native code.

like image 86
Cody Gray Avatar answered Aug 25 '26 12:08

Cody Gray