Hello XPerts,
I have problem with dynamic allocation memory in palm. Please help.
1. How do i convert array of pointers from using 'New' to 'MemGluePtrNew'/'MemPtrNew'?
Define your own operator new (using inline) that calls MemGluePtrNew. See http://www.palmoswerks.com/stories/storyReader$15
2. How to dispose dynamic array claimed by MemPtrNew/MemGluePtrNew? So far I used MemPtrFree but somehow it returns 'Fatal Exception' while closing applicaton?
If it's a dynamic array of objects, there's a hidden extra allocation that CodeWarrior's C++ compiler adds that holds the count of objects. Bypassing operator new causes problems when you delete.
3. MemHandle : Which should i use, MemPtrUnlock or MemHandleUnlock to unlock Pointer from Handle? If i lock chunk/handle with a pointer - Ptr = MemHandleLock(xx), do I need to dispose the pointer Ptr once i I have unlocked it? So far i only unlock the pointer and free up the handle (MemHandleFree).
They do the same thing. There's no preference in the OS to one form or the other. Actually, MemPtrUnlock is slightly faster.
4. What is the maximum size of chunk allocated by MemHandleNew? can it be exceed 64K such as MemGluePtrNew?
On the Tapwave Zodiac, it can exceed 64K, but on other Palm OS 5 devices, the limit is slighly less than 64K. On all OS 3.5 and later devices, MemGluePtrNew can allocate up to the maximum available chunk size on the dynamic heap.
-- Ben Combee, DTS technical lead, PalmSource, Inc. Read "Combee on Palm OS" at http://palmos.combee.net/
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
