I am embedding the ESRI Map Control into a custom ActiveX control written in MFC/C++. The custom ActiveX control serves as a Map Control wrapper so I can embed it into a specific environment that is runtime only and non-relational. Thanks to this site, I am able to load feature points into an in-memory workspace. However, the hosting environment now gets stuck in memory when closed, and it only does this when I am using the InMemoryWorkspaceFactory. My conclusion, therefore, is that the factory has locked a file or resource and, by not releasing it, is causing the host environment to never close.Is there a way I can manually delete all features and feature classes during my ActiveX control's WM_DESTROY message and release the workspace completely? There doesn't seem to be a counterpart to the IWorkspaceFactory's Create method. My code is releasing all interfaces to the workspace factory, but apparently there are still references internally in ArcObjects.Here's the code I use during the WM_CREATE message to create the in-memory workspace:// create workspace for in-memory features
if( m_pMapControl )
{
CComPtr<IWorkspaceFactory2> pWorkspaceFactory2 = NULL;
if( SUCCEEDED(pWorkspaceFactory2.CoCreateInstance(CLSID_InMemoryWorkspaceFactory)) && pWorkspaceFactory2 )
{
CComPtr<IWorkspaceName> pWorkspaceName = NULL;
if( SUCCEEDED(pWorkspaceFactory2->Create(CComBSTR(), CComBSTR(_T("MyInMemoryWorkspace")), NULL, NULL, &pWorkspaceName)) && pWorkspaceName )
{
CComQIPtr<IName> pName( pWorkspaceName );
CComPtr<IUnknown> pUnknown = NULL;
if( pName && SUCCEEDED(pName->Open(&pUnknown)) && pUnknown )
{
if( SUCCEEDED(pUnknown->QueryInterface(IID_IWorkspace, (void**)&m_pInMemoryWorkspace)) && m_pInMemoryWorkspace )
m_pInMemoryWorkspace->AddRef();
}
}
}
}
I release the workspace during the WM_DESTROY message, but clearly this is insufficient.// release in-memory workspace
if( m_pInMemoryWorkspace )
m_pInMemoryWorkspace->Release();