> I keep stubbing my toe on the MemHandle vs. MemPtr issue, and I can't seem
> to find any documentation that really does a good job of explaining how
they
> work, and work together. (If anyone knows of some good reading on the
> subject, I'd love to know about it.)

In the Palm OS Companion there is a chapter on the Palm's memory
architecture.  I found this enlightening.

> My specific question has to do with the data that a gadget can store. I
know
> it stores a pointer to something (anything), but in the function
> FrmSetGadgetData, can the argument that represents the pointer to the data
> be a *handle* to the data instead of a pointer?

It may be a handle only if Palm OS does not try to use it, i.e. if it is
just a "convenience" placeholder for your gadget-specific data.  (I don't
know if this is the case for gadgets...)

> I know a handle is a moveable chunk of memory and a pointer is a
nonmoveable
> chunk. I know that to read or write to a chunk, you have to make it
> nonmoveable (either by declaring it as a pointer right off the bat, or by
> declaring it as a handle, then locking the handle, which returns a
pointer -
> right?).

You are correct.

> But can you use a handle instead of a pointer as an argument to
> some functions? Like FrmSetGadgetData, in particular?

In general, no.  You need assurance that the OS won't try to use the handle
as a pointer.

> Finally, how important is it to use handles instead of pointers in the
first
> place? When my app is running, why does the OS need to be moving memory
> around anyway?

To prevent memory fragmentation.  Fragmentation makes it more likely that a
request for a given size chunk will fail.

> Or is it that idea that, while my app is running, if it's
> possible to start another app, THAT's when the OS might want to move the
> memory? I mean, if I use pointers instead of handles for the gadgets on a
> form, but they're around only as long as the form itself is around, is
this
> a big deal?

It might be a big deal -- it depends on how large the dynamic heap is (a
robust/portable application does not make any assumptions about this), how
much memory your form/app uses, and possibly (?) other factors outside of
your app's control.

Hope this helps.


Eric W. Sirko
Softworks Solutions, LLC



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

Reply via email to