[vtkusers] Serious leaks in all vtk versions

Mathieu Malaterre mathieu.malaterre at kitware.com
Thu May 20 11:35:02 EDT 2004


Ali,

	When you build VTK, you may want to turn VTK_DEBUG_LEAKS:ON (this is in 
advanced option). Therfore when you write your own example you won't 
forget to delete vtk object.

	BTW I didn't /really/ send you the same message two times, I am used to 
do reply all so that vtkusers also benefit from your question/answer.

	Finally please find attached the correct vtk example

Mathieu


#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"

int main ()
{

   // create sphere geometry
   vtkSphereSource *sphere = vtkSphereSource::New();
   sphere->SetRadius(1.0);
   sphere->SetThetaResolution(18);
   sphere->SetPhiResolution(18);

   // map to graphics library
   vtkPolyDataMapper *map = vtkPolyDataMapper::New();
   map->SetInput(sphere->GetOutput());

   // actor coordinates geometry, properties, transformation
   vtkActor *aSphere = vtkActor::New();
   aSphere->SetMapper(map);
   aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue

   // a renderer and render window
   vtkRenderer *ren1 = vtkRenderer::New();
   vtkRenderWindow *renWin = vtkRenderWindow::New();
   renWin->AddRenderer(ren1);

   // an interactor
   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
   iren->SetRenderWindow(renWin);

   // add the actor to the scene
   ren1->AddActor(aSphere);
   ren1->SetBackground(1,1,1); // Background color white

   // render an image (lights and cameras are created automatically)
   renWin->Render();

   // begin mouse interaction
   iren->Start();

  sphere->Delete();
  map->Delete();
  aSphere->Delete();
  ren1->Delete();
  iren->Delete();
  renWin->Delete();

   return 0;
}


Ali - wrote:
> Hi Mathieu
> 
> I run the c++ example under XP/VS.NET.7.1 from 
> http://public.kitware.com/VTK/example-code.php , which Delete() is not 
> called at the end of it. So I added the following lines at the end of main:
> 
>  sphere->Delete();
>  map->Delete();
>  aSphere->Delete();
>  ren1->Delete();
>  iren->Delete();
> 
> This includes deleting everything but the render window which without it 
> I wont be able to see the output!
> 
> The result is still the same:
> 
> [I] Starting Purify'd vtkTest2.exe at 20/05/2004 14:38:52
> [E] BSR: Beyond stack read in chkstk {1 occurrence}
> [E] BSR: Beyond stack read in chkstk {1 occurrence}
> [E] BSR: Beyond stack read in chkstk {1 occurrence}
> [E] BSR: Beyond stack read in chkstk {1 occurrence}
> [E] BSR: Beyond stack read in chkstk {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [I] Starting main
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in delete(void *) {7 occurrences}
> [E] FMM: Freeing mismatched memory in delete(void *) {7 occurrences}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in delete(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in !>(void *) {1 occurrence}
> [E] FMM: Freeing mismatched memory in delete(void *) {4406 occurrences}
> [E] FMM: Freeing mismatched memory in !>(void *) {528 occurrences}
> [E] FMM: Freeing mismatched memory in delete(void *) {12 occurrences}
> [E] FMM: Freeing mismatched memory in !>(void *) {6 occurrences}
> 
> The FMM error are mainly from these two functions:
> 
> vtkCharArray::GetTuple(int,double *) [vtkCommon.dll]
> vtkAxisActor2D::vtkAxisActor2D(void) [vtkRendering.dll]
> 
> It seems to me somewhere in the pipeline some pointers are created using 
> malloc and deleted in c++ way.
> 
> 
> -Ali
> 
> 
> 
> 
>> From: Mathieu Malaterre <mathieu.malaterre at kitware.com>
>> To: Ali - <saveez at hotmail.com>
>> CC: vtkusers at vtk.org
>> Subject: Re: [vtkusers] Serious leaks in all vtk versions
>> Date: Thu, 20 May 2004 09:21:36 -0400
>>
>> Ali - wrote:
>>
>>
>>> Hi
>>>
>>> I just ran the standard vtk example under Rational PurifyPlu (and 
>>> this is NOT and advert for this product) and found uncountable error 
>>> regarding: "freeing mismatched memory".
>>>
>>> Basically the error occures whenever the visualistion pipeline is 
>>> updated, hence, it is a substantial one.
>>>
>>> Please let me know whether this is going to be debuged in near future 
>>> or I am wrong.
>>
>>
>>
>> Ali,
>>
>>     Which example are you running ? We are are also running valgrind 
>> and purify to detect memory leak, and we got rid of them (except 
>> timerlog maybe).
>>
>>     BTW, If you wrote your example make sure you call Delete at the end.
>>
>>
>> Mathieu
>>
>>
> 
> _________________________________________________________________
> Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
> http://join.msn.com/?page=features/featuredemail
> 
> 






More information about the vtkusers mailing list