Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

variable size in memory c#

Unmanaged object:
Marshal.SizeOf(object yourObj);
//-----------------------------------------------------
Value Types:
sizeof(object val);
  //-----------------------------------------------------
calculate how much memory an object take c#

long size = 0;
object o = new object();
using (Stream s = new MemoryStream()) {
    BinaryFormatter formatter = new BinaryFormatter();
    formatter.Serialize(s, o);
    size = s.Length;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #variable #size #memory
ADD COMMENT
Topic
Name
6+8 =