2008
04.07

Apparently there is no way I haven’t find a way to determine the size of a .NET managed object in memory.

The closest I can come out, particularly for a DataSet object is as follows:

DataSet ds = new DataSet();
// ...
// This is where you populate the content of DataSet
// ...
String xmlContent = ds.GetXml();
UnicodeEncoding uniEnc = new UnicodeEncoding();
int byteCount = uniEnc.GetByteCount(xmlContent);

But why we use UnicodeEncoding, not ASCIIEncoding, or UTF8Encoding, well, as MSDN says, String object is a collection of Unicode characters. So if we want to know how many bytes are they, we need to use UnicodeEncoding.

Of course we are still far from our actual objective, but this is a good start. I’ll update as I found other possible method.

GD Star Rating
a WordPress rating system
there is no way I haven't find a way<" data-image="http://sodeve.net/wp-content/uploads/2008/04/dataset.png">

Incoming Search Term

Advertise Here

1 Trackback

 

1 comment so far

Add Your Comment
  1. Hmm.. to think about it… Serialization could do the trick…. 😀