MemHandleLock is surprisingly slow function. I've benchmarked it many times and got awful results - it was a times slower than everything else in my program. I found no way to avoid it - even if I use the the handle as a pointer to pointer (and the value it points is the actual value I receive from MemHandleLock) I'm getting fatal alerts. So the only way I found is to make a FtrPtrNew at the start of the program, lock all the records and store the pointers in this feature memory, then unlock back at the end. Sad but true.

Richard Coutts wrote:

My database has typically 300 or so records where each records is from 100
byts to 65535 bytes long, with the typical size being around 10,000 bytes.
The first 20 or so bytes of each record is a table that describes what's in
the rest of the record, so when searching the database I often only need to
load the first 20 bytes of the record to determine if the remainder of the
record needs to be loaded.

I did it this way to speed up searching the database, but it still is taking
a surprisingly long time.  E.g., I'm averaging around 10 records per second,
which means it takes about 30 seconds to load the first 20 bytes of 300
records on a Tungsten E.

I'm wondering if I'm doing something wrong or if there's a way to speed
things up.  To load the first 20 bytes of each record, I loop through and
open each record like this:

for (index = 0; index < numRecs; index++)
{
     recHandle = DmGetRecord(dbHandle, index);
     // get the recID (need this later)
     DmRecordInfo( dbHandle, index, NULL, &recID, NULL);
     // get the buffer
     buffer = (char*)MemHandleLock(recHandle);
          :
     // do other stuff here to see if we need to search the rest of the
record
          :
     MemHandleUnlock(recHandle);
}

Thanks,
Rich



-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to