Here's the snippet:
long StopBytes = 0;
foo myFoo;
long StartBytes = System.GC.GetTotalMemory(true);
myFoo = new foo();
StopBytes = System.GC.GetTotalMemory(true);
GC.KeepAlive(myFoo); // This ensures a reference to the object kept in memory
MessageBox.Show("Size is " + ((long)(StopBytes - StartBytes)).ToString());
However, I guess it would be better if one would get the StopBytes after the statement of KeepAlive... Don't you think?
No comments:
Post a Comment