BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory Leak Using Locate

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop)
View previous topic :: View next topic  
Author Message
D Ray
Guest





PostPosted: Sun Oct 15, 2006 11:50 pm    Post subject: Memory Leak Using Locate Reply with quote



I'm using Locate to check for duplicates during a database import that
involves hundreds of thousands to millions of records. The following
code is consistently generating a memory leak, and I'm wondering (a) if
anyone knows the cause of it (there seems to be some stuff in previous
posts about Variants generally, but I couldn't nail down anything
specific), and if not, whether anyone can suggest a workaround that
would be just as fast. (By the way I define FBN as FieldByName as a
shortcut in coding, and LocateArray and SearchOptions are defined
globally rather than within this function).

Thanks, in advance, for any suggestions....



if (!RemoveDuplicatesCheckbox->Checked)
return false; // just assume not a dupe.

LocateArray.PutElement (Imp->FBN("First Name")->AsString, 0);
LocateArray.PutElement (Imp->FBN("Last Name")->AsString, 1);
LocateArray.PutElement (Imp->FBN("Middle Name")->AsString, 2);
LocateArray.PutElement (Imp->FBN("Street Name")->AsString, 3);
LocateArray.PutElement (Imp->FBN("House No")->AsString, 4);
LocateArray.PutElement (Imp->FBN("Apt No")->AsString, 5);
bool RetVal = DM->MList->Locate ("FIRST NAME;LAST NAME;MIDDLE
NAME;STREET NAME;HOUSE NO;APT NO", LocateArray, SearchOptions);
return RetVal;
Back to top
Mark Guerrieri
Guest





PostPosted: Mon Oct 16, 2006 7:21 am    Post subject: Re: Memory Leak Using Locate Reply with quote



Quote:
Thanks, in advance, for any suggestions....

Don;t know if it will make a difference, but you could simplify the code and
try:

Variant LocateArray[6];
LocateArray[0] = Imp->FBN("First Name")->AsString;
LocateArray[1] = Imp->FBN("Last Name")->AsString;
LocateArray[2] = Imp->FBN("Middle Name")->AsString;
LocateArray[3] = Imp->FBN("Street Name")->AsString;
LocateArray[4] = Imp->FBN("House No")->AsString;
LocateArray[5] = Imp->FBN("Apt No")->AsString;

May not make a difference, but this is how I typically set up a Locate and
I've not noticed any leaks...

Mark
Back to top
D Ray
Guest





PostPosted: Mon Oct 16, 2006 8:10 am    Post subject: Re: Memory Leak Using Locate Reply with quote



Thanks for the suggestion -- after doing further reading, it seems the
help has had a lot of people confused on this for a long time; I've been
using the other form since BCB1, but have never had to deal with a
million or more records so hadn't picked up on the leak. At any rate, I
changed it to look like your code with one exception:

bool RetVal = DM->MList->Locate ("FIRST NAME;LAST NAME;MIDDLE
NAME;STREET NAME;HOUSE NO;APT NO", VarArrayOf(LocateArray,5),
SearchOptions);

Memory leak is gone.

Thanks a lot for the suggestion/cure.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.