>From: "Chris Tutty" <[EMAIL PROTECTED]>
>
>"Stringer" <[EMAIL PROTECTED]> wrote
>>
>> Note: Some people suggest writing a custom new() to avoid the
>> heap allocation issue, but personally I don't like creating my
>> own version of a standard function.
>>
>OK, I'm curious. How does a custom new() overcome the heap issues. Do >you
>mean that they're creating the object in a locked chunk? If so, wouldn't
>you have to leave that chunk locked for the life of the program (or, at
>least, for the life of the object). Maybe that's the key - use this
>technique for short-lived objects.
>More importantly, since you can't write directly to that area of memory do
>you have to use DmWrite for all property manipulation?
>Chris Tutty
A locked memory chunk does not have to be written to with DmWrite(),
that's only for persistent 'database' memory (for files).
Keep in mind you have 4 kinds of memory available to you on the
Palm OS(r).
Stack (very small, a few KB, varies by OS)
Heap (very small, perhaps 4KB - 32KB, varies by OS)
Lockable memory (very, very large, limited by device RAM)
Palm OS 'database' (persistent, for files)
On Palm OS 3.0 and above, which had a much improved memory
manager, the locking of chunks of memory for the life of the program
is much less of an issue than for earlier versions of the OS, where it
could cause horrible memory fragmentation problems.
So if you are going to use this technique, I'd recommend freezing
out older versions of the Palm OS. Also the amount you lock is
important, so life time locks of 500KB is bad, but life time locks
of 50KB should be OK. << Controversial opinion? >>
I do allocate and lock chunks of memory, but anything that is going
to be allocated for the life of the program is allocated and locked
when the program first loads, and deallocated when it exits as part of
a master class object 'constructor' / 'destructor' function pair.
Roger Stringer
Marietta Systems, Inc.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/