class memory usage

hello all, i need to know if the “Runtime.memoryusage” returns me all memory usage or just that of a single allocated object? i need to know only the memory usage of a single class

thank you in advance

Runtime.MemoryUsed is the current used memory of the app. You could possibly find the size of an instance of a class by comparing the memory used before creating the instance and after it is created. However if any one property is a string, memory block or other variable sized object then the size of the instance will change.

Perhaps you need something like a structure where you define the size/type of the data?

specifically i need the class memory usage while running

Why? Usually this doesn’t matter, so it would be good to hear the specific case you have.