How do I measure the size of a dataset?

M

Max2006

Hi,

How do I measure the size of a dataset (including data in data tables and
rows)?

Thank you,
Max
 
J

Jialiang Ge [MSFT]

Hello Max,

I assume that you meant the size of the dataset's serialization result by
"the size of a dataset (including data in the data tables and rows). The
answer depends on the serialization format:

If we use BinaryFormatter, Code list 1 shows the pseudocode:

---Code list 1 ---
DataSet ds = GetData();
ds.RemotingFormat = SerializationFormat.Binary;
BinaryFormatter bin = new BinaryFormatter();
bin.Serialize(stream, ds);
Console.Write(stream.Length);

If we serialize the dataset to XML, we can do it in this way:

---Code list 2 ---
DataSet ds = GetData();
Console.Write(Encoding.UTF8.GetByteCount(ds.GetXml()));

For more information of DataSet Serialization, please refer to the articles:

Binary Serialization of DataSets
http://msdn.microsoft.com/en-us/magazine/cc163911.aspx

Improving DataSet Serialization and Remoting Performance
http://support.microsoft.com/kb/829740/en-us

If you have any other questions or concerns, please DON'T hesitate to tell
me.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Max2006

Hi Cor,

I am referring to amount of bytes that the dataset data occupies in memory.

Regards,
Max
 
M

Max2006

Hi Jialiang,

I am developing a web application and I have to put this dataset in asp.net
in-memory session.
I am concern about the web server memory that this dataset might occupy.

The memory that a dataset occupies might not be equal with the size of the
dataset's serialization result (am I wrong?)

Is there any technique to analyze the amt of RAM memory that a dataset
occupies?

Thank you,
Max



"Jialiang Ge [MSFT]" said:
Hello Max,

I assume that you meant the size of the dataset's serialization result by
"the size of a dataset (including data in the data tables and rows). The
answer depends on the serialization format:

If we use BinaryFormatter, Code list 1 shows the pseudocode:

---Code list 1 ---
DataSet ds = GetData();
ds.RemotingFormat = SerializationFormat.Binary;
BinaryFormatter bin = new BinaryFormatter();
bin.Serialize(stream, ds);
Console.Write(stream.Length);

If we serialize the dataset to XML, we can do it in this way:

---Code list 2 ---
DataSet ds = GetData();
Console.Write(Encoding.UTF8.GetByteCount(ds.GetXml()));

For more information of DataSet Serialization, please refer to the
articles:

Binary Serialization of DataSets
http://msdn.microsoft.com/en-us/magazine/cc163911.aspx

Improving DataSet Serialization and Remoting Performance
http://support.microsoft.com/kb/829740/en-us

If you have any other questions or concerns, please DON'T hesitate to tell
me.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
 
J

Jialiang Ge [MSFT]

Hello Max,
Is there any technique to analyze the amt of RAM memory that a
dataset occupies?

Yes. To retrieve the size of a managed object (e.g. a DataSet object) in
memory, there are several approximate calculations that are documented at

Size of a managed object
http://blogs.msdn.com/cbrumme/archive/2003/04/15/51326.aspx

How to determine size of .NET managed object in memory (like a sizeof for
reference types)
http://blogs.msdn.com/mab/archive/2006/04/24/582666.aspx

Getting the size of a managed object
http://blogs.msdn.com/pierreg/archive/2008/05/08/getting-the-size-of-a-manag
ed-object.aspx

Here are more materials of debug ASP.NET application with windbg + SOS, and
the SOS commands:
http://support.microsoft.com/kb/892277
http://msdn.microsoft.com/en-us/library/bb190764.aspx

If you have any other questions or concerns, please DON'T hesitate to tell
me.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
J

Jialiang Ge [MSFT]

Hello Max

I am writing to check the status of the issue on your side. Would you mind
letting me know the result of the suggestions? If you need further
assistance, feel free to let me know. I will be more than happy to be of
assistance.

Have a great day!

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top