Wiktor,
The two ways I could think of doing this would be to hook into the
debugging interface in the CLR, or to provide a custom host which would be
able to report the memory consumed by your particular object(s).
The thing is though, why the need for this kind of mechanism? It's
surely more trouble than it's worth, and there is usually not a justifiable
need (not saying yours isn't, but it would help to know why, given that you
have GC to take care of memory management issues for you).
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Wiktor Zychla [C# MVP]" <wz*****@nospm.ii.uni.wroc.pl.nospmwrote in
message news:ey**************@TK2MSFTNGP04.phx.gbl...
suppose I implement a custom caching mechanism for my custom ORM
implementation. suppose I'd like the client code to be able to define the
maximum amount of memory the cache is allowed to occupy.
however, I have no idea how from within the code I can even retrieve the
amount of memory an object takes. the System.GC.GetTotalMemory method seem
to retrieve the total amount of allocated memory while I would be
interested in monitoring the memory usage for a selected object.
what I need is just a right direction of research.
Thanks in advance
Wiktor Zychla