<?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: Memory Leak with COM Server in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961261#M21847</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm not aware of any leaks.  If you'd like to send the COM server and VB client to vf-support, I'll take a look at it.&lt;BR /&gt;&lt;BR /&gt;Leo</description>
    <pubDate>Tue, 31 Jul 2001 06:06:21 GMT</pubDate>
    <dc:creator>Intel_C_Intel</dc:creator>
    <dc:date>2001-07-31T06:06:21Z</dc:date>
    <item>
      <title>Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961260#M21846</link>
      <description>Using COM Wizard, I have developed a Fortran COM server application that is called from Visual Basic.  Both the Fortran and VB applications work fine, except that there is a memory leak.  Everytime a particular method is called, the memory usage increases ~8K.  If the calls to the method are removed from the VB application, there is no memory leak.  If all of the function of the method is removed from the Fortran, leaving just a dummy method, the memory leak does still occur.  This leads to the conclusion that the problem is in the code generated by the COM Wizard, which leaves me at a bit of a loss as to how to debug.  &lt;BR /&gt;  &lt;BR /&gt;Has anyone seen this occurring?  I am running Version 6.5.A on Windows NT.  &lt;BR /&gt;  &lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 31 Jul 2001 04:54:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961260#M21846</guid>
      <dc:creator>brownts</dc:creator>
      <dc:date>2001-07-31T04:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961261#M21847</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm not aware of any leaks.  If you'd like to send the COM server and VB client to vf-support, I'll take a look at it.&lt;BR /&gt;&lt;BR /&gt;Leo</description>
      <pubDate>Tue, 31 Jul 2001 06:06:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961261#M21847</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-07-31T06:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961262#M21848</link>
      <description>Leo, &lt;BR /&gt; &lt;BR /&gt;I am in the process of paring the project down to bare bones to get something that I can send you complete.  Probably send it to Compaq tomorrow. &lt;BR /&gt; &lt;BR /&gt;Trent</description>
      <pubDate>Tue, 31 Jul 2001 06:33:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961262#M21848</guid>
      <dc:creator>brownts</dc:creator>
      <dc:date>2001-07-31T06:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961263#M21849</link>
      <description>Hi, &lt;BR /&gt; &lt;BR /&gt;Ive made the same discovery but the other way around. Ive made a COM -dll written in VB and I used the wizard to access it from VF. Everything works fine but there is a memoryleak when using strings and variants. No solution found yet &lt;BR /&gt;Im using Windows NT/2000 and VF6.1a &lt;BR /&gt; &lt;BR /&gt;/Martin</description>
      <pubDate>Fri, 03 Aug 2001 17:17:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961263#M21849</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-08-03T17:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961264#M21850</link>
      <description>The COM Server Wizard is a different beast than the COM Module Wizard.   &lt;BR /&gt; &lt;BR /&gt;Prior to CVF 6.5 the Module Wizard generated code for intent(in) BSTRs that had a memory leak.  This was fixed in 6.5.  If you don't want to upgrade, then the solution is to call SysFreeString on the local integer (BSTR) variable in the wrapper function $ISomeInterface_MethodFoo after the actual COM method call is made. &lt;BR /&gt; &lt;BR /&gt;Do you have an example of a memory leak with Module Wizard generated code using variants?  I'm sure people would be interested in seeing it. &lt;BR /&gt; &lt;BR /&gt;hth, &lt;BR /&gt;John</description>
      <pubDate>Fri, 03 Aug 2001 22:04:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961264#M21850</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-08-03T22:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961265#M21851</link>
      <description>Martin, &lt;BR /&gt; &lt;BR /&gt;My first note seems to have misdiagnosed the problem.  We have been trying, off and on, to isolate the problem down to a concise piece of code.  We also are using Fortran to access VB COM objects including passing strings and variants.  The memory leak appears to occur when we convert a fortran character strings into a variant and send this to VB.  Sounds similar to your problem.  When we get it completely isolated we will send the code to Compaq. &lt;BR /&gt; &lt;BR /&gt;Trent</description>
      <pubDate>Fri, 03 Aug 2001 22:05:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961265#M21851</guid>
      <dc:creator>brownts</dc:creator>
      <dc:date>2001-08-03T22:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961266#M21852</link>
      <description>Trent, &lt;BR /&gt; &lt;BR /&gt;The wrapper code  that the Module Wizard generates for variants pretty much just passes what the caller has provided to the COM object's method (sometimes it makes a shallow copy like in the case of an optional arg).  I'm having a hard time imagining where it could create a leak.  Makes me wonder if the code that calls the wrapper is properly dealing with memory wrt variants and BSTRs.   &lt;BR /&gt; &lt;BR /&gt;COM memory management requires that If the argument is intent in, then the caller is required to allocate and deallocate the memory.  If the argument is intent out, the method will allocate and the caller gets to deallocate.  There's a brief example below if it helps at all. &lt;BR /&gt; &lt;BR /&gt;Just a stab in the dark, &lt;BR /&gt;John &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; &lt;BR /&gt; &lt;BR /&gt;&lt;FONT color="#008000"&gt;    ! COM memory management &lt;BR /&gt;    ! For intent in args, the caller owns the memory.  In this case,  &lt;BR /&gt;    ! caller allocates and deallocates memory for the string &lt;BR /&gt;    &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;function &lt;/FONT&gt;&lt;FONT color="#000000"&gt;foo_intent_in(pObj, Str) &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;result &lt;/FONT&gt;&lt;FONT color="#000000"&gt; &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;use &lt;/FONT&gt;&lt;FONT color="#000000"&gt;dfcom &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;implicit none &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;        ! dummy vars &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;integer&lt;/FONT&gt;&lt;FONT color="#000000"&gt;, &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;intent&lt;/FONT&gt;&lt;FONT color="#000000"&gt;(in) :: pObj &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;character&lt;/FONT&gt;&lt;FONT color="#000000"&gt;(len=*), &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;intent&lt;/FONT&gt;&lt;FONT color="#000000"&gt;(in) :: Str &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;integer &lt;/FONT&gt;&lt;FONT color="#000000"&gt;:: r &lt;BR /&gt; &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;        ! locals &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;integer &lt;/FONT&gt;&lt;FONT color="#000000"&gt;:: bstrStr, hr &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;type &lt;/FONT&gt;&lt;FONT color="#000000"&gt;(VARIANT) :: vStr &lt;BR /&gt; &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;        ! body &lt;BR /&gt;        ! convert to BSTR for packaging in a variant &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#000000"&gt;bstrStr = ConvertStringToBSTR( Str(1:&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;len_trim&lt;/FONT&gt;&lt;FONT color="#000000"&gt;(Str)) ) &lt;BR /&gt; &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;CALL &lt;/FONT&gt;&lt;FONT color="#000000"&gt;VariantInit(vStr) &lt;BR /&gt;        vStr%VT = VT_BSTR &lt;BR /&gt;        vStr%VU%PTR_VAL = bstrStr &lt;BR /&gt; &lt;BR /&gt;        hr = $ISomeInterface_MethodFoo_IntentIn(pObj, vStr) &lt;BR /&gt; &lt;BR /&gt;        r = hr &lt;BR /&gt;        hr = VariantClear(vStr)     &lt;/FONT&gt;&lt;FONT color="#008000"&gt;! calls SysFreeString  &amp;lt;===  critical &lt;BR /&gt;    &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;end function &lt;/FONT&gt;&lt;FONT color="#000000"&gt;foo_intent_in &lt;BR /&gt; &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;    ! For intent out args, the COM method allocates memory for the string  &lt;BR /&gt;    ! and the caller deallocates it. &lt;BR /&gt;    &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;function &lt;/FONT&gt;&lt;FONT color="#000000"&gt;foo_intent_out(pObj, Str) &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;result &lt;/FONT&gt;&lt;FONT color="#000000"&gt; &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;use &lt;/FONT&gt;&lt;FONT color="#000000"&gt;dfcom &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;implicit none &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;        ! dummy vars &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;integer&lt;/FONT&gt;&lt;FONT color="#000000"&gt;, &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;intent&lt;/FONT&gt;&lt;FONT color="#000000"&gt;(in) :: pObj &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;character&lt;/FONT&gt;&lt;FONT color="#000000"&gt;(len=*), &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;intent&lt;/FONT&gt;&lt;FONT color="#000000"&gt;(out) :
: Str &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;integer &lt;/FONT&gt;&lt;FONT color="#000000"&gt;:: r &lt;BR /&gt; &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;        ! locals &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;integer &lt;/FONT&gt;&lt;FONT color="#000000"&gt;:: bstrStr, hr &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;type &lt;/FONT&gt;&lt;FONT color="#000000"&gt;(VARIANT) :: vStr &lt;BR /&gt; &lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;        ! body &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;CALL &lt;/FONT&gt;&lt;FONT color="#000000"&gt;VariantInit(vStr)      &lt;/FONT&gt;&lt;FONT color="#008000"&gt;! must pass an initialized variant &lt;BR /&gt;        &lt;/FONT&gt;&lt;FONT color="#000000"&gt;Str = " " &lt;BR /&gt; &lt;BR /&gt;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Aug 2001 02:09:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961266#M21852</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-08-04T02:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Memory Leak with COM Server</title>
      <link>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961267#M21853</link>
      <description>Gotta love that forum message size limit.  &lt;&gt; &lt;BR /&gt;Get the sample at &lt;A href="http://www.termine.org/f90/variantmem.f90" target="_blank"&gt;http://www.termine.org/f90/variantmem.f90&lt;/A&gt; &lt;BR /&gt; &lt;BR /&gt;-John&lt;/&gt;</description>
      <pubDate>Sat, 04 Aug 2001 02:16:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Memory-Leak-with-COM-Server/m-p/961267#M21853</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-08-04T02:16:23Z</dc:date>
    </item>
  </channel>
</rss>

