[Insight-developers] Question about delete on VC++

Jisung Kim bahrahm@yahoo.com
Mon, 30 Sep 2002 12:50:39 -0700 (PDT)


I looked at the dashboard for every plaform, but it
didn't report any warning about this.


--- Bill Hoffman <bill.hoffman@kitware.com> wrote:
> Isn't this a warning on some compilers?
> (Class with virutal table has non-virutal
> destructors?)
> 
> 
> -Bill
> 
> 
> At 03:41 PM 9/30/2002 -0400, Miller, James V
> (Research) wrote:
> >I ran the test through Purify.  This identified
> that a leak
> >occurred.  The I spent several hours trying to find
> why your
> >memory was not being deallocated.  Eventually, I
> put print 
> >statements in each node type's destructor to make
> sure they 
> >were being called.  As it turned out, the
> destructors were
> >never being called because the nodes in the kdtree
> store pointers
> >to a kdnode and kdnode did not have a destructor
> defined. This
> >meant that the compiler provided its own destructor
> which by
> >default is non-virtual.
> >
> >Jim
> >
> >
> >
> >> -----Original Message-----
> >> From: Jisung Kim [mailto:bahrahm@yahoo.com]
> >> Sent: Monday, September 30, 2002 2:16 PM
> >> To: Miller, James V (Research); insight-dev-list
> >> Subject: RE: [Insight-developers] Question about
> delete on VC++
> >> 
> >> 
> >> Thanks, Jim.
> >> 
> >> Could you tell me how did you found the memory
> leaks?
> >> I was experimenting with _CrtDumpMemoryLeaks()
> >> function. It would be helpful in future.
> >> 
> >> Thank you very much,
> >> 
> >> Jisung.
> >> 
> >> --- "Miller, James V (Research)"
> <millerjv@crd.ge.com>
> >> wrote:
> >> > Jisung,
> >> > 
> >> > I just fixed the memory leaks in your KdTree.
> >> > 
> >> > The base kd-node class did not have a "virtual"
> >> > destructor.  When the 
> >> > tree was being deleted, the destructors for
> "real"
> >> > kd-nodes was not 
> >> > being called.
> >> > 
> >> > Jim
> >> > 
> >> > 
> >> > 
> >> > > -----Original Message-----
> >> > > From: Jisung Kim [mailto:bahrahm@yahoo.com]
> >> > > Sent: Friday, September 27, 2002 1:53 PM
> >> > > To: Jisung Kim; Miller, James V (Research);
> >> > insight-dev-list
> >> > > Subject: RE: [Insight-developers] Question
> about
> >> > delete on VC++
> >> > > 
> >> > > 
> >> > > The print out result shows exact match
> between
> >> > > addresses of pointer (to nodes) and the
> order. 
> >> > > 
> >> > > 
> >> > > --- Jisung Kim <bahrahm@yahoo.com> wrote:
> >> > > > In a same thread.
> >> > > > 
> >> > > > I will do printing out address of nodes in
> >> > creation
> >> > > > and deletion in VC++ too. And let you know
> the
> >> > > > result.
> >> > > > 
> >> > > > --- "Miller, James V (Research)"
> >> > > > <millerjv@crd.ge.com>
> >> > > > wrote:
> >> > > > > Are those in different threads?
> >> > > > > 
> >> > > > > 
> >> > > > > 
> >> > > > > > -----Original Message-----
> >> > > > > > From: Jisung Kim
> [mailto:bahrahm@yahoo.com]
> >> > > > > > Sent: Friday, September 27, 2002 12:48
> PM
> >> > > > > > To: Miller, James V (Research);
> >> > insight-dev-list
> >> > > > > > Subject: RE: [Insight-developers]
> Question
> >> > about
> >> > > > > delete on VC++
> >> > > > > > 
> >> > > > > > 
> >> > > > > > Yes, the tree was created by the
> >> > > > > > itkWeightedCenteroidKdTreeGenerator and
> the
> >> > > > > deletion
> >> > > > > > logic is inside of the itkKdTree.
> >> > > > > > 
> >> > > > > > Is it a problem?
> >> > > > > > 
> >> > > > > > Thanks,
> >> > > > > > 
> >> > > > > > 
> >> > > > > > --- "Miller, James V (Research)"
> >> > > > > <millerjv@crd.ge.com>
> >> > > > > > wrote:
> >> > > > > > > Another thought.  Is the data
> allocated in
> >> > one
> >> > > > > > > thread and destroyed
> >> > > > > > > in another thread?
> >> > > > > > > 
> >> > > > > > > 
> >> > > > > > > 
> >> > > > > > > > -----Original Message-----
> >> > > > > > > > From: Miller, James V (Research) 
> >> > > > > > > > Sent: Friday, September 27, 2002
> 12:07
> >> > PM
> >> > > > > > > > To: 'Jisung Kim'; insight-dev-list
> >> > > > > > > > Subject: RE: [Insight-developers]
> >> > Question
> >> > > > > about
> >> > > > > > > delete on VC++
> >> > > > > > > > 
> >> > > > > > > > 
> >> > > > > > > > Strange.  If we were building Dlls,
> I
> >> > would
> >> > > > > say
> >> > > > > > > that maybe we were
> >> > > > > > > > allocating nodes in one DLL and
> >> > deallocating
> >> > > > > them
> >> > > > > > > in another DLL.
> >> > > > > > > > (I think each DLL has its own heap
> >> > > > > management).
> >> > > > > > > But since we are 
> >> > > > > > > > not building DLLs, then that is not
> the
> >> > > > > problem.
> >> > > > > > > > 
> >> > > > > > > > Have you run with VC the version
> that
> >> > prints
> >> > > > > out
> >> > > > > > > all the node
> >> > > > > > > > allocation and deletions?
> >> > > > > > > > 
> >> > > > > > > > Is there anything "inside" a node
> that
> >> > is
> >> > > > not
> >> > > > > > > being deleted? 
> >> > > > > > > > Perhaps a 
> >> > > > > > > > subitem is missing a destructor
> that
> >> > needs
> >> > > > to
> >> > > > > do
> >> > > > > > > something 
> >> > > > > > > > that another
> >> > > > > > > > compiler is providing by default.
> >> > > > > > > > 
> >> > > > > > > > 
> >> > > > > > > > 
> >> > > > > > > > 
> >> > > > > > > > Friday, September 27, 2002 10:16 AM
> >> > > > > > > > > To: insight-dev-list
> >> > > > > > > > > Subject: [Insight-developers]
> Question
> >> > > > about
> >> > > > > > > delete on VC++
> >> > > > > > > > > 
> >> > > > > > > > > 
> >> > > > > > > > > Hi.
> >> > > > > > > > > 
> >> > > > > > > > > I have a question for memory
> >> > deallocation
> 
=== message truncated ===


=====
Jisung Kim
bahrahm@yahoo.com
106 Mason Farm Rd.
129 Radiology Research Lab., CB# 7515
Univ. of North Carolina at Chapel Hill
Chapel Hill, NC 27599-7515

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com