 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
D Ray Guest
|
Posted: Sun Oct 15, 2006 11:50 pm Post subject: Memory Leak Using Locate |
|
|
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
|
Posted: Mon Oct 16, 2006 7:21 am Post subject: Re: Memory Leak Using Locate |
|
|
| 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
|
Posted: Mon Oct 16, 2006 8:10 am Post subject: Re: Memory Leak Using Locate |
|
|
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 |
|
 |
|
|
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
|
|