Article View: borland.public.cppbuilder.nativeapi
Article #2503Re: Memory Leak - TForm or TStringGrid or DynamicArray
From: Dan Mayo
Date: Thu, 08 Feb 2007 22:51
Date: Thu, 08 Feb 2007 22:51
37 lines
2416 bytes
2416 bytes
Dan Mayo wrote:
> Alan Bellingham wrote:
> > std::auto_ptr<TSubForm> Foo(new TSubForm(this));
>
Ok, I have went thru all of my code and have changed to auto_ptrs for
the most part; and in places where I still need to use the pointer, I
have been sure to initialize it so that I don't attempt to delete a
pointer that hasn't been initialized.
The frequency of 'Out of Resources' messages has been reduced by this
change; but it still occurs, and it is in the same spot; except this
time rather that failing on a TSubForm *newform = new TSubForm(this);
it's failing on a std::auto_ptr<TSubForm> newform(TSubForm(this)); call.
Any additional ideas are greatly appreciated.
Thanks.
On a side note, is the following valid?
TSubForm *SubFormICanReferenceSomewhereElse = NULL;
void DoSomething()
{
if (SubFormICanReferenceSomewhereElse)
{
//do something with the SubFormICanReferenceSomewhereElse
}
}
void function()
{
std::auto_ptr<TSubForm> newform(TSubForm(this));
SubFormICanReferenceSomewhereElse = &*newform;
DoSomething();
SubFormICanReferenceSomewhereElse = NULL;
}
Technical Details
Message-ID:
<45cba995$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!wns13feed!worldnet.att.net!64.192.187.27!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<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>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,191a7d21d69bde32 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 08 Feb 2007 16:51:03 -0600 From: Dan Mayo <do_not_spam_dmayo2@netzero.com> User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Memory Leak - TForm or TStringGrid or DynamicArray 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> In-Reply-To: <45cb5f6b@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 216.174.165.174 Message-ID: <45cba995$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1170975125 216.174.165.174 (8 Feb 2007 14:52:05 -0800) Lines: 37 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!64.192.187.27!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail