Size of object in at runtime memory

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Rune Andersen (rune135_at_REMOVEpop.k-net.dk)
Date: 03/19/04


Date: Fri, 19 Mar 2004 13:23:14 +0100

Hi....

I'm working on a cache controller and needs to know the current size of the
cache object, but how do I get that ?

I've got an ArrayList populated with structs and now I want to know the
current memory usage of the ArrayList at runtime.

I've tried using

System.Runtime.InteropServices.Marshal.SizeOf( object structure );

but it seems like it's only working on types like int, long, double etc.

Is there any method I can use that gives me the size of memory used by a
specified object ?

/Rune