[IGSTK-Users] igstkImageSpatialObject memory management problem
Torleif Sandnes
Torleif.Sandnes at sintef.no
Wed Jun 20 05:37:20 EDT 2007
Hi Louis.
Thanks for your reply!
Not using the singleton pattern and instantiating a volumemanager
with VolumeManager::New(), the problem goes away.
I have put together a mininal application that reproduces the problem
with singleton pattern/DICOM image loading and attached it with this
email.
In the attached example, the VolumeManager is not in a library, but
the problem is still present.
Please set the constant TestVolumeManager::DICOMSERIES_PATH to a
suitable DICOM MR image.
> 1) Why are you using a Singleton for the volume Manager ?
There should never be more than one volume manager in my application.
> 2) Are you creating a shared library with this class ?
No, the class is in a static library. Also, linking the volumemanager
directly with the executable, the problem is still present.
(As in the attached example)
>
> 3) Can you please send the actual source files and
> test files ? something we could compile and run
> in order to reproduce the problem.
>
> In the code snippets that you sent we can't find
> the declaration of "imageSpatialObject_"... for
> example
See the attached files.
> BTW: Please don't do:
>
> using std::vector;
> using std::string;
>
>
> This is equivalent to opening the namespace for these
> symbols. Instead of doing this, you should always use
> the std:: namespace specifier.
Well, I agree that the "using" directive shouldn't be used in header
files and thus pollute every file that includes that header file.
I can also agree that putting "using" directives on the top of
implementation, (cpp/cxx), files can be bad, but IMHO it is okay in
more limited scopes to avoid writing the namespace prefix over and
over again.
Regards,
Torleif Sandnes
Sintef Health Resarch
-------------- next part --------------
PROJECT(TESTVOLMANAGER)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})
FIND_PACKAGE(ITK REQUIRED)
IF (USE_ITK_FILE)
INCLUDE (${USE_ITK_FILE})
ENDIF (USE_ITK_FILE)
INCLUDE(${ITK_USE_FILE})
FIND_PACKAGE(IGSTKSandbox)
IF(NOT IGSTKSandbox_DIR)
MESSAGE(FATAL_ERROR "Please set IGSTKSandbox_DIR.")
ENDIF(NOT IGSTKSandbox_DIR)
INCLUDE(${IGSTKSandbox_USE_FILE})
INCLUDE_DIRECTORIES(volumemanager)
ADD_EXECUTABLE(testVolManager MACOSX_BUNDLE main.cpp testvolumemanager.cpp volumemanager.cpp)
TARGET_LINK_LIBRARIES (testVolManager IGSTKSandbox )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: application/octet-stream
Size: 155 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/igstk-users/attachments/20070620/18a265f5/main-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testvolumemanager.cpp
Type: application/octet-stream
Size: 902 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/igstk-users/attachments/20070620/18a265f5/testvolumemanager-0002.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testvolumemanager.h
Type: application/octet-stream
Size: 632 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/igstk-users/attachments/20070620/18a265f5/testvolumemanager-0003.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volumemanager.cpp
Type: application/octet-stream
Size: 3413 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/igstk-users/attachments/20070620/18a265f5/volumemanager-0002.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volumemanager.h
Type: application/octet-stream
Size: 2137 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/igstk-users/attachments/20070620/18a265f5/volumemanager-0003.obj
More information about the IGSTK-Users
mailing list