Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Using IDisposableUsing IDisposable
Previous
 
Next
New Post
5/3/2007 6:06 AM
 

Hi, I noticed in all dnn module building examples nobody really uses IDisposible for objects & methods.
Is there a reason for this?
Is it possible to use IDisposible, I want to be sure I clear out stuff from memory...

 
New Post
5/3/2007 6:39 AM
 

Most of things do not need to be disposed. Disposing .NET objects with only .NET types  is not really meaningful as they still need to be garbaged.... A counter example is the SQLConnection and his pooling that needs to be disposed if you are running multiple threads at a same time, as each connection use a pool slot, you need to dispose the object to be sure to free the slot used, otherwise you could run out of space.

So in most cases IDisposable is useful when the object is using interacting with non managed objects, that can not free his memory from himself. Like SQL Pools, Twain drivers, some Windows API, ...

 

 
New Post
5/3/2007 6:44 AM
 

Well, lets say you have a standard DNN module. 
Then you have all the methods like AddSomething, GetSomething, DeleteSomething, etc.
Each one of them will create connections with the database.
So wouldn't you run out of connections on busy websites without disposing of them?

 
New Post
5/3/2007 6:54 AM
 

The SqlConnection needs to be disposed indeed. (SqlConnection.Close() is not enough, the pool will only be freed when the garbage collector will catch that object and dispose it before deleting it). It can takes a while before the collector is called 10, 20, 30 seconds and depending on the pool size (if you are using pooling with SQL) and the number of requests you can reach the limit.

So now I don't know about your code samples, and I didn't read the data accessors of DNN, but what I meant is that a class that has two INT properties, and three strings does not need to have a IDisposable function.

 

 

 

 
New Post
5/3/2007 7:00 AM
 

That's what I like to know...

Does DNN take care of this, or is it (theoretically) possible to run out of connection's on a DNN site.
And if so, how busy should a site be before you run out of connections or memory or whatever.

Cause we have this site which first reached the connection pool limit, so I assume it didn't close the connections.
After that I tried to improve the connection part by using DNN's DAL method, and now I do not run out of connections anymore, but the site still seems to use a lot of memory. So I thought disposing of objects, or setting object = nothing might help this a bit.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Using IDisposableUsing IDisposable


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out