What is WCF?




First let us give a short answer to this: - “WCF (Indigo was the code name for WCF) is a unification of .NET framework communication technologies “.WCF is a unification technology, which unites the following technologies:-
• NET remoting
• MSMQ
• Web services
• COM+.
Below figure depicts WCF fundamentals pictorially.

---------------------------------------------------------------------
2)What are bindings?
Ans)
Bindings specify how a Windows Communication Foundation (WCF) service endpoint communicates with other endpoints. At its most basic, a binding must specify the transport (for example, HTTP or TCP) to use. You can also set other characteristics, such as security and transaction support, through bindings.
Here we have 9 types of binidings and this binding classes are under the
System.ServiceModel namespase
Binding type
Class name under  “System.ServiceModel” namespase

Basic Binding

BasicHttpBinding

TCP Binding

NetTcpBinding

Peer Network Binding

NetPeerTcpBinding 

IPC Binding

NetNamedPipeBinding

Web Service (WS)  Binding

WSHttpBinding

Federated WS Binding

WSFederationHttpBinding

Duplex WS Binding

WSDualHttpBinding

MSMQ Binding

NetMsmqBinding

MSMQ Integration Binding

MsmqIntegrationBinding



-------------------------------------------------------------------------------------------------------
3)      Which specifications does WCF follow?
Ans)

WCF supports specifications defined by WS-* specifications. WS-* specifications are defined together by Microsoft, IBM, SUN and many other big companies so that they can expose there service through a common protocol. WCF supports all specifications defined we will understand them one by one.

1.Messaging (WS-Addressing):- SOAP is the fundamental protocol for web services. WS Addressing defines some extra additions to SOAP headers, which makes SOAP free from underlying transport protocol. One of the good things about Message transmission is MTOM, also termed as Message Transmission Optimization Mechanism. They optimize transmission format for SOAP messages in XML-Binary formant using XML optimized packaging (XOP). Because the data will sent in binary and optimized format, it will give us huge performance gain.

2.Security (WS-Security, WS-Trust, and WS-Secure Conversation): - All the three WS- define authentication, security, data integrity and privacy features for a service.

3.Reliability (WS-Reliable Messaging): - This specification ensures end-to-end communication when we want SOAP messages to be traversed back and forth many times.

4.Transactions (WS-Coordination and WS-Atomic Transaction): - These two specifications enable transaction with SOAP messages.

5.Metadata (WS-Policy and WS-Metadata exchange): - WSDL is a implementation of WS-Metadata Exchange protocol. WS-Policy defines more dynamic features of a service, which cannot be expressed by WSDL.
We have stressed on the WS-* specification as it is a specification which a service has to follow to be compatible with other languages. Because WCF follows WS-* specifications other languages like JAVA , C++ can also exploit features like Messaging , Security , Reliability and transactions written in C# or VB.NET. This is the biggest achievement of WCF to integrate the above features with other languages. 

Garbage Collection


Garbage Collector provide automatic Memory Management in .NET. It is Component of .net CLR
(Common Language Runtime)
Follow are the advantages of Garbage Collection
  • It allocates memory objects on heap efficiently.
  • Develop application without worrying about releasing of memory.
  • Reclaims object that are no longer in use, clear their memory and keep it available for future memory allocations.
  • Memory Safe as cannot direct access memory of other objects.

Fundamentals of Memory –

  • Each process has its own, separate virtual address space; on 32-bit computers each process has a 2-GB user-mode virtual address space.
  • Garbage collector is responsible for Allocation and frees virtual memory on Managed Heap.
  • Virtual memory can be in three state – FREE , RESERVED, COMMITTED
  • We can run out of memory if run out of virtual address space to reserve or physical space to commit.

When Garbage Collection runs-

  • System has low physical memory
  • The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This means that a threshold of acceptable memory usage has been exceeded on the managed heap. This threshold is continuously adjusted as the process runs.
  • The GC.Collect method is called. In almost all cases, you do not have to call this method, because the garbage collector runs continuously. This method is primarily used for unique situations and testing.

What is Managed Heap?

  • Garbage Collector allocates segment of memory for objects which is called Managed Heap.
  • Each managed process has managed heap.
  • Win32 VirtualAlloc and VirtualFree functions called by garbage collector to reserve or release segment of memory.
  • After triggering Garbage Collector, it reclaims the memory occupied by dead objects and compact live objects so they live together. This process will make heap smaller.
  • Heap can be considered as : Large Object Heap and Small Object Heap
  • Objects with size 85000 bytes and larger will go on Large Object Heap.

Generations

  • Heap is organized into generations which can easily handle long live objects and short lived objects.
  • There are three generations – Generation 0 , Generation 1, Generation 2
  • Generation 0 – This is youngest generation for newly created objects. Garbage collector reclaims memory from this Generation most frequently. For e.g. Temporary variables, new objects
  • Generation 1 – Short lived objects are resides in this generation. As soon as Garbage collector starts reclaiming memory, objects from Generation 0 will move to Generation 1 if they are still in use.
  • Generation 2 – Long lived objects are resides in this generation. For e.g. Static variables.