this may not be accurate but its close enough for me
long size = 0;
object o = new object();
using (Stream s = new MemoryStream()) {
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(s, o);
size = s.Length;
}
More Related Contents:
- Benchmarking small code samples in C#, can this implementation be improved?
- How much memory does a C#/.NET object use?
- Explicitly freeing memory in c#
- Comparing two byte arrays in .NET
- Any decent C# profilers out there? [closed]
- Handling warning for possible multiple enumeration of IEnumerable
- Performance Tests of Serializations used by WCF Bindings
- Exact time measurement for performance testing [duplicate]
- What is the real overhead of try/catch in C#?
- Performance of calling delegates vs methods
- When is optimization premature? [closed]
- What’s the difference between encapsulating a private member as a property and defining a property without a private member?
- How do I do logging in C# without using 3rd party libraries? [closed]
- C# / F# Performance comparison
- Performance of “direct” virtual call vs. interface call in C#
- System.Net.WebClient unreasonably slow
- Performance of Find() vs. FirstOrDefault() [duplicate]
- Does String.GetHashCode consider the full string or only part of it?
- How do I measure how long a function is running?
- LINQ performance FAQ
- Is it better to execute many sql commands with one connection, or reconnect every time?
- Allocating more than 1,000 MB of memory in 32-bit .NET process
- How to read last “n” lines of log file [duplicate]
- Why is my C# program faster in a profiler?
- How to use StringBuilder wisely?
- Array bounds check efficiency in .net 4 and above
- Where are methods stored in memory?
- Does any one know of a faster method to do String.Split()?
- Garbage Collection not happening even when needed
- Memory usage in C#