Profile Picture
IT Made Easy
The site provides some rough IT Notes that make your life easier. The site currently has notes on HTML, CSS, Regex, OOPS, JS, JQuery, PHP, Java, ASP.NET, C#, Database, Linux, URL Rewrite, SEO, Project Management and Hosting. Please do share this site if you like.

Memory Allocation and Performance

  • Separate allocations of memory for the reference and object
  • The object consumes as many bytes as its fields, plus additional administrative overhead (typically 12 bytes).
  • Each reference to an object requires an extra 4 or 8 bytes, depending on whether the .NET runtime is running on a 32- or 64-bit platform.
  • The float and double are called floating-point types and are typically used for scientific calculations.
  • The decimal type is typically used for financial calculations, where base-10-accurate arithmetic and high precision are required.
  • For reference types, equality, by default, is based on reference (Exception : String), as opposed to the actual value of the underlying object as in case of value types
  • All array indexing is bounds-checked by the runtime
  • Stack for local variables and parameters. An example is a reference to an object which is local
  • Heap for objects
  • If the instance was declared as a field within an object, or as an array element, that instance lives on the heap.
  • An object is eligible for deallocation as soon as nothing references it
  • The heap is also used to store static fields and constants and will live on until the application domain is torn down
  • An unreferenced object is eventually collected by the garbage collector. It can’t be explicitly be removed
  • Whenever an unboxing or downcast occurs, the runtime checks the type dynamically.
  • Generic collections are better than collections iff it stores value type and has large entries. For reference type they are same. Generally former is better. Example List<T> is better than Array List for value entries > 500
  • Presently, .NET does not provide a mechanism for constraining a generic type parameter to be serializable

IT Notes

by VinodSebastian

IT Downloads