Solved

Real-World ASP.NET 2.0, Datasets, DAL, Dataview, and Disposal

Posted on 2007-11-26
6
995 Views
Last Modified: 2013-11-07
Greetings,

I'm rewriting an app, and am starting to worry about long term performance of the way I'm writing it. First, a little background, and please read all of this because I think it all comes into play. Google EE Linkers need not apply.

I'm using Subsonic as my DAL, and subclassing it for the most part. I'm trying to avoid using their collections within the page classes (although sometimes that's just so easy it's sick!), and wrapping things in my own DAL (as seen below).

Getting to my questions,

1.) When I return a DataSet, how is that destroyed? Does the GC come by at the end of the page and wipe all that up? If so, is it something I can rely on, or is it like ASP Classics, "Oh, we close all connections so you don't have to *wink wink*?

2.) Same thing with a DataView, and would it be better to return the dataset and work with that, or is it roughly equivalent

3.) Same thing with SubSonic COLLECTIONS

4.) Any recommendations on making my DAL a little leaner, meaner, and extensible?

Points will be awarded to those who

a.) Link me to PRECISELY what I'm looking for
b.) Engage and really try to understand what I'm trying to accomplish.

I've asked these types of "theory" or best practices questions before, and have been consistently disappointed with the Interaction. I would really like to LEARN here, not just quick fix, and not with people randomly linking me garbage that doesn't really apply (the quick points people).

Thanks in advance.
public class StatusControl

{

	public static DataView GetAllStatus()

	{

        DataSet ds0 = new DataSet();

        IDataReader i1 = SPs.SelectStatusAll().GetReader();

        ds0.Tables.Add("Status");

        ds0.Tables[0].Load(i1, LoadOption.Upsert);

        DataView dvView = ds0.Tables[0].DefaultView;

        return dvView;

	}

}

Open in new window

0
Comment
Question by:NauticalNonsense
  • 3
  • 2
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 20353392
1) Garbage collection is non-deterministic--you can't predict when it will run.

2) It is a pretty complex algorithm that takes into account all kinds of things, but doesn't use reference counting.

3) With local variables that aren't passed outside of a method, the reference variables will be automatically garbage collected.

4) If an object implements the IDisposable interface, you can control when the object is destroyed by calling the Dispose method.

Bob
0
 
LVL 7

Author Comment

by:NauticalNonsense
ID: 20354291
Hiya Bob, I see you around here an awful lot.

So what is the "best" way of doing this, or how is this commonly done? Is this something that I should even worry about?

It just seems like when I'm binding up a bunch of data in a class file, and letting that hang out there, .. well .. just doesn't seem efficient.

I've worked with more web companies than I can count, and most of what I've learned is on the job stuff and they all seem to do it the same way .. now that I'm building a my OWN site, I find myself thinking, "wait a minute, is this the RIGHT way to do it?"
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20354460
The garbage collector makes your job significantly easier, but it is not the "perfect" way of memory management.  If you use a lot of global references that last the entire life-time of the application, or module-level references that get created indescriminately, you could run into some serious memory problems.  

A good rule of thumb, though, when developing software is to not worry about every little detail of memory management, and work more on the process details.  Then, you can use a profiler to monitor memory usage.  Sometimes worrying about memory management and other such optimization steps can make your program run slower.  

I read something the other day that there isn't any "right" or "wrong" way to build web sites, there is just a "better" way.   If the site does what you need, then it serves a purpose.  If it can look better, and perform faster, then it is a bonus!!  Studying, reading, talking, learning, experimenting, failing, and succeeding some ways that you can learn more about the "better way".

If you want to use static classes or methods, you can use them very carefully.  The life-time of static variables changes drastically with web sites, and server memory.  Using static methods with local instance variables is a perfectly good way of accessing methods without instance variables.

Bob

0
 
LVL 7

Author Comment

by:NauticalNonsense
ID: 20354558
Bob, thanks for the dialogue.

The site is basically a Social Engineering type site. For example, on any given number of pages I need to pull repetitive data/code (user's photo, common controls), and then there is the whole personal profiling for people and their objects of possession .. there will likely be thousands of users, hundreds online at any given time, looking at other people's inventories, blogs, photo galleries, etc. All is heavily data-driven and customizable ... data caching will only take me so far since the data is so disparate.

I'm throwing pretty much everything that is reusable into class files to get the data, but it sounds like I might be better off considering user controls with the DAL closer to that... but then again, maybe .NET can handle the way I'm laying things out now. Arrrgh. :)

This is a project that I've been developing for 3 years, since ASP.NET 1.1 and I'm in the process of basically doing a total rewrite... looking for some "gotchas" in design and scalability. At the worst case I'll have a great DAL and everything well consolidated in one framework. The best case is that I'm dong the right thing and everything runs like a champ, but I guess I'm starting to get nervous.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20354592
It you are starting to feel nervous, then you need to think about stress testing your web site.

There are a few tools, and here is a representative list:

How do I stress test my ASP application?
http://classicasp.aspfaq.com/general/how-do-i-stress-test-my-asp-application.html

There is the ACT (Application Center Test) for web applications from Microsoft:

INFO: Application Center Test (ACT) Tests Your Web Applications by Simulating Load
http://support.microsoft.com/default.aspx/kb/307492

Bob
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now