<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I release an InMemoryWorkspaceFactory in the ESRI Map Control? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-i-release-an-inmemoryworkspacefactory-in/m-p/220807#M5697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I discovered the cause of this problem. I was not calling the Shutdown method of the IAoInitialize interface during the WM_DESTROY event. Adding that cleans everything up and allows the hosting application to close completely.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Aug 2010 23:10:37 GMT</pubDate>
    <dc:creator>KevinFournier</dc:creator>
    <dc:date>2010-08-09T23:10:37Z</dc:date>
    <item>
      <title>How do I release an InMemoryWorkspaceFactory in the ESRI Map Control?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-i-release-an-inmemoryworkspacefactory-in/m-p/220806#M5696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the code I use during the WM_CREATE message to create the in-memory workspace:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;// create workspace for in-memory features
if( m_pMapControl )
{
 CComPtr&amp;lt;IWorkspaceFactory2&amp;gt; pWorkspaceFactory2 = NULL;
 if( SUCCEEDED(pWorkspaceFactory2.CoCreateInstance(CLSID_InMemoryWorkspaceFactory)) &amp;amp;&amp;amp; pWorkspaceFactory2 )
 {
&amp;nbsp; CComPtr&amp;lt;IWorkspaceName&amp;gt; pWorkspaceName = NULL;
&amp;nbsp; if( SUCCEEDED(pWorkspaceFactory2-&amp;gt;Create(CComBSTR(), CComBSTR(_T("MyInMemoryWorkspace")), NULL, NULL, &amp;amp;pWorkspaceName)) &amp;amp;&amp;amp; pWorkspaceName )
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; CComQIPtr&amp;lt;IName&amp;gt; pName( pWorkspaceName );
&amp;nbsp;&amp;nbsp; CComPtr&amp;lt;IUnknown&amp;gt; pUnknown = NULL;
&amp;nbsp;&amp;nbsp; if( pName &amp;amp;&amp;amp; SUCCEEDED(pName-&amp;gt;Open(&amp;amp;pUnknown)) &amp;amp;&amp;amp; pUnknown )
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if( SUCCEEDED(pUnknown-&amp;gt;QueryInterface(IID_IWorkspace, (void**)&amp;amp;m_pInMemoryWorkspace)) &amp;amp;&amp;amp; m_pInMemoryWorkspace )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_pInMemoryWorkspace-&amp;gt;AddRef();
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
 }
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I release the workspace during the WM_DESTROY message, but clearly this is insufficient.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;// release in-memory workspace
if( m_pInMemoryWorkspace )
 m_pInMemoryWorkspace-&amp;gt;Release();&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Aug 2010 15:46:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-i-release-an-inmemoryworkspacefactory-in/m-p/220806#M5696</guid>
      <dc:creator>KevinFournier</dc:creator>
      <dc:date>2010-08-09T15:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I release an InMemoryWorkspaceFactory in the ESRI Map Control?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-i-release-an-inmemoryworkspacefactory-in/m-p/220807#M5697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I discovered the cause of this problem. I was not calling the Shutdown method of the IAoInitialize interface during the WM_DESTROY event. Adding that cleans everything up and allows the hosting application to close completely.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Aug 2010 23:10:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-do-i-release-an-inmemoryworkspacefactory-in/m-p/220807#M5697</guid>
      <dc:creator>KevinFournier</dc:creator>
      <dc:date>2010-08-09T23:10:37Z</dc:date>
    </item>
  </channel>
</rss>

