garbage collection - Managed and Unmanaged resources in .Net -


i confused between managed , unmanaged resources in .net programming. developing vb.net application. read in microsoft website that, if use managed resources garbage collector dispose , if use unmanaged resources need call dispose. didn’t answer following questions anywhere.

  1. how can differentiate resources used code “managed” , “unmanaged”? can have list of resources belonging managed , unmanaged resources?
  2. whether resources used/allocated before creation of objects or after creation of objects?
  3. in case of unmanaged resources whether resources disposed once scope gets closed or should dispose after closing of scope?

  1. if class inherits idisposable unmanaged or contains unmanaged
  2. not sure mean, @ ctor, creation of object, cant before, consider ctor after? (o.c. unless stated otherwise)
  3. best practice inheriting idisposableanywhere use managed code, .net having gc unless somehow lock unmanaged res. should ok.

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -