Skip to content

9. Using()/IDisposable, tasklist /m “mscor*”, in-proc/out-of-proc

February 23, 2011

25. How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization? The using statement defines a scope, outside of which an object or objects will be disposed. The CLR automatically releases the memory used to store objects that are no longer required. The release of memory is non-deterministic, memory is released whenever the CLR decides to perform garbage collection. However it is a best practice to release limited resources such as file handles and network connections as quickly as possible. The using statement allows the programmer to specify when objects that use resources should release them. The object provided to the using must implement the IDisposable interface. This interface provides the Dispose method, which should release the object’s resources.  A using statement can be exited either when the end of the using statement is reached or if an exception is thrown and control leaves the statement block before the end statement. Deterministic finalization is supported that upon ending or exiting the using statement all objects and components that are encapsulated are cleaned up immediately. In other words the object will be disposed at the end of the scope of the using statement.

26. What does this useful command line do? tasklist /m “mscor*”? This is a command line tool in Windows that shows a list of all running processes. Lists all of the processes running on the machine that begin with “mscor“, the * is a wildcard character. Examples are mscoree.dll, mscoreei.dll…

27. What is the difference between in-proc and out-of-proc? In process is within the same process area as a client application, giving a performance advantage but a stability disadvantage. Out of process works outside the clients memory space, providing a stability advantage but takes a performance hit. Marshaling may also be required. Executables are out of process servers and dynamic link libraries are in process servers. In ASP.NET in process means the session state is managed in process and if the process is recycled session state is lost. The performance of session state, the time it takes to read and write to the session state dictionary will be much faster when the memory read to is in process, as cross process calls add overhead when data is marshalled back and forth or possibly read from SQL Server.

Happy Programing! =)

Source: mainly MSDN.

Advertisements

From → OOP

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: