🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2525

Re: Memory Leak - TForm or TStringGrid or DynamicArray

#2525
From: Remy Lebeau (TeamB)
Date: Fri, 09 Feb 2007 19:05
19 lines
1993 bytes
"Dan Mayo" <do_not_spam_dmayo2@netzero.com> wrote in message
news:45cc9095$1@newsgroups.borland.com...

> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> static std::auto_ptr<TForm> subform(new TForm(this));
> subform->ShowModal();
> }

That is very dangerous code.  Because the auto_ptr is static, it will
not be freed when the methods exits, but when the program is shut down
instead.  However, you have also assigned an Owner to the TForm as
well.  So that means that you have two different objects owning the
same TForm instance.  So you are going to end up with the TForm being
destroyed twice at two different times.


Gambit
Technical Details
Message-ID: <45ccc619$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45c7810f@newsgroups.borland.com> <45c7dc8d$1@newsgroups.borland.com> <45c89ec6@newsgroups.borland.com> <45ca4546$1@newsgroups.borland.com> <0sqks2t4c90epuc62bv635h36cqeat0ujd@4ax.com> <45cb3451$1@newsgroups.borland.com> <ptems2p2k2rquqdiao805ik2fhg6jl9n9a@4ax.com> <45cb5f6b@newsgroups.borland.com> <45cba995$1@newsgroups.borland.com> <45cbb722$1@newsgroups.borland.com> <45cc8d73$1@newsgroups.borland.com> <45cc9095$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,191a7d21d69bde32
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <45c7810f@newsgroups.borland.com> <45c7dc8d$1@newsgroups.borland.com> <45c89ec6@newsgroups.borland.com> <45ca4546$1@newsgroups.borland.com> <0sqks2t4c90epuc62bv635h36cqeat0ujd@4ax.com> <45cb3451$1@newsgroups.borland.com> <ptems2p2k2rquqdiao805ik2fhg6jl9n9a@4ax.com> <45cb5f6b@newsgroups.borland.com> <45cba995$1@newsgroups.borland.com> <45cbb722$1@newsgroups.borland.com> <45cc8d73$1@newsgroups.borland.com> <45cc9095$1@newsgroups.borland.com>
Subject: Re: Memory Leak - TForm or TStringGrid or DynamicArray
Date: Fri, 9 Feb 2007 11:05:24 -0800
Lines: 21
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <45ccc619$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1171047961 75.83.34.171 (9 Feb 2007 11:06:01 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail