You have been allocating handles and pointers mixing calls,
so that you have non-movable chunks just in the middle of
the heap. This problem arises because locked handles tend
to go to upper memory, while pointer allocations is made
in lower addresses, so that there is the largest free
block possible. But there is the risk of heap fragmenta-
tion if you mix handle and pointer allocation, or if you
use pointer allocation with some kind of pseudorandom dea-
llocation, you can start making holes that don't fit lar-
ger blocks when they're demanded...
As a rule of thumb, you should pair pointer allocations
at the enter and exit of functions, and use handles for
any other allocation, and locking and unlocking them also
in a clearly paired form...
----- Original Message -----
From: "Michal Seliga" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Wednesday, June 06, 2001 12:23 PM
Subject: Memory problems
> Hello
>
> I asked once, but I've got no reply...
>
> My problem is, that I have enough free heap (almost 60kB), but too small
max. free block (29kB). How is it possible to defragment heap?
MemHeapCompact doesn't
> help.
>
> My code looks like this:
>
> MemHeapFreeBytes(0,&x1,&x2); file://only test, this shows nearly 60kb
free heap and 50kb max free block
> ok=SelectDay(selectDayByDay,&(xxl.month), &(xxl.day),&(xxl.year),"tum");
> MemHeapFreeBytes(0,&x1,&x2); file://only test, but now this shows same
amount of free heap as before, but only 29kB long max. free block - and not
every
> time...
>
> I have to allocate 32kB later in my program and _sometimes_ it fails, I
believe it is because of this strange 50->29 reduction
>
> Is there any known bug with SelectDay() function?
>
> I use PalmOS3.5 on Handspring Visor Platinum and Metrowrks CodeWarrior r6
>
> Please reply to my email as well (if possible)
>
> bye
>
> --
> 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/