"Chris Antos" <[EMAIL PROTECTED]> wrote:
>from looking at the OS source for ResLoadForm (called by FrmInitForm),
file
>"HwrRes.c" line 85, there's an obvious low-memory bug.  it allocates
memory

"Andrew Ball" wrote:
>Is this, in fact, a bug?  Or should my programming never put
>the OS in a condition where I expose this bug?


Programs should never request functionality without designing to make sure
that there is enough memory for success.  Or at least that is the followed
approach.  This is a bit vague so I'll talk about this.  In general,
optional UI services that the user can request like the keyboard, find
dialog, the old launcher, and so on were designed to fail gracefully when
there isn't enough memory.  It's not ideal because the user's request is
being denied, but it's safer.  Non optional requests like opening a
database or displaying a form are designed to fail when there isn't enough
memory.  These are cases were the program design must account for
sufficient memory.  The belief is that the code is smaller and simpler when
it doesn't have to detect and recover from this problems, and that's it's
not unreasonably hard to do.  As proof, we followed this for all of our
apps.  Several folks have pointed out that there aren't hard numbers to
follow.  This is true.  And as long as Hacks exists, will always be true.
But there are some simple techniques.  Generally, go to the deepest part of
your UI, and then pop up system dialogs (keyboard or find or contrast or
whatever).  Try and have a low battery alert or alarm then happen.
Ideally, check how much heap is left.  Alternatively, develope with an
extra buffer (a few KB) which you can remove for the release build.  This
will flush out problems and assure you of a minimum buffer for your users.

Note that this is very different from running out of storage memory. This
is beyond a developer's control so Palm OS does provide feedback and apps
are expected to handle those cases.  This should be tested too.  One thing
I've seen missed is the inability to even create a database because the
device is full.  To test, run gremlins until the device fills, then keep on
going for a while longer.  Alternatively, allocate memory until the storage
heap is full, then test.  There is the console 'hf 1 400' command for those
with PalmDebugger or Simulators so you don't have to do this
programatically.


As for FrmInitForm, since it's the most common function to fail when apps
are too low on memory, an error was added last year to better indicate the
problem ("Out of memory").


-Roger Flores


Reply via email to