Try allocation the memory with MemHandleNew,
MemHandleLock instead. Then free the memory using
MemHandleUnlock and MemhandleFree.

The question really is, whether the MemHandleFree
frees the memory or it just marks that memory chunk to
be freed later.

Thanks,
Mayank. 
--- priyesh  parikh <[EMAIL PROTECTED]>
wrote:
> Hello Everybody
> 
> I need some help  on the memory management in palm
> os.
> 
> When i am going to create a memory or handle then
> some times MemPtrNew or MemHandleNew returns NULL.
> 
> This will happen in the folowing cases
>  a) no memory 
>  b) you are trying to allocate too much..
> 
> Can you write me how to solve this problem.
> 
> Now i will explain you my exect problem.
> 
> I have a one form having 6 PopTrigger and of course
> with 6 List and also i have 6 sepreate databases to
> populate this dropdowns.
> 
> I am going to use follwing code to populate the
> dropdown with data. 
> 
> void cDsgNewPatient ::FillBloodList (ListType*
> pLookupList,UInt8 _dbCardNo,char* _dbName,UInt32
> _dbType,UInt32 _dbCreator)
> {
>       UInt16 count,i;
>       cLookupMaster *ObjLookupMasterFill;
>       
>       ObjLookupMasterFill = new
> cLookupMaster(_dbCardNo,_dbName,_dbType,_dbCreator);
>       count = ObjLookupMasterFill->GetNumRecords();
>       if (count != 0)
>       {
>               Blood = (char**)MemPtrNew(sizeof(char*)*count);
>               for(i=0;i<count;i++)
>               {
>                       ObjLookupMasterFill->GoTo(i);
>                       Blood[i] =
>
(char*)MemPtrNew(StrLen(ObjLookupMasterFill->GetDescr())+1);
>                       Blood[i] = ObjLookupMasterFill->GetDescr();
>               }
>               LstSetListChoices(pLookupList,Blood, count);
>               LstSetHeight (pLookupList,count);
> 
>       }
>       delete(ObjLookupMasterFill);
> }
> 
> This code works fine and all dropdown are populated
> properly. I am also freeing the memory using
> MemPtrFree() in the frmCloseEvent.
> 
> But if i go this form 20 times and come back to
> another form then it gives the error  "Null String
> Passed" means the line 
> 
> Blood = (char**)MemPtrNew(sizeof(char*)*count);
> 
> do not create the memory and returns NULL.
> 
> How to solve this problem.
> 
> i am very confused because i am freeing the memory
> in the frmCloseEvent i have checked that
> frmCloseEvent executes properly.
> 
> My question is that if i am able to open that form
> 19 times then why not more then 19.
> 
> i  have also tryed using 
> 
> hBlood=MemHandleNew (sizeof(char*)*count); 
> MemHeapCompact (MemHandleHeapID (hBlood));
> Blood=(char**)MemHandleLock(hBlood);
> ...
> ...
> MemHandleUnlock(hBlood);
> ...
> ...
> MemHandleFree(hBlood)(in the frmCloseEvent)
> 
> but the same thing happen.
> 
> please help me on this problem.
> 
> your small help is very valuable for me!!!
> 
> thanks
> 
> [EMAIL PROTECTED]
> 
> priyesh
> 
> 
>
_____________________________________________________
> Chat with your friends as soon as they come online.
> Get Rediff Bol at
> http://bol.rediff.com
> 
> 
> 
> 
> 
> -- 
> For information on using the Palm Developer Forums,
> or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

-- 
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