> First since I am using C++ instead of C, I am using new and delete.
> This is the same as using MemPtrNew and MemPtrFree, right?
You've got the runtime sources...you can see for yourself if this is true or
not.
> New creates a
> nonmovable chunk in the dynamic heap and delete would delete it. The only
> down side in using this technique is that the memory isn't movable to the
> system. Correct?
I think that there are many subtle issues here that can be debated ad nauseum,
but essentially that's correct.
> Is this a bug in.... somewhere? I didn't allocate anything and the
> error was thrown?
What do you mean you didn't allocate anything? You loaded a form...don't you
think that will perform memory allocations? If you want to clean up after
yourself, call FrmCloseAllForms. Or, as David Fedor suggested today with
regards to handling the error message Palm OS 3.5 and displays when your
application has memory leaks:
* See also http://www.palmos.com/dev/tech/docs/palmos35/topissues.html for
* other explanations of this message, and other common error messages like
* this.
-- Keith
Ralph Krausse <[EMAIL PROTECTED]> on 07/21/2000 09:33:44 AM
Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent by: Ralph Krausse <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
cc: (Keith Rollin/US/PALM)
Subject: Memory Leaks
Hello all,
I have been trying to find out if my application has any memory
leaks. Two questions.
First since I am using C++ instead of C, I am using new and delete.
This is the same as using MemPtrNew and MemPtrFree, right? New creates a
nonmovable chunk in the dynamic heap and delete would delete it. The only
down side in using this technique is that the memory isn't movable to the
system. Correct?
Second, during my hunt for memory leaks, I came across this piece of
code.
PilotMain()
{
#if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
Dword startFreeDynamicMemory, endFreeDynamicMemory,
junk
MemHeapFreeBytes(0, &startFreeDynamicMemory, &junk);
#endif
DoApp();
#if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
MemHeapFreeBytes(0, &endFreeDynamicMemory, &junk);
ErrNonFatalDisplayIf (startFreeDynamicMemory !=
endFreeDynamicMemory, "Memory Leak Occurred");
#endif
}
I found it at http://oasis.palm.com/dev/kb/papers/1146.cfm.
Sure enough, I had a leak. So just to test something, I created a new C++
application with CW, put this code in, compiled, linked and ran it. Upon
application termination, the error was thrown. Again, I didn't put any code
other than the above code. In fact, here is my code. *** Is what I put
in......
static DWord StarterPilotMain(Word cmd, Ptr cmdPBP, Word
launchFlags)
{
Err error;
error = RomVersionCompatible (version20, launchFlags);
if (error) return (error);
switch (cmd)
{
case sysAppLaunchCmdNormalLaunch:
***ULong startFreeDynamicMemory,
endFreeDynamicMemory,junk;
***MemHeapFreeBytes(0,
&startFreeDynamicMemory, &junk);
error = AppStart();
if (error)
return error;
FrmGotoForm(MainForm);
AppEventLoop();
AppStop();
***MemHeapFreeBytes(0,
&endFreeDynamicMemory,&junk);
***ErrNonFatalDisplayIf
(startFreeDynamicMemory != endFreeDynamicMemory,"Memory Leak Occurred");
break;
default:
break;
}
return 0;
}
Is this a bug in.... somewhere? I didn't allocate anything and the
error was thrown? What could be the problem? Palm? MetroWorks? Anyone want
to take a shot at this? By the way, I am using a Symbol 1740, Palm OS 3.2
with 8 Meg.
Thanks
Ralph Krausse
Expo International, Inc...
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/