Is native resource term equal to unmanage resource in C#? #137
-
Hello, You wrote in your book native resource |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Mostly yes. A native resource is always an unmanaged resource, but not necessary the other way around. A managed resource is a resource managed by the garbage collector, an unmanaged resource is not managed by the garbage collector. A native resource typically is allocated by using Platform Invoke, using a native API of the operating system. Because these APIs allocate native memory (using the native heap, not the managed heap), it's also an unmanaged resource. |
Beta Was this translation helpful? Give feedback.
Mostly yes. A native resource is always an unmanaged resource, but not necessary the other way around.
A managed resource is a resource managed by the garbage collector, an unmanaged resource is not managed by the garbage collector.
A native resource typically is allocated by using Platform Invoke, using a native API of the operating system. Because these APIs allocate native memory (using the native heap, not the managed heap), it's also an unmanaged resource.