Are dataset automatically stored in memory?
Does the dispose() method automatically dispose of the dataset in the code
below?
Do I have to dispose a dataset from memory or does the dataset dispose
itself when not in use?
I know I can use the clear method, but that just clear the data within
dataset not dispose of the dataset all together right?
*****Code Ex.
Public Overloads Function RetrievePersona lization(ByVal AccountID As
Integer) As DataRow
Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID",
SqlDbType.Int, 4)}
parameters(0).V alue = AccountID
Dim Account As DataSet
Try
Account = RunProcedure( "GetStudentPers onalization", parameters, "Account")
Return Account.Tables( 0).Rows(0)
Account.Dispose ()
Finally
If Not Account Is Nothing Then
Account.Dispose ()
End If
End Try
End Function 11 2560
Hi Leon:
As far as memory is concerned, you do not have to Dispose any object.
The CLR manages memory and will periodically reclaim unused memory
with a garbage collector. This includes the DataSet and the data in a
DataSet. Calling Dispose does not hurry this process along.
Dispose is for unmanaged resources, like file handles and database
connections. The rule of thumb is to call Dispose on any and every
object that implements IDisposable. Unfortunately, the DataSet
inherits from MarshalByValueC omponent which gives the DataSet a
Dispose method. In pratice we rarely Dispose a DataSet because it
offers little benefit, and the DataSet often ends up in remoting and
caching scenarios where you don't know when all clients are actually
done with the DataSet
--
Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 09:56:49 -0600, "Leon" <vn*****@msn.co m> wrote: Are dataset automatically stored in memory?
Does the dispose() method automatically dispose of the dataset in the code below?
Do I have to dispose a dataset from memory or does the dataset dispose itself when not in use?
I know I can use the clear method, but that just clear the data within dataset not dispose of the dataset all together right?
*****Code Ex. Public Overloads Function RetrievePersona lization(ByVal AccountID As Integer) As DataRow
Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID", SqlDbType.In t, 4)} parameters(0). Value = AccountID
Dim Account As DataSet Try Account = RunProcedure( "GetStudentPers onalization", parameters, "Account") Return Account.Tables( 0).Rows(0) Account.Dispos e()
Finally If Not Account Is Nothing Then Account.Dispos e() End If End Try
End Function
you are right thanks, but..
is an arraylist a managed or unmanaged resource?
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:h1******** *************** *********@4ax.c om... Hi Leon:
As far as memory is concerned, you do not have to Dispose any object. The CLR manages memory and will periodically reclaim unused memory with a garbage collector. This includes the DataSet and the data in a DataSet. Calling Dispose does not hurry this process along.
Dispose is for unmanaged resources, like file handles and database connections. The rule of thumb is to call Dispose on any and every object that implements IDisposable. Unfortunately, the DataSet inherits from MarshalByValueC omponent which gives the DataSet a Dispose method. In pratice we rarely Dispose a DataSet because it offers little benefit, and the DataSet often ends up in remoting and caching scenarios where you don't know when all clients are actually done with the DataSet
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 09:56:49 -0600, "Leon" <vn*****@msn.co m> wrote:
Are dataset automatically stored in memory?
Does the dispose() method automatically dispose of the dataset in the code below?
Do I have to dispose a dataset from memory or does the dataset dispose itself when not in use?
I know I can use the clear method, but that just clear the data within dataset not dispose of the dataset all together right?
*****Code Ex. Public Overloads Function RetrievePersona lization(ByVal AccountID As Integer) As DataRow
Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID", SqlDbType.Int , 4)} parameters(0) .Value = AccountID
Dim Account As DataSet Try Account = RunProcedure( "GetStudentPers onalization", parameters, "Account") Return Account.Tables( 0).Rows(0) Account.Dispo se()
Finally If Not Account Is Nothing Then Account.Dispo se() End If End Try
End Function
Memory is a managed resource.
The memory an ArrayList uses will be managed.
If the ArrayList held on to any unmanged resources, it would implement
IDisposable (which it doesn't).
--
Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 10:40:43 -0600, "Leon" <vn*****@msn.co m> wrote: you are right thanks, but.. is an arraylist a managed or unmanaged resource?
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message news:h1******* *************** **********@4ax. com... Hi Leon:
As far as memory is concerned, you do not have to Dispose any object. The CLR manages memory and will periodically reclaim unused memory with a garbage collector. This includes the DataSet and the data in a DataSet. Calling Dispose does not hurry this process along.
Dispose is for unmanaged resources, like file handles and database connections. The rule of thumb is to call Dispose on any and every object that implements IDisposable. Unfortunately, the DataSet inherits from MarshalByValueC omponent which gives the DataSet a Dispose method. In pratice we rarely Dispose a DataSet because it offers little benefit, and the DataSet often ends up in remoting and caching scenarios where you don't know when all clients are actually done with the DataSet
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 09:56:49 -0600, "Leon" <vn*****@msn.co m> wrote:
Are dataset automatically stored in memory?
Does the dispose() method automatically dispose of the dataset in the code below?
Do I have to dispose a dataset from memory or does the dataset dispose itself when not in use?
I know I can use the clear method, but that just clear the data within dataset not dispose of the dataset all together right?
*****Code Ex. Public Overloads Function RetrievePersona lization(ByVal AccountID As Integer) As DataRow
Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID", SqlDbType.In t, 4)} parameters(0 ).Value = AccountID
Dim Account As DataSet Try Account = RunProcedure( "GetStudentPers onalization", parameters, "Account") Return Account.Tables( 0).Rows(0) Account.Disp ose()
Finally If Not Account Is Nothing Then Account.Disp ose() End If End Try
End Function
So how exactly does the CLR know when to periodically reclaim unused memory
with a garbage collector? or how does it know when you are using some object
anymore?
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:5f******** *************** *********@4ax.c om... Memory is a managed resource. The memory an ArrayList uses will be managed.
If the ArrayList held on to any unmanged resources, it would implement IDisposable (which it doesn't).
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 10:40:43 -0600, "Leon" <vn*****@msn.co m> wrote:
you are right thanks, but.. is an arraylist a managed or unmanaged resource?
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message news:h1****** *************** ***********@4ax .com... Hi Leon:
As far as memory is concerned, you do not have to Dispose any object. The CLR manages memory and will periodically reclaim unused memory with a garbage collector. This includes the DataSet and the data in a DataSet. Calling Dispose does not hurry this process along.
Dispose is for unmanaged resources, like file handles and database connections. The rule of thumb is to call Dispose on any and every object that implements IDisposable. Unfortunately, the DataSet inherits from MarshalByValueC omponent which gives the DataSet a Dispose method. In pratice we rarely Dispose a DataSet because it offers little benefit, and the DataSet often ends up in remoting and caching scenarios where you don't know when all clients are actually done with the DataSet
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 09:56:49 -0600, "Leon" <vn*****@msn.co m> wrote:
Are dataset automatically stored in memory?
Does the dispose() method automatically dispose of the dataset in the code below?
Do I have to dispose a dataset from memory or does the dataset dispose itself when not in use?
I know I can use the clear method, but that just clear the data within dataset not dispose of the dataset all together right?
*****Code Ex. Public Overloads Function RetrievePersona lization(ByVal AccountID As Integer) As DataRow
Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID", SqlDbType.I nt, 4)} parameters( 0).Value = AccountID
Dim Account As DataSet Try Account = RunProcedure( "GetStudentPers onalization", parameters, "Account" ) Return Account.Tables( 0).Rows(0) Account.Dis pose()
Finally If Not Account Is Nothing Then Account.Dis pose() End If End Try
End Function
the arraylist is all managed, but can contain an object that uses unmanqged
resources. for example an arraylist of SqlConnections.
-- bruce (sqlwork.com)
"Leon" <vn*****@msn.co m> wrote in message
news:et******** ******@TK2MSFTN GP15.phx.gbl...
| you are right thanks, but..
| is an arraylist a managed or unmanaged resource?
|
| "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
| news:h1******** *************** *********@4ax.c om...
| > Hi Leon:
| >
| > As far as memory is concerned, you do not have to Dispose any object.
| > The CLR manages memory and will periodically reclaim unused memory
| > with a garbage collector. This includes the DataSet and the data in a
| > DataSet. Calling Dispose does not hurry this process along.
| >
| > Dispose is for unmanaged resources, like file handles and database
| > connections. The rule of thumb is to call Dispose on any and every
| > object that implements IDisposable. Unfortunately, the DataSet
| > inherits from MarshalByValueC omponent which gives the DataSet a
| > Dispose method. In pratice we rarely Dispose a DataSet because it
| > offers little benefit, and the DataSet often ends up in remoting and
| > caching scenarios where you don't know when all clients are actually
| > done with the DataSet
| >
| > --
| > Scott
| > http://www.OdeToCode.com/blogs/scott/
| >
| >
| > On Fri, 12 Nov 2004 09:56:49 -0600, "Leon" <vn*****@msn.co m> wrote:
| >
| >>Are dataset automatically stored in memory?
| >>
| >>Does the dispose() method automatically dispose of the dataset in the
code
| >>below?
| >>
| >>Do I have to dispose a dataset from memory or does the dataset dispose
| >>itself when not in use?
| >>
| >>I know I can use the clear method, but that just clear the data within
| >>dataset not dispose of the dataset all together right?
| >>
| >>*****Code Ex.
| >>Public Overloads Function RetrievePersona lization(ByVal AccountID As
| >>Integer) As DataRow
| >>
| >>Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID",
| >>SqlDbType.Int , 4)}
| >>parameters(0) .Value = AccountID
| >>
| >>Dim Account As DataSet
| >>Try
| >>Account = RunProcedure( "GetStudentPers onalization", parameters,
| >>"Account")
| >>Return Account.Tables( 0).Rows(0)
| >>Account.Dispo se()
| >>
| >>Finally
| >>If Not Account Is Nothing Then
| >>Account.Dispo se()
| >>End If
| >>End Try
| >>
| >>End Function
| >>
| >>
| >>
| >
|
|
The CLR has plenty of rich metadata to draw from. It knows what
variables are referencing objects in memory, and what types those
objects are.
Every application then has a set of 'roots', which are local variables
or static variables that are referencing objects in memory. The JIT
compiler and the CLR work together to understand when the roots are
active, and when they go out of scope. From these roots the CLR can
know what objects in memory are still "in play" and what objects can
no longer trace back a chain of ownership to a root.
It's hard to answer questions like "when" will the CLR collect,
because it's really a low level detail. My understanding right now is
that the collector waits to run until a specific area of the heap (gen
0) is full. This is a hot area for optimizations and perf
improvements, so expect some change some in nearly every release.
Right now there are two different implementations of the garbage
collector, one is optimized for multi-proc machines (packaged in
MsCorSvr.dll) and one for uni-proc machines (packaged in
MsCorWks.dll)- these are often referred to as the server and
workstation garbage collectors. My understanding is this changes for
2005, in that there is a single dll, but still multi-proc vs.
single-proc implementations .
--
Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 11:03:21 -0600, "Leon" <vn*****@msn.co m> wrote: So how exactly does the CLR know when to periodically reclaim unused memory with a garbage collector? or how does it know when you are using some object anymore?
Thank again Scott, you have been a tremendous help!
I will return the favor by sharing the knowledge.
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:so******** *************** *********@4ax.c om... The CLR has plenty of rich metadata to draw from. It knows what variables are referencing objects in memory, and what types those objects are.
Every application then has a set of 'roots', which are local variables or static variables that are referencing objects in memory. The JIT compiler and the CLR work together to understand when the roots are active, and when they go out of scope. From these roots the CLR can know what objects in memory are still "in play" and what objects can no longer trace back a chain of ownership to a root.
It's hard to answer questions like "when" will the CLR collect, because it's really a low level detail. My understanding right now is that the collector waits to run until a specific area of the heap (gen 0) is full. This is a hot area for optimizations and perf improvements, so expect some change some in nearly every release.
Right now there are two different implementations of the garbage collector, one is optimized for multi-proc machines (packaged in MsCorSvr.dll) and one for uni-proc machines (packaged in MsCorWks.dll)- these are often referred to as the server and workstation garbage collectors. My understanding is this changes for 2005, in that there is a single dll, but still multi-proc vs. single-proc implementations .
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 12 Nov 2004 11:03:21 -0600, "Leon" <vn*****@msn.co m> wrote:
So how exactly does the CLR know when to periodically reclaim unused memory with a garbage collector? or how does it know when you are using some object anymore?
Dispose is used to free unmanaged resources. I try always to call Dispose,
then set the dataset to null such as Account = null. Otherwise, the dataset
object still exist after the dispose and can still be called. Setting it to
null let's the framework know that it can free up the object whenever it
gets around to garbage collection. As to when the object is cleared out of
memory is anyone's guess as it's totally up to the garbage collection and
memory management of the framework itself.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Leon" <vn*****@msn.co m> wrote in message
news:ez******** ******@tk2msftn gp13.phx.gbl... Are dataset automatically stored in memory?
Does the dispose() method automatically dispose of the dataset in the code below?
Do I have to dispose a dataset from memory or does the dataset dispose itself when not in use?
I know I can use the clear method, but that just clear the data within dataset not dispose of the dataset all together right?
*****Code Ex. Public Overloads Function RetrievePersona lization(ByVal AccountID As Integer) As DataRow
Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID", SqlDbType.Int, 4)} parameters(0).V alue = AccountID
Dim Account As DataSet Try Account = RunProcedure( "GetStudentPers onalization", parameters, "Account") Return Account.Tables( 0).Rows(0) Account.Dispose ()
Finally If Not Account Is Nothing Then Account.Dispose () End If End Try
End Function
Thanks Mark!
"Mark Fitzpatrick" <ma******@fitzm e.com> wrote in message
news:eK******** *****@TK2MSFTNG P11.phx.gbl... Dispose is used to free unmanaged resources. I try always to call Dispose, then set the dataset to null such as Account = null. Otherwise, the dataset object still exist after the dispose and can still be called. Setting it to null let's the framework know that it can free up the object whenever it gets around to garbage collection. As to when the object is cleared out of memory is anyone's guess as it's totally up to the garbage collection and memory management of the framework itself.
Hope this helps, Mark Fitzpatrick Microsoft MVP - FrontPage
"Leon" <vn*****@msn.co m> wrote in message news:ez******** ******@tk2msftn gp13.phx.gbl... Are dataset automatically stored in memory?
Does the dispose() method automatically dispose of the dataset in the code below?
Do I have to dispose a dataset from memory or does the dataset dispose itself when not in use?
I know I can use the clear method, but that just clear the data within dataset not dispose of the dataset all together right?
*****Code Ex. Public Overloads Function RetrievePersona lization(ByVal AccountID As Integer) As DataRow
Dim parameters As SqlParameter() = { New SqlParameter("@ AccountID", SqlDbType.Int, 4)} parameters(0).V alue = AccountID
Dim Account As DataSet Try Account = RunProcedure( "GetStudentPers onalization", parameters, "Account") Return Account.Tables( 0).Rows(0) Account.Dispose ()
Finally If Not Account Is Nothing Then Account.Dispose () End If End Try
End Function
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: faktujaa |
last post by:
Hi All,
A small confusion. I have defined a connection class that has
System.Data.IDbConnection as a member variable and implements IDisposable
interface. I have implemented Dispose method to call Dispose method of
IDbConnection. This Dispose method is called from a destructor. In the
dispose method, i also call GC.SuppressFinalize(this) so as to avoid
finalizer. All this was OK untill i came across one article that says - not
to call...
|
by: RiteshDotNet |
last post by:
..net Frame work
1. Dispose Method what it does ?
A. who its call / when it calls ?
B. Is it fire automatically ?
c. When dispose method is call what it does ?
D. Release a Object from memory or release refrence from memory ?
E. If it release object from memory then what GC does ?
2. Which class can have dispose method ?
class which is member of IDispose Inteface
3. Where we should use abstract / Interface ?
|
by: Chris Dunaway |
last post by:
If I place objects into the cached that implement an IDispose, are they
automatically disposed when removed? Looking at the code it doesn't
appear so. How can I handle this? Anyone with a suggestion?
Chris
|
by: Hans Kesting |
last post by:
Hi,
What are the performance benefits of calling Dispose on a DataSet?
We have a (web) application that we tried to run on a shared server.
It crashed due to memory constraints.
The helpdesk of the hoster said "you need to call Dispose on every
object". Now I know that not every object implements this method,
but DataSet does (and we use it a lot).
|
by: Dennis |
last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose
method based on advice from this newsgroup. However, I'm not sure how to
dispose of the following object that was created inside a method call.
dim myvar as new object1
object1.dosomethingmethod(new object2)
Note that object 2 has a dispose method but how do I dispose of it unless I
do the following:
| |
by: MilanB |
last post by:
Hello
When Windows.Forms.Form procceds Dispose(), do it dispose all child controls
and fields?
I have Form variable Image which is connected to opened MemoryStrem (also
Form field)
When I call Form.Dispose(), does it mean that Image will be disposed and
MemoryStrem closed and disposed/distroyed
|
by: Anonieko |
last post by:
Understanding and Using Exceptions
(this is a really long post...only read it if you (a) don't know what
try/catch is OR (b) actually write catch(Exception ex) or catch{ })
The first thing I look for when evaluating someone's code is a
try/catch block. While it isn't a perfect indicator, exception handling
is one of the few things that quickly speak about the quality of code.
Within seconds you might discover that the code author...
|
by: active |
last post by:
In the main program I check to see if a certain form has been disposed.
Does it make sense in that form's FormClosed event to do:
Me.Dispose to make sure it is disposed the next time I check.
Or is that automatic?
Thanks
|
by: viswarajan |
last post by:
Introduction
This article is to go in deep in dome key features in the ADO.NET 2 which was shipped with VS 2005.
In this article I will go trough one of the key features which is the Connection Pooling.
This feature is a key feature plays an important role in the performance in most of business application or Data driven application.
What's Connection Pooling?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |