How to get mem-size of a structure?

Is there a way to get the memory size used by a structure (say a 2-dimensional array of type String) I need to compare implementations mem-wise, but I can't find what I need to know. I hope this isn't a too dumb question :x


Answer this question

How to get mem-size of a structure?

  • ctsand

    You won't necessarily be able to extrapolate from the memory size of individual types to the run-time memory usage of an application, if that's what you're getting at. The run-time memory characteristics will depend heavily on how you use the memory and when the garbage collection decides to run.

    Can you be more specific about the comparison you're trying to do

    -Tom Meschter
    Software Dev, Visual C# IDE



  • RichHamilton

    I am representing a polygonal 2D structure (mapped onto a grid) into memory. I have 2 ways of doing it:
    1) represent all grid points in a 2-dimensional matrix and if there is a line from point grid point 1 to grid point 2; make the value of the matrix > 0 (this is indicating a line-type)
    2) represent the structure as an array of lines (so an array of {x,y}-{x,y})

    I am facing the problem that I am working on a massive computer with lots of mem (and a very large windows swap file), but that the application is meant to be run on a small computer (512 MB - 2048 MB of mem). The array structure is of course very wastefull for mem but for other calculations it is rather fast. However if the swapping becomes to horrible it's performance will degrade to unacceptable level; so I need to know how much memory the matrix structure takes.

    I suppose I could calculate it; it's a 1000 x 1000 array of type int (likelly implemented with 32 bit), so that would be 3,9 MB (1000 x 1000 x 32 / 4 (byte) / 1024 (kb) / 1000 (mb)). But I want to know what amount of vmem I need.

  • How to get mem-size of a structure?