Anthony Sox said:
Hi all
is there as way i can tell the amount of memory my object takes. for
example
if i have a collection of employee object say of 20, how much memory do
they
take e.g. 500kb.
..NET deliberately makes it extremely difficult to determine how much memory
an object actually consumes because the information is architectural and you
can't go messing about with the .NET architecture.
That said, there are at least two ways out of the near predicament.
1. Spend a few weeks mucking about with the CopyMemory API, allocating
objects to managed and unmanaged memory, interop object marshalling and
pointer to structure manipulations... and getting nowhere fast.
2. State the general structure of the objects and the purpose of needing to
know how much memory each one object consumes.
If you take option 2 then it can be determined if an approximation might be
sufficient, and if that is the case then there are any number of ways to
skin your particular cat.