473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

custom memory management

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

Nov 15 '07 #1
2 2004
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
Nov 15 '07 #2

"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.
First you must define the boundary of your object. Is it:

(A) the memory block on the heap which the reference points to
(B) the set of all blocks reachable from that object (i.e. consider the
object as a GC root)
(C) the set of all blocks which could be freed if the object was eliminated
from the cache
(D) something else
>
what I need is just a right direction of research.

Thanks in advance
Wiktor Zychla

Nov 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DanielGifford | last post by:
Hi I'm making some basic cryptography software and I've run into a snag. I'm trying to retrieve some sort of system number thats specific to the system I'm working on. It can't change over...
5
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.