[Insight-users] itk::ObjectFactoryBase::RegisterFactory under win32

Neil.Burdett at csiro.au Neil.Burdett at csiro.au
Sat Jun 26 05:44:15 EDT 2010


Hi Luis,
            in this particular case the

itk::ObjectFactoryBase::RegisterFactory( itk::INRImageIOFactory::New() );

line is being called from an executable not a DLL as it's a unit test case

Neil

________________________________________
From: Luis Ibanez [luis.ibanez at kitware.com]
Sent: Saturday, June 26, 2010 5:50 AM
To: Burdett, Neil (ICT Centre, Herston - RBWH)
Cc: insight-users at itk.org
Subject: Re: [Insight-users] itk::ObjectFactoryBase::RegisterFactory under      win32

Hi Neil,

Is the RegisterFactory() line being called from
code in a DLL library  ?


    Please let us know,


          Thanks


               Luis


--------------------------------------------------------------
On Fri, Jun 25, 2010 at 2:14 AM, <Neil.Burdett at csiro.au> wrote:
Hi,
     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

  itk::ObjectFactoryBase::RegisterFactory( itk::INRImageIOFactory::New() );


causes a memory leak (shown by the visual leak detector):

---------- Block 46358 at 0x04EBACB8: 92 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_x86\crt\src\dbgmalloc.c (56): malloc
    f:\dd\vctools\crt_bld\self_x86\crt\src\newaop.cpp (7): operator new[]
    c:\milxview-win32-depend\src-itk-3.16.0\code\common\itklightobject.cxx (102): itk::LightObject::operator new
    c:\milx-view\lib\include\itk-ext\modules\io\itkinrimageiofactory.h (52): itk::INRImageIOFactory::New
    c:\milx-view\testing\src\milxcte\milxemsfiltertest.cxx (75): main   <--- This line
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (582): __tmainCRTStartup
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (399): mainCRTStartup
    0x7C817077 (File and line number not available): RegisterWaitForInputIdle


Under windows do we have to delete this object? Because I see there is a win32 branch in the itklightobject.cxx i.e.

/**
 * Avoid DLL boundary problems.
 */
#ifdef _WIN32
void*
LightObject
::operator new(size_t n)
{
  return new char[n];       <--- This line corresponds to line 102 above
}

void*
LightObject
::operator new[](size_t n)
{
  return new char[n];
}

void
LightObject
::operator delete(void* m)
{
  delete [] (char*)m;
}

void
LightObject
::operator delete[](void* m, size_t)
{
  delete [] (char*)m;
}
#endif

Any help most appreciated

Neil

_____________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users




More information about the Insight-users mailing list