Ramel,
We reporting problems, it helps to also mention what results you're expecting
and what results you're actually getting.
In the snippet you've included below, I'm assuming that you're wondering why
MemHeapFreeBytes is returning an apparently incorrect value. The reason is that
you're asking for the amount of free memory in the heap with the heap ID of "1".
The Palm OS supports multiple RAM heaps, but you're asking for the available
space in only one of them. You need to walk all the RAM heaps just like you walk
all of the memory cards in order to get the *total* amount of free space.
Use something like the following inside your card loop:
UInt numOfRAMHeaps = MemNumRAMHeaps(i);
for (UInt heapIndex = 0; heapIndex < numOfRAMHeaps; ++heapIndex)
{
UInt heapID = MemHeapID (i, heapIndex);
MemHeapFreeBytes(heapID, &free, &max);
*outFreeByte += free;
}
Or you could probably just use the value returned by MemCardInfo, which does the
same thing. You carefully *get* this value; I'm not sure why you're not using
it.
-- Keith
"Ramel Levin" <[EMAIL PROTECTED]> on 01/11/2000 08:01:48 AM
Please respond to [EMAIL PROTECTED]
Sent by: "Ramel Levin" <[EMAIL PROTECTED]>
To:
cc: (Keith Rollin/HQ/3Com)
Subject: Free Memory on PalmOS 2.0?!?!
We have a problem with showing the right amount of memory in Palm
professional. The code below works fine on OS 3.0 and above. Any ideas
what's wrong?
void
OSGetMemInfo(
ULong* outRomSize,
ULong* outRamBytes,
ULong* outFreeByte)
{
UInt numOfCards = MemNumCards();
ULong ram = 0L;
ULong free = 0L;
ULong max = 0L;
ULong rom = 0L;
*outRomSize = 0L;
*outRamBytes = 0L;
*outFreeByte = 0L;
for (UInt i = 0; i < numOfCards; i++) {
MemCardInfo(i, NULL, NULL, NULL, NULL, &rom, &ram, &free);
*outRomSize += rom;
*outRamBytes += ram;
}
MemHeapFreeBytes(1, &free, &max);
*outFreeByte = free;
}
Regards,
Ramel Levin
CTO
The PalmMate Team
Gotta a Palm? Gotta visit www.PalmMate.com