At 12:13 PM 11/8/2000, Tilo Christ wrote:
>Oops, I asked the wrong question (I shouldn't write e-mails early in the
>morning). I really wanted to ask about locking and releasing database records in
>resource databases.
>Like in this typical piece of code:
>
> MemHandle resH = DmGetResource( bitmapRsc, maskID );
> ErrNonFatalDisplayIf( !resH, "Missing mask" );
> BitmapType* resP = (BitmapPtr)MemHandleLock(resH);
>
> WinDrawBitmap (resP, 0,0);
>
> MemPtrUnlock(resP);
> DmReleaseResource( resH );
>
>Will there be any adverse side-effects to keeping the Resource locked if I need
>it a lot of times? The DmGetResource method does eat up a considerable amount of
>CPU cycles, according to the profiler log.
You might want to cache the handle for the resource if that's a bottleneck for you.
Once you have the handle, you need to lock it, and that's just the same as locking a
record: they both use the underlying memory manager. So, keeping the resource locked
for extended periods of time isn't a good idea, especially if you're allocating memory
while it's locked. But, you don't need to keep it locked in order to avoid repeatedly
finding the handle for a resource.
--
Peter Epstein
Palm Inc. Developer
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/