[Insight-developers] ObjectFactory memory leaks

Miller, James V (CRD) millerjv@crd.ge.com
Mon, 19 Nov 2001 14:28:33 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C17130.6056E180
Content-Type: text/plain

Is atexit() platform specific?  I thought that was part of the C++ standard for exception handling.

-----Original Message-----
From: Bill Hoffman [mailto:bill.hoffman@kitware.com]
Sent: Monday, November 19, 2001 2:00 PM
To: Miller, James V (CRD); 'Aljaz Noe'; Insight-Developers
Subject: RE: [Insight-developers] ObjectFactory memory leaks


Or, we can do what I did in VTK.   Use a file scope smart pointer that deletes the pointer.
Since the bug was assigned to me, I have checked in the above fix.
(atexit is too platform specific.)

-Bill

At 11:26 AM 11/19/2001 -0500, Miller, James V (CRD) wrote:


I think the atexit approach is the right way to resolve this.  The other option is to have Purify
ignore the this error.
  


-----Original Message----- 

From: Aljaz Noe [ mailto:noe@grasp.cis.upenn.edu <mailto:noe@grasp.cis.upenn.edu> ] 

Sent: Monday, November 19, 2001 10:59 AM 

To: Insight-Developers 

Subject: [Insight-developers] ObjectFactory memory leaks



Hi! 



I noticed that the ObjectFactoryBase does not release the allocated member m_RegisteredFactories when
the application finishes. Technically this is not a memory leak, since the memory is definitely
allocated only once and is released by OS when the application quits. It is however a bit annoying,
when searching for true memory leaks caused by bugs in other parts of code. 



Is this behavior by design, or is it a bug (feature???) in ObjectFactoryBase? 



The above problem can be eliminated quite easy by using the atexit function, but I might not be aware
of all the consequences. It seems to work on VC++, though. 



Aljaz 




------_=_NextPart_001_01C17130.6056E180
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=991002819-19112001><FONT color=#0000ff size=2>Is atexit() 
platform specific?&nbsp; I thought that was part of the C++ standard for 
exception handling.</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Bill Hoffman 
  [mailto:bill.hoffman@kitware.com]<BR><B>Sent:</B> Monday, November 19, 2001 
  2:00 PM<BR><B>To:</B> Miller, James V (CRD); 'Aljaz Noe'; 
  Insight-Developers<BR><B>Subject:</B> RE: [Insight-developers] ObjectFactory 
  memory leaks<BR><BR></FONT></DIV>Or, we can do what I did in VTK.&nbsp;&nbsp; 
  Use a file scope smart pointer that deletes the pointer.<BR>Since the bug was 
  assigned to me, I have checked in the above fix.<BR>(atexit is too platform 
  specific.)<BR><BR>-Bill<BR><BR>At 11:26 AM 11/19/2001 -0500, Miller, James V 
  (CRD) wrote:<BR>
  <BLOCKQUOTE class=cite cite type="cite"><FONT color=#0000ff size=2>I think 
    the atexit approach is the right way to resolve this.&nbsp; The other option 
    is to have Purify ignore the this error.</FONT><BR>&nbsp; 
    <DL><FONT face=tahoma size=2>
      <DD>-----Original Message----- 
      <DD>From:</B> Aljaz Noe [<A href="mailto:noe@grasp.cis.upenn.edu" 
      eudora="autourl">mailto:noe@grasp.cis.upenn.edu</A>] 
      <DD>Sent:</B> Monday, November 19, 2001 10:59 AM 
      <DD>To:</B> Insight-Developers 
      <DD>Subject:</B> [Insight-developers] ObjectFactory memory 
      leaks<BR><BR></FONT><FONT face=arial size=2>
      <DD>Hi!</FONT> 
      <DD><FONT face=arial size=2> 
      <DD>I noticed that the ObjectFactoryBase does not release the allocated 
      member m_RegisteredFactories when the application finishes. Technically 
      this is not a memory leak, since the memory is definitely allocated only 
      once and is released by OS when the application quits. It is however a bit 
      annoying, when searching for true memory leaks caused by bugs in other 
      parts of code.</FONT> 
      <DD><FONT face=arial size=2> 
      <DD>Is this behavior by design, or is it a bug (feature???) in 
      ObjectFactoryBase?</FONT> 
      <DD><FONT face=arial size=2> 
      <DD>The above problem can be eliminated quite easy by using the atexit 
      function, but I might not be aware of all the consequences. It seems to 
      work on VC++, though.</FONT> 
      <DD><FONT face=arial size=2> 
      <DD>Aljaz</FONT> 
      <DD> </DD></DL></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C17130.6056E180--