共用方式為


IHostMemoryManager

更新:2007 年 11 月

提供方法讓 Common Language Runtime (CLR) 透過主應用程式進行虛擬記憶體的要求,而不是經由使用標準的 Win32 虛擬記憶體函式。

interface IHostMemoryManager : IUnknown {

    HRESULT CreateMAlloc (
        [in]  BOOL    fThreadSafe,
        [out] IHostMalloc **ppMalloc
    );

    HRESULT VirtualAlloc (
        [in]  void*   pAddress,
        [in]  SIZE_T  dwSize,
        [in]  DWORD   flAllocationType,
        [in]  DWORD   flProtect,
        [in]  EMemoryCriticalLevel dwCriticalLevel,
        [out] void**  ppMem
    );

    HRESULT VirtualFree (
        [in]  LPVOID  lpAddress,
        [in]  SIZE_T  dwSize,
        [in]  DWORD   dwFreeType
    );

    HRESULT VirtualQuery (
        [in]  void*   lpAddress,
        [out] void*   lpBuffer,
        [in]  SIZE_T  dwLength,
        [out] SIZE_T  *pResult
    );

    HRESULT VirtualProtect (
        [in]  void*   lpAddress,
        [in]  SIZE_T  dwSize,
        [in]  DWORD   flNewProtect,
        [out] DWORD*  pflOldProtect
    );

    HRESULT GetMemoryLoad (
        [out] DWORD*  pMemoryLoad, 
        [out] SIZE_T  *pAvailableBytes
    );

    HRESULT RegisterMemoryNotificationCallback (
        [in]  ICLRMemoryNotificationCallback* pCallback
    );

    HRESULT NeedsVirtualAddressSpace(
        [in]  LPVOID  startAddress,
        [in]  SIZE_T  size
        );

    HRESULT AcquiredVirtualAddressSpace(
        [in]  LPVOID  startAddress,
        [in]  SIZE_T  size
        );

    HRESULT ReleasedVirtualAddressSpace(
        [in]  LPVOID  startAddress
        );
};

方法

方法

描述

IHostMemoryManager::AcquiredVirtualAddressSpace 方法

通知主應用程式,Common Language Runtime (CLR) 已從作業系統取得指定的記憶體。

IHostMemoryManager::CreateMAlloc 方法

取得 IHostMAlloc 執行個體的介面指標,這個執行個體是用來從主應用程式所建立的堆積中要求記憶體配置。

IHostMemoryManager::GetMemoryLoad 方法

取得目前使用的實體記憶體數量 (如主應用程式所報告)。

IHostMemoryManager::NeedsVirtualAddressSpace 方法

通知主應用程式,CLR 即將嘗試使用指定的記憶體。

IHostMemoryManager::RegisterMemoryNotificationCallback 方法

註冊主應用程式叫用的回呼函式指標,以便向 CLR 告知電腦上目前的記憶體負載。

IHostMemoryManager::ReleasedVirtualAddressSpace 方法

通知主應用程式,CLR 已完成使用指定的記憶體。

IHostMemoryManager::VirtualAlloc 方法

當做對應 Win32 函式的邏輯包裝函式,這個函式會在呼叫處理序的虛擬位址空間中保留或認可頁面區域。

IHostMemoryManager::VirtualFree 方法

當做對應 Win32 函式的邏輯包裝函式,這個函式會在呼叫處理序的虛擬位址空間中釋放、解除認可或釋放並解除認可頁面區域。

IHostMemoryManager::VirtualProtect 方法

當做對應 Win32 函式的邏輯包裝函式,這個函式會在呼叫處理序的虛擬位址空間中變更已認可頁面區域的保護。

IHostMemoryManager::VirtualQuery 方法

當做對應 Win32 函式的邏輯包裝函式,這個函式會擷取呼叫處理序之虛擬位址空間中頁面範圍的資訊。

備註

IHostMemoryManager 也會為 CLR 提供方法,讓它取得指標,透過此指標在堆積上提出記憶體要求,以及取得處理序中記憶體不足的壓力層級 (如主應用程式所報告)。

需求

**平台:**請參閱 .NET Framework 系統需求

**標頭:**MSCorEE.idl

程式庫:包含做為 MSCorEE.dll 中的資源

**.NET Framework 版本:**3.5 SP1、3.5、3.0 SP1、3.0、2.0 SP1、2.0

請參閱

參考

IHostMAlloc

其他資源

裝載介面