Seeing odd behavior with DataSet objects

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
QScend
Posts: 8
Joined: Tue Mar 04, 2008 5:40 pm

Seeing odd behavior with DataSet objects

Post by QScend » Thu Mar 06, 2008 9:26 pm

If I make a VB .NET 2.0 control and in CreateChildControls() simple do:

Dim objDS As New DataSet
objDS.Dispose()

I notice the following odd behavior with .NET MP:

Image

What are all of these extra data object arrays (Datatable[], DataView[] etc) that stay in memory even after GC? They don't seem to go away until I cycle the worker process, so I'm a bit concered that I'm not properly destroying the DataSet objects somehow (I thought I only had to call Dispose() on them).

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Fri Mar 07, 2008 3:34 pm

I tried to reproduce the problem by creating an empty page, which included the code you provided in the CreateChildControls method. However, I could only see one Live instance of the DataTable[] class. Collecting a snapshot and investigating the root path of the instance revealed that is was referenced by the System.DataSet.zeroTables field.

Have you collected a heap snapshot and investigated the root paths of the instances you think should be GCed (i.e., the instances of Datatable[], DataView[] etc)? The root paths should help you understand why the instances are not GCed.
Best regards,

Andreas Suurkuusk
SciTech Software AB

QScend
Posts: 8
Joined: Tue Mar 04, 2008 5:40 pm

Post by QScend » Fri Mar 07, 2008 5:17 pm

You're correct, we see the same, referenced by System.DataSet.zeroTables. You don't seem surprised by this, so what is it and why is it staying in memory? Searching didn't turn up much information on it, and not anything really useful.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Sun Mar 09, 2008 8:11 pm

The DataTable array referenced by zeroTables is a standard static field referencing an instance that is needed for future use. I have not investigated the use of zerotTables, but I assume that is merely used for performance reasons. It is a zero long array of DataTables which might be used any time an empty array of DataTables need to be returned from a method.

It is very common that an action creates initial instances that will be used by subsequent similar actions. As long as the number of instances doesn't increase when the action is performed repeatedly, this normally doesn't indicates a memory leak. That's why I'm not surprised by seeing a single live instance of a DataTabe[] array.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 16 guests