look for a place where you are missing a MemPtrFree call.
also, try comparing the heap size before you allocate, and after you think
you've released the memory.

here are a couple macros i use to perform heap checking on a given scope.
if you're using C++, they're a great candidate for getting rolled into a
class that automatically checks the heap.  you'll need to replace the DbgMsg
function call with something of your own that accomplishes the same thing.

i use them at the beginning and end of my PilotMain function.


#define BEGIN_HEAP_CHECK \
    { \
    DWord startFreeDynamicMemory, endFreeDynamicMemory, junk; \
    Word crc; \
    Boolean fIgnoreLeaks = fFalse; \
    crc = Crc16CalcBlock(NULL, 256, 0); \
    MemHeapFreeBytes(0, &startFreeDynamicMemory, &junk); \

#define END_HEAP_CHECK \
    ErrNonFatalDisplayIf(crc != Crc16CalcBlock(NULL, 256, 0), "Low mem
corrupted"); \
    MemHeapFreeBytes(0, &endFreeDynamicMemory, &junk); \
    if (startFreeDynamicMemory != endFreeDynamicMemory && !fIgnoreLeaks) \
     DbgMsg((20, "memory difference: %ld", endFreeDynamicMemory -
startFreeDynamicMemory)); \
    } \



----- Original Message -----
From: Aaron Ardiri <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 01, 1999 7:42 AM
Subject: PalmOS: memory 'problems'


hi!

  in my program, i have the following occuring:

    ptr = MemPtrNew(64000);
    MemPtrFree(ptr);

  now.. this works fine, and it does what i expect, *but*..
  here is where it gets interesting..

  i can run this program a few times (8 from memory).. then,
  all of a sudden.. i get a memory error (basically, ptr == 0)

  why?

  it looks to me like i am dynamically asking for memory..
  freeing it.. and then leaving my program.. but when i come
  back.. it must still be locked or something??

  looks like it is not giving back the memory i freed..
  the error occurs until i physically reset the machine.

  this is NOT good..

  i tried changing it to use Handle's - but the same error
  occurs.. it most definately is NOT resetting my Heap.

  cheers

az.
--
Aaron Ardiri
Lecturer                       http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 352 8192           A/H: +46 26 10 16 11



Reply via email to