Page 1 of 1

PostPosted: Thu Sep 19, 2002 3:23 pm
by Frank Crab
I would like to know what are memory leaks and waht harm may them cause.

Tahnks for help.

PostPosted: Thu Sep 19, 2002 4:26 pm
by goodey
To my knoladge it meens:
When a program uses memmory it locks that memmory so a different program dosent use it. After the program finished using the memmory it should free it up (unlock it). If it dosent you lose the use of that memmory, That whould be a leak.

Israel Vish

PostPosted: Thu Sep 19, 2002 4:46 pm
by jstadolnik
Programs with memory leaks tend to use more and more dynamic memory as they run, to the point where they run out of available memory and either crash or can no longer run (since further mallocs fail - robust programmers force thier apps to exit cleanly if this happens).

The rules of thumb are: 1) free what dynamic memory you use as soon as you are done with it, and 2) always check the return status of malloc type commands.

If you are getting memory leaks with POSE from a PocketC app then the source of the leak is either PocketC itself or in a native library you use. Any such leaks should be reported to the respective developer.


The PToolboxLib guy.

PostPosted: Thu Sep 19, 2002 5:14 pm
by soinsg
So if there is a memory leak, but the program doens't stop working or crash, does the OS free/cleanup the "leaked" memory automatically after the program exits?

PostPosted: Thu Sep 19, 2002 6:10 pm
by jstadolnik
Yes. PocketC will free it up its own internal dynamic heap when it an pocketC app exits, and the PalmOS will free the "palmos" heap for PocketC when PocketC exits. (There are two heaps in play here.)

However, the bottom line is that apps which leak tend to crash because they can use up all the available heap space. The longer a leaky program runs the greater the chance of a crash.

With few exceptions, you should never release an app which kicks out errors running on POSE (the palm OS emulator) whether they be leaks or otherwise, else you run the risk of crashing end user's machines.


The PToolboxLib guy.