Using a handle (and unlocking it) allows the memory manager to move it to make room. 
This is important if the memory is going to stick around for a while. Over time, with 
allocations and deallocations occurring out of sequence, memory gets fragmented into 
lots of little pieces. Eventually, an allocation can fail because it can't find any 
pieces that are big enough, even though there is plenty of space available in total. 
If you use handles and lock them only for short periods of time, you allow the memory 
manager to clean things up. There are no hard and fast rules, but my rule of thumb is 
to use pointers for memory that is allocated and deallocated in the same routine, and 
to use handles for anything that outlives the routine.
--
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/

Reply via email to