<br>Hi Neil,<br><br>Is the RegisterFactory() line being called from <br>code in a DLL library  ?<br><br><br>    Please let us know,<br><br><br>          Thanks<br><br><br>               Luis<br><br><br>--------------------------------------------------------------<br>
<div class="gmail_quote">On Fri, Jun 25, 2010 at 2:14 AM,  <span dir="ltr">&lt;Neil.Burdett@csiro.au&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">









<div link="blue" vlink="purple" lang="EN-AU">

<div>

<p class="MsoNormal">Hi,</p>

<p class="MsoNormal">     I’m currently porting an application from Linux
(Ubuntu) to Windows (Visual Studio 9 2008). The code works fine under Linux but
the following line in Visual studio</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">  itk::ObjectFactoryBase::RegisterFactory(
itk::INRImageIOFactory::New() );</span></p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">causes a memory leak (shown by the visual leak detector):</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">---------- Block 46358 at 0x04EBACB8: 92 bytes
----------</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">  Call Stack:</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">    f:\dd\vctools\crt_bld\self_x86\crt\src\dbgmalloc.c
(56): malloc</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">   
f:\dd\vctools\crt_bld\self_x86\crt\src\newaop.cpp (7): operator new[]</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">   
c:\milxview-win32-depend\src-itk-3.16.0\code\common\itklightobject.cxx (102):
itk::LightObject::operator new</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">    c:\milx-view\lib\include\itk-ext\modules\io\itkinrimageiofactory.h
(52): itk::INRImageIOFactory::New</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">   
c:\milx-view\testing\src\milxcte\milxemsfiltertest.cxx (75): main   </span><b><span style="font-size: 8pt; font-family: Wingdings; color: red;">ß</span></b><b><span style="font-size: 8pt; font-family: &quot;Courier New&quot;; color: red;">- This line</span></b><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;"></span></p>


<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c
(582): __tmainCRTStartup</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c
(399): mainCRTStartup</span></p>

<p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: &quot;Courier New&quot;;">    0x7C817077 (File and line number not available):
RegisterWaitForInputIdle</span></p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Under windows do we have to delete this object? Because I
see there is a win32 branch in the itklightobject.cxx i.e.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">/**</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"> * Avoid DLL boundary problems.</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"> */</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">#ifdef</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> _WIN32   </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">void</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">*</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">LightObject</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">::<span style="color: blue;">operator</span> <span style="color: blue;">new</span>(size_t n)   </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">  <span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: blue;">char</span>[n];       </span><b><span style="font-size: 8pt; font-family: Wingdings; color: red;">ß</span></b><b><span style="font-size: 8pt; font-family: &quot;Courier New&quot;; color: red;">- This line
corresponds to line 102 above</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">void</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">*</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">LightObject</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">::<span style="color: blue;">operator</span> <span style="color: blue;">new</span>[](size_t n)</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">  <span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: blue;">char</span>[n];</span></p>


<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">void</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">LightObject</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">::<span style="color: blue;">operator</span> <span style="color: blue;">delete</span>(<span style="color: blue;">void</span>* m)</span></p>


<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">  <span style="color: blue;">delete</span> [] (<span style="color: blue;">char</span>*)m;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">void</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">LightObject</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">::<span style="color: blue;">operator</span> <span style="color: blue;">delete</span>[](<span style="color: blue;">void</span>* m,
size_t)</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">{</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">  <span style="color: blue;">delete</span> [] (<span style="color: blue;">char</span>*)m;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">#endif</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">Any help most appreciated</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;"> </span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">Neil</span></p>

</div>

</div>


<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>