S
Sudip_inn
Guest
i found this one which return memory used in byte
/// <summary>
/// Calculates the lenght in bytes of an object
/// and returns the size
/// </summary>
/// <param name="TestObject"></param>
/// <returns></returns>
private int GetObjectSize(object TestObject)
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
byte[] Array;
bf.Serialize(ms, TestObject);
Array = ms.ToArray();
return Array.Length;
}
tell me is the above approach is right one ?
how to customize above code which will return memory used in terms of Byte/ KB / MB ?
how to make above function extension one which can work for any object type ?
please share one extension method which tell me how much memory my Dataset or List<T> consumed in terms of Byte/ KB / MB.
CyberSaving/MemoryUsage
Find size of object instance in bytes in c#
thanks
Continue reading...
/// <summary>
/// Calculates the lenght in bytes of an object
/// and returns the size
/// </summary>
/// <param name="TestObject"></param>
/// <returns></returns>
private int GetObjectSize(object TestObject)
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
byte[] Array;
bf.Serialize(ms, TestObject);
Array = ms.ToArray();
return Array.Length;
}
tell me is the above approach is right one ?
how to customize above code which will return memory used in terms of Byte/ KB / MB ?
how to make above function extension one which can work for any object type ?
please share one extension method which tell me how much memory my Dataset or List<T> consumed in terms of Byte/ KB / MB.
CyberSaving/MemoryUsage
Find size of object instance in bytes in c#
thanks
Continue reading...