> I just fixed the bug in my sample Palm application that had be bothered
> since Friday.  I had created a form with a list of strings built from a Palm
> resource.  I set up the list in response to the frmOpenForm event and I was
> freeing the memory when my form got a frmCloseForm event.  Although I was
> acquiring memory and freeing it correctly, the emulator reported a memory
> leak.  The problem was my event handler for frmCloseForm returned true,
> telling the system the event had been handled.  Because of this, the event
> never propogated into the system routines which actually deallocated the
> form.  Returning false from the handler (after it freed my resource handle
> and the handle to the array of char pointers) allowed the system to do its
> thing -- no more leak.
>
> So... would it be better for me to create my list and destroy it in response
> to winEnterEvent and winExitEvent?  Then, my event handler could return true
> without fouling the system.  My final application is going to contain five
> or six different forms, so it may help memory usage to only create these
> lists when the form is active.
>
>

No, don't look at winEnterEvent/winExitEvent.

Instead, as you've found, just go ahead and look for the frmCloseEvent, do
your freeing, and then return false.

Here's what my frmCloseEvent handling normally looks like:
    case frmCloseEvent:
        MyFormDeinit(FrmGetActiveForm());
        handled = false;
        break;

Neil
--
Neil Rhodes
Calliope Enterprises, Inc.
1328 Clock Avenue
Redlands, CA  92374
(909) 793-5995     [EMAIL PROTECTED]      fax: (909) 793-2545

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

Reply via email to