Hi,
I'm trying to figure why the code below produces a memory leak:
static Int32 getFreeMem()
{
UInt32 maxP,freeBytesP; // [EMAIL PROTECTED]
MemHeapFreeBytes (0, &freeBytesP, &maxP);
return (Int32)freeBytesP;
}
DWord PilotMain(Word cmd, Ptr cmdline, Word launchFlags)
{
if (cmd == sysAppLaunchCmdNormalLaunch)
{
Int32 ini = getFreeMem(),fim;
Err e = DmCreateDatabase(0,"PERSON_PK2", 'SWAD', 'SWDB', false);
LocalID dbID = DmFindDatabase(0,"PERSON_PK2");
int apagou=0;
if (dbID)
{
Word attributes;
DmDatabaseInfo(0,dbID, NULL, &attributes,NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL);
attributes |= dmHdrAttrBackup | dmHdrAttrStream;
DmSetDatabaseInfo(0,dbID, NULL, &attributes,NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL);
apagou = DmDeleteDatabase(0,dbID) == 0;
}
fim = getFreeMem();
if (ini != fim)
{
char buf[40];
StrPrintF(buf, "leak %d %s %s",(int)(fim-ini),dbID?"created":"not
created",apagou?",deleted":",not deleted");
ErrDisplay(buf);
}
}
return 0;
}
When i run the code, it says: "leak -240 created,deleted".
What i have to do to make Palm OS release this memory? I'm runnning in a
Tungsten T.
Happy 2007
guich
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/