hi,
  I 'm facing probs on  memory leak with table -- in
my application i 'm displaying diff set of data in a
table with 3 columns & 10 rows  --  i 'm   following
the approach given in  Rhodes & Mckeehan's chapter on
table (page 210 - 215)- to insert data in every cell
i'm calling a custom Load routine as follows-- 

MemHandle gHandles[kNumTextColumns][kNumRows];
//declared globally
static void InitTableData(int TopNo)
{       
        CharPtr textPtr,s ;
        UInt column , row1  ,ListNo;
        for(column=0;column<kNumTextColumns;column++)
        for(row1=0; row1<kNumRows;row1++)
        {       
          -----------
        // some code to consider the scrolling and
        // get correct rowNo and data for diff column
        ----------
        ----------
        if(column==0)
                textPtr = Name[ListNo];
        else if(column==1)
                textPtr = Type[ListNo] ;
        else if(column==2)
                textPtr =Size[ListNo] ;
        
        gHandles[column][row1] =
MemHandleNew(StrLen(textPtr)+1); 
//allocate mem & return handle of the mem-chunk

        if(!gHandles[column][row1]) return;

        s = MemHandleLock(gHandles[column][row1]);

        StrCopy(s, textPtr);  
// copy the data to the mem chunk
                        
        MemHandleUnlock(gHandles[column][row1]);
        }
}
and i 'm calling this function at the end of my
table_initialization function 
(passing topNo as Zero) and in sclRepeatEvent.
This book doesn't mention anything abt freeing the
allocated mem handle in that example --but in my 
frmCloseEvent i did it as follows -
                        
case frmCloseEvent:
        for(i=0;i<kNumTextColumns;i++)
        for(j=0;j<kNumRows;j++)
        {
                if(gHandles[i][j]) 
                        MemHandleFree(gHandles[i][j]);
        }
        handled = false;
        break;

and i 'm handing exit button as follows :

case  OptionExit:
        EventType evtStop;
        -----------
        //call routine to free mem 
        //dellocate other golbal varibles
        ---------------
        evtStop.eType = appStopEvent;
        EvtAddEventToQueue (&evtStop);

        handled =false;
        break;

- but still it's giving memory leak whenever i press
the exit button and i 'm sure it's bocz the  memory 
allocated for ghandle -- how i can free the mem for
ghandle prpperly??
some more observations -
1) i'm calling FrmCloseAllForms() in my AppStop()
function -- and after entering into the main page
without doing anything if press "exit" button it's 
exiting without any mem leak --  
2) if i add FrmCloseAllForms() in my frmCloseEvent
it's giving Mem Error - SysFatalAlert with the message
"MemoryMgr.c, Line:4384,Free Handle--
3) if i put the FrmCloseAllForms() in ExitButon case
-- there also i 'm getting mem error as read frm
unallocated chunk of memory 

Can anybody tell me please where i 'm going wrong ??
Thanx a ton for any help --
pinaki

________________________________________________________________________
Yahoo! India Insurance Special: Be informed on the best policies, services, tools and 
more. 
Go to: http://in.insurance.yahoo.com/licspecial/index.html

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

Reply via email to