Subject: re: MemPtrResize
From: "Orasanu Iuliana" <[EMAIL PROTECTED]>
Date: Mon,  9 May 2005 09:57:45 -0000

> Do you actually lock the memory anywhere, for instance?
No.
> Can't you use a linked list or something?
Yes.

I found in the docs this: This routine is always successful when shrinking the size of a chunk.

so... I've done this : (for testing)

pDBName = (char**)MemPtrNew( sizeof( char*)*1000);

If you are going to have a section of memory that can expand and contract, then you really should use a handle (assigned with MemHandleNew()) not a resizable pointer. When you want to read or write, then lock the handle, which gives you a pointer, then unlock the handle before resizing, discarding the pointer, which is no longer valid.


If your memory needs grow too large, then it is easier to switch over from heap memory to storage memory if you've used this technique, plus its a good way of differentiating between memory areas that aren't going to be resized and those that might be.

Also if you have several resizable memory areas or memory areas that aren't always being accessed, then the memory manager can move around memory owned by unlocked handles, which reduces the chance of fragmentation. Whereas when you allocate memory with MemPtrNew() that memory area is locked and immovable, unless you resize it larger.


Roger Stringer Marietta Systems, Inc. (www.rf-tp.com)


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

Reply via email to