Stack is very tight, so don't do this
         Char MemSpace[100000];

Instead do
         Char *MemSpace;
         MemSpace = (Char*)MemGluePtrNew(100000);

         ....

         if (MemSpace) {MemPtrFree(MemSpace); MemSpace = NULL;}

Handles vs pointers

Most modern programs don't use handles for heap memory allocation, 
though sometimes it makes sense to do so.

A handle is re-locatable by the OS when not locked, so use handles if 
you have long lasting memory chunks that aren't used in parts of your 
program. Then lock them when you need them and release the lock when 
you don't need to access them.  This way the OS can optimize memory layout.

Records in PDB files are write protected handles, which need special 
functions to write to them.
But, after locking down a pointer to a record, reading is as fast as 
normal memory!

Roger Stringer


At 03:15 AM 2/6/2007, you wrote:
>Subject: Re: Data structures: heap or PDB?
>From: "Jeff Loucks" <[EMAIL PROTECTED]>
>Date: Mon, 5 Feb 2007 20:16:18 -0800
>X-Message-Number: 35
>
>------=_Part_1311_3882042.1170735378091
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>Content-Transfer-Encoding: 7bit
>Content-Disposition: inline
>
> > I just got it into my head after reading the
> > docs that I should be ultra memory conservative, which doesn't seem
> > to be the case.
>
>Well, yes and no. The Foster quote makes some good points about PalmOS
>limitations:
>
>1. True dynamic heap (as opposed to storage heap) is only a fraction of
>advertised RAM.
>2. Even if dynamic heap is a megabyte or more, the legacy processor
>architecture choices limit many (not all) memory allocations to less than
>64K. This is most painful when segmenting a large app, and in data and stack
>allocation.
>3. The stack is miniscule, by default. It can be enlarged, or simply
>replaced, but will never match the seemingly 'endless' stack of a platform
>with virtual memory manglement.

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

Reply via email to