>1) Which method, dmNewHandle or MemHandleNew would be a better
choice?
If you are going to allocate this memory and hold on to it throughout
your entire program, I don't think there is much difference between
doing it as a global and doing it in dynamic ram using MemHandleNew
(or probably better, MemPtrNew). 3 - 4k is not all that big, provided
you are not doing anything else in dynamic ram that takes up lots of
room (like saving offscreen images, etc.)
The main reason not to use a global is that globals are not always
available. If you need this information during a Find, for example,
you cannot put it in a global. Your application will crash when the
user does a Find while running a different application.
If these arrays are likely to grow bigger, and you want this to run
on an older device, you might consider putting the arrays in storage
ram using DmNewHandle. Your dynamic ram will not be impacted then.
However, make sure you free that memory before exiting your
application.
>2) Is there still a better way than in (1)?
It depends on what you are specifically doing. For example, if this
is very static information that takes a long time to create, you can
consider putting it in a resource. That will make your application
bigger, but creating the array will be faster. It all depends.
>3) What benefits are gained by declaring memory and using a ptr
>instead of a public array?
As mentioned above, Globals are not available during most launch
codes. If you need this information during a Find, for example, you
will have to recreate the memory, depending on whether your app was
running at the time of the Find. See the sample source code for
examples on how to properly determine when globals are available.
The trade off between dynamic and storage ram is mainly write speed.
Whenever you write to the storage ram, you have to use DmWrite (and
related) calls.
Another small issue is that you are locking a decent sized chunk down
in memory. If you put it in the storage heap, that is not all that
big a deal, because generally the storage heap is much larger and can
handle it, and your app is locked down when your running anyways.
If you decide to put it in dynamic RAM, then use MemPtrNew instead of
MemHandleNew. MemPtrNew tries to put the memory in an area of the
heap with other parts of memory that are not expected to grow or
move. Similarly, MemHandleNew puts handles together in a different
area of the heap. The assumption is that handle based memory is
likely to grow or move around. If you lock something that was created
using MemHandleNew, then you might create an island in your dynamic
heap that would make it harder for the memory manager to manipulate
the handles. The real impact depends on the size of the memory you
are locking, how early in your program you are allocating it, and the
size of the dynamic heap.
>4) What disadvantages are there by doing this?
Hopefully the above covers it. If you don't need this info during a
Find or some other launch code that might be called from another app,
then just use a global.
Shannon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hands High Software
Award winning software for the Palm(tm) Computing platform
<http://www.handshigh.com/>
[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~