View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011901VTK(No Category)public2011-02-28 03:512013-04-05 20:23
ReporterPetr Petrov 
Assigned ToRobert Maynard 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
Platformintel x86OSWindows VistaOS VersionWindows 6.0
Product Version 
Target VersionFixed in Version 
Summary0011901: Memory leak in vtkPLYReader class
DescriptionI have created a small program which reads an arbitrary .ply file.

Also I have enable memory leak detection by using DebugCRT:

_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

I put the above line in begin of main() function.

And I got a lot of memory leaks! Only for vtkPLYReader class!
It seems that another classes work fine!
TagsNo tags attached.
Project
Type
Attached Filescxx file icon vtkPLY.cxx [^] (74,020 bytes) 2011-03-03 07:06

 Relationships

  Notes
(0025602)
Sean McBride (developer)
2011-02-28 11:00

I once looked at fixing some of the PLY leaks, but gave up because the code is, umm, scary.
(0025625)
Petr Petrov (reporter)
2011-03-03 02:20

Small advise: the allocation is here:

void vtkPLY::ascii_get_element(PlyFile *plyfile, char *elem_ptr)
{
... skipped some code...

  /* do we need to setup for other_props? */

  if (elem->other_offset != NO_OTHER_PROPS) {
    char **ptr;
    other_flag = 1;
    /* make room for other_props */
    other_data = (char *) myalloc (elem->other_size); // ALLOCATION IS HERE!!!!!
    /* store pointer in user's structure to the other_props */
    ptr = (char **) (elem_ptr + elem->other_offset);
    *ptr = other_data;
  }
  else
    other_flag = 0;

...code continues....
(0025626)
Petr Petrov (reporter)
2011-03-03 02:21

also it is possible to use vtkHeap to track all memory leaks... but I am not sure
(0025631)
Petr Petrov (reporter)
2011-03-03 07:06

it seems that I have fixed these memory leaks.

just two lines change:

other_data = (char *) myalloc (elem->other_size); // ALLOCATION IS HERE!!!!!

change to

other_data = (char *) plyHeap->AllocateMemory(elem->other_size); // fixed, use vtkHeap to free memory as last resot


and another the similar change in a code place little below.

I have attached the modified source file (IO\vtkPLY.cxx)
(0025668)
Robert Maynard (developer)
2011-03-04 10:12

Merge topic '11901-ply-memory-leaks'

92c370f Fix memory leaks in the PLY implementation. Thanks to Petr Petrov.

 Issue History
Date Modified Username Field Change
2011-02-28 03:51 Petr Petrov New Issue
2011-02-28 08:12 David Partyka Assigned To => Robert Maynard
2011-02-28 08:12 David Partyka Status backlog => tabled
2011-02-28 11:00 Sean McBride Note Added: 0025602
2011-03-03 02:20 Petr Petrov Note Added: 0025625
2011-03-03 02:21 Petr Petrov Note Added: 0025626
2011-03-03 07:06 Petr Petrov Note Added: 0025631
2011-03-03 07:06 Petr Petrov File Added: vtkPLY.cxx
2011-03-04 10:12 Robert Maynard Note Added: 0025668
2011-03-04 10:12 Robert Maynard Status tabled => @80@
2011-03-04 10:12 Robert Maynard Resolution open => fixed
2013-04-05 20:23 Berk Geveci Status customer review => closed


Copyright © 2000 - 2018 MantisBT Team