all groups > dotnet clr > august 2004 >
You're in the

dotnet clr

group:

How can I get IEEMemoryManager ?


How can I get IEEMemoryManager ? Flier Lu
8/26/2004 10:45:23 PM
dotnet clr:
There is a IEEMemoryManager interface in .NET FX 2.0 SDK's mscoree.idl,
but why I cannot query it with ICLRControl::GetCLRManager?
mscorwks.dll has a debug symbol GetEEMemoryManager, but not export it at
all. I found this interface is implemented in CExecuteEngine but not in
CorHost2 like IClrGCManager. so how can I get IEEMemoryManager ?
Thanks

--
http://flier_lu.blogone.net/

RE: How can I get IEEMemoryManager ? alessc NO[at]SPAM online.microsoft.com
9/1/2004 6:33:42 PM
IEEMemoryManager is an internal-only interface that is used to allow other
DLLs to interface with hosted memory operations.

If you need to control memory allocations in a CLR host, what you want to
do is to implement IHostMemoryManager on the host and follow the sample
shown in Dino's blog (http://weblogs.asp.net/dinoviehland ) to see how to
hook it up.

Could you elaborate more on what you are trying to do?

--Alessandro

This posting is provided "AS IS" with no warranties, and confers no rights.
Sample code subject to http://www.microsoft.com/info/cpyright.htm
Re: How can I get IEEMemoryManager ? Flier Lu
9/6/2004 12:29:02 AM
Thanks to your reply :D

I'm just exploring the CLR host support in whidbey, so want to konwn why
I can't got IEEMemoryManager directly. I think IHostMemoryManager is
provider for CLR to get memory from Host, IEEMemoryManager is provider for
Host to get memory from CLR, so their purpose maybe different.
For example, I had implement IHostMemoryManager with Win32API
VirutalAllocEx etc. But in some situation (maybe alloc memory block size
less 1k), I want bypass the memory alloc request back to CLR, to reuse the
CLR internal cache or pool mechanism. So I need a interface like
IEEMemoryManager to export the CLR's memory management. But I walk into the
whidbey implementation, IEEMemoryManager seems based on IHostMemoryManager,
so it would recursion :(
I need a partial Host memory management. :D

btw: Could I return E_XXX from IHostMemoryManager::VirtualAlloc to bypass
the memory alloc request ?

--

"Alessandro Catorcini" <alessc@online.microsoft.com> дÈëÏûÏ¢
news:uHLCdIFkEHA.2516@cpmsftngxa10.phx.gbl...
[quoted text, click to view]

Re: How can I get IEEMemoryManager ? dinov NO[at]SPAM online.microsoft.com (
9/7/2004 7:01:54 PM
Hi Flier,

If you've implemented IHostMemoryManager, and you're wanting to allocate <
1k of memory, the best option you have available is to go to your
IHostMalloc implementation instead of your VirtualAlloc implementation (or
just use ye-olde-malloc). The CLR will typically do the same thing to get
small amounts of memory from the host. The only times it wouldn't do this
is for allocations that need to happen during startup (before we have the
host memory manager) or when it's using a special purpose pool (which seems
to be what you're wanting to get at).

The special purpose allocators the CLR implements are typically very
special purpose. One example would be the sync block cache (you could see
this in Rotor) where we may sometimes allocate a sync block, and other
times we have the cached sync blocks lying around. But because you're not
allocating sync blocks, this is useless for you. And in general that's how
all the internal caches will go... And anyway, we don't expose the sync
block allocator :) So I'd say if you want an allocator that's going to
cache things you'd want to build your own special case allocator based upon
your usage patterns inside your host.

As Alessandro mentioned the IEEMemoryManager interface is used to
provide the hosted memory allocations to other components of the CLR. The
most obvious one to mention would be the JIT which needs to VirtualAlloc
memory for placing jitted code into. And as you've discovered, it just
turns around and passes the request off to the host implementation. This
ensures that wherever the allocation comes from in the CLR that it will
always go through the host. I think the key thing to note here is that
when you replace the memory manager that you implement all the memory
allocation primitives yourself - you get complete control.

Finally on the returning an error code. Yes you can return error
codes from your VirtualAlloc implementation, but the CLR will treat that as
a failure to allocate the memory, and an exception will be propagated into
managed code. So it won't bypass it, just fail it (or in other words the
CLR will always do what your memory allocator tells it to do).

Are you just trying to get performance by piggybacking on the CLR's
allocator? Or do you have another goal in mind?



Re: How can I get IEEMemoryManager ? Flier Lu
9/8/2004 10:59:09 PM
Thanks very much! :D

I would try to use my own memory pool instead of bypassing request back to
CLR.

--

·ÅÏÂ
""Dino Viehland [MS]"" <dinov@online.microsoft.com> дÈëÏûÏ¢
news:BPLbk0QlEHA.2148@cpmsftngxa10.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button