🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Ternary operator memory leak

#17207
From: Mark Guerrieri
Date: Thu, 03 Apr 2003 08:40
36 lines
2238 bytes
Using BCB6 on Win2K all SP's applied to everything...

In an NT service, I have a thread which loops about 10 times a second and in
the loop is the following code:

...
AnsiString cOp = FQuery->FieldByName("operator")->AsString.Trim();
AnsiString cUserName = (cOp.Length() > 0) ?
FQuery->FieldByName("tsr")->AsString.Trim() : AnsiString("");
...

Where FQuery is a dynamically created at runtime TTable (I have also tried
TADOTable and TADOQuery, but I don't think this is the issue).

When the service runs, watching its process in the Task Manager (I know, its
only an approx.) show the memory usage of the process continually increasing
forever.

If I change the code to:

...
AnsiString cOp = FQuery->FieldByName("operator")->AsString.Trim();
AnsiString cUserName = "";
if(cOp.Length() > 0)
  cUserName = FQuery->FieldByName("tsr")->AsString.Trim();
...

Then Task Manager show the memory usage as constant and never increasing.

The code produces the expected results either way...

Can anyone else reproduce this?  If this is an issue, I likely have large
memory leaks in just about every piece of code I've ever written...

Mark
mguerrieri@cmsgrp.com
Technical Details
Message-ID: <3e8bf300$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!news1.optus.net.au!optus!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e689c7bb2171dc9a,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-04-03 00:50:29 PST
Reply-To: "Mark Guerrieri" <mguerrieri@cmsgrp.com>
From: "Mark Guerrieri" <mguerrieri@cmsgrp.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Ternary operator memory leak
Date: Thu, 3 Apr 2003 03:40:31 -0500
Lines: 38
Organization: Creative Marketing Strategies
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 66.200.143.50
Message-ID: <3e8bf300$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1049359104 66.200.143.50 (3 Apr 2003 00:38:24 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!news1.optus.net.au!optus!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail