Better leak example

Tom Radcliffe radcliffe at igotechnologies.com
Thu May 11 10:28:57 EDT 2000


The exampled I posted last night was over-refined (why does this always
happen?)  It leaks on Linux but not Solaris. The example attached here
leaks on both Linux and Solaris.  The difference is the use of a
vtkAssembly rather than a vtkActor in two renderers in different render
windows.

I've got an eval copy of Purify and am currently setting up to run it
against this example on Solaris.  Stay tuned.  The current example has a
problem on exit as well -- there is a fatal XIO error on that appears to
be due to the call to Delete on the second render window.

--Tom

==================================
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkAssembly.h"
#include "vtkSphereSource.h"

void main( int argc, char *argv[] )
{
  // create two rendering windows and two renderers
  vtkRenderer *ren1 = vtkRenderer::New();
  vtkRenderWindow *renWindow1 = vtkRenderWindow::New();
  renWindow1->AddRenderer(ren1);

  vtkRenderer *ren2 = vtkRenderer::New();
  vtkRenderWindow *renWindow2 = vtkRenderWindow::New();
  renWindow2->AddRenderer(ren2);

  // create an assembly and give it cone geometry
  vtkConeSource *cone = vtkConeSource::New();
  vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
  coneMapper->SetInput(cone->GetOutput());
  vtkAssembly *coneActor = vtkAssembly::New();
  coneActor->SetMapper(coneMapper);

  // create an actor and give it sphere geometry
  vtkSphereSource *sphere = vtkSphereSource::New();
  vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
  sphereMapper->SetInput(sphere->GetOutput());
  vtkActor *sphereActor = vtkActor::New();
  sphereActor->SetMapper(sphereMapper);

  coneActor->AddPart(sphereActor);

  // assign our actor to both renderers
  ren1->AddActor(coneActor);
  ren2->AddActor(coneActor);

  // set the size of our window
  renWindow1->SetPosition(0,50);
  renWindow2->SetPosition(0,300);

  for(int i = 0; i < 100; i++)
  {
    renWindow1->Render();
    renWindow2->Render();
  }

  // Clean up
  ren1->Delete();
  ren2->Delete();
  renWindow1->Delete();
  renWindow2->Delete();
  sphere->Delete();
  sphereMapper->Delete();
  sphereActor->Delete();
  cone->Delete();
  coneMapper->Delete();
  coneActor->Delete();

}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: radcliffe.vcf
Type: text/x-vcard
Size: 364 bytes
Desc: Card for Tom Radcliffe
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20000511/2c9dd786/attachment-0001.vcf>


More information about the vtkusers mailing list