.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

Why doesn't the .NET runtime offer deterministic destruction?

Posted By :Jegan R     Posted Date :November 03, 2010    Points :10   Category :.NET Framework 
Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn't find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn't get notified immediately when the final reference on an object goes away - it only finds out during the next sweep of the heap.
Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep.



You can also find related Interview Question to Why doesn''t the .NET runtime offer deterministic destruction?  below: 

Is the lack of deterministic destruction in .NET a problem?

  
It's certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way for the client to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of reference-counting or ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime offers no help with this (More...)

What is the Common Language Runtime (CLR)?

  
The Common Language Runtime is the execution engine for .NET Framework applications.
It provides a number of services, including the following:
1. Code management (loading and execution)
2. Application memory isolation
3. Verification of type safety
4. Conversion of IL to native code
5. Access to metadata (enhanced type information)
6. Managing memory for managed objects
7. Enforcement of code access security
8. Exception handling, including cross-language exceptions
9. Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data)
10. Automation of object layout
11. Support for developer services (profiling, debugging, and so on) (More...)

How does non-deterministic garbage collection affect my code?

  
For most programmers, having a garbage collector (and using garbage collected objects) means that you never have to worry about deallocating memory, or reference counting objects, even if you use sophisticated data structures. It does require some changes in coding style, however, if you typically deallocate system resources (file handles, locks, and so forth) in the same block of code that releases the memory for an object. With a garbage collected object you should provide a method that releases the system resources deterministically (that is, under your program control) and let the garbage collector release the memory when it compacts the working set. (More...)

Explain why java doesn't support multiple inheritance.

  
Java does not support multiple inheritances. To avoid ambiguity problem - Diamonds of Death - and complexity of multiple inheritance.

The Diamond of Death is a problem without clarity. The Diamond problem is:

Two classes Two and Three inherit from class One. Class Four inherits from both Two and Three. When a method in Four invokes a method that is defined in One, and Two and Three have overridden that method in different way, the ambiguity and complexity occurs - through which class does it inherits: class Two or class Three?

Like wise if it is encouraged to have more than two classes to inherit, the ambiguity raises which leads to future conflict of applications. (More...)

How to find the current application file path while runtime?

  
System.Reflection.Assembly.GetExecutingAssembly().Location (More...)

Which design pattern to use if i needed to add additional responsibilities at runtime?

  
Decorator Pattern design pattern is use if i needed to add additional responsibilities at runtime (More...)

How to format a grid at runtime based on some condition

  
i think we can do that by using
if(e.row.column[1].text>10)
{
e.row.backgroundColor="green"
}

wat say?? (More...)

How can I change master page at runtime

  
The Pre_Init event is a key event to examine if we want to change the master page file programmatically.

Example:

using System;
using System.Web.UI;

public class BasePage : Page
{
public BasePage()
{
this.PreInit += new EventHandler(BasePage_PreInit);
}

void BasePage_PreInit(object sender, EventArgs e)
{
MasterPageFile = "~/Master1.master";
}
}

We get error "The 'MasterPageFile' property can only be set in or before the 'Page_PreInit' event." If we try to change master page in any other event than Pre_Init.



(More...)

Which is the design pattern that is type-safe and still extensible on runtime?

  
Decorator Pattern design pattern that is type-safe and still extensible on runtime (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend