473,783 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetTo talMemory 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 2020
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.co m

"Wiktor Zychla [C# MVP]" <wz*****@nospm. ii.uni.wroc.pl. nospmwrote in
message news:ey******** ******@TK2MSFTN GP04.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.GetTo talMemory 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******** ******@TK2MSFTN GP04.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.GetTo talMemory 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
1643
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 time. Whether its a cpu id, memory id, system serial key, or anything else
5
24805
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 (I am new to Windows so not sure). We are currently bouncing the instance to overcome this error. This generally happen at the end of business day only (So maybe memory might be getting used up?). We have already increased the statement heap & ...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.