Scott L. Johnson wrote in message <5911@palm-dev-forum>...
>
>> From: Richard M. Hartman [mailto:[EMAIL PROTECTED]]
>> What does the OS normally do for memory management
>> on label objects on forms?  Likewise, what must I do if
>> I am going to mess w/ the label text?
>
>When a form is initially loaded, the text pointer in every control (and
>label, etc) points to a string of bytes that is embedded inside the form
>object itself.  The entire form object itself is a single chunk in the
>dynamic heap.
>
>When you close a form, the OS basically just frees the single chunk that
>constitutes the form object.  It does not attempt to free any other memory
>chunks that may be referenced by the various pointers in controls and
labels
>within the form.  It just assumes that nothing got changed, so that the
>controls and labels still point to the embedded strings within the form
>object.
...
>The key to all this is to understand exactly who (you -or- the form object)
>owns the memory you're about to fiddle with.  If you own it, then you need
>to clean it up.

Ok, your explanation makes it pretty clear for labels.  I can see how
their original text is part of the resource so the pointers are "included"
when you deallocate the form resource as a whole.

But now what about fields (using FldSetTextHandle() & FldGetTextHandle())?

The documentation states:

     If the previous text handle points to a string on the dynamic heap
    and you want to free it, use     FldGetTextHandle

But that is a big "if" there ... does the initial handle for a field point
to
a string on the dynamic heap?  If so, I am responsible for freeing it
if I replace it with my own handle, if not then I am not responsible.  So I
know what to do for each answer but I don't know the answer....

--
-Richard M. Hartman
[EMAIL PROTECTED]

186,000 mi/sec: not just a good idea, it's the LAW!






-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to