Brian,
Here's the function I use:
void
GetAvailMemory (UInt32* totalMemP, UInt32* freeMemP)
{
// Declare local variables.
UInt32 totalMemory = 0; // Total memory.
UInt32 availMemory = 0; // Available memory.
UInt16 numHeaps = 0; // Number of heaps to traverse.
UInt16 i = 0; // Iterator.
UInt16 heapID; // Identifier for each heap.
UInt32 maxChunk = 0; // Max chunk size (per heap).
UInt32 freeMemory = 0; // Free memory (per heap).
// Get the number of heaps.
numHeaps = MemNumHeaps (0);
// Traverse the heaps.
for (i = 0; i < numHeaps; i++)
{
// For each heap...
// Get the heap identifier.
heapID = MemHeapID (0, i);
// Check if the heap is dynamic.
if (MemHeapDynamic (heapID))
{
// Heap is dynamic.
// Get amount of free memory (and size of max chunk).
MemHeapFreeBytes (heapID, &freeMemory, &maxChunk);
// Add free memory
availMemory += freeMemory;
// Add heap size to total.
totalMemory += MemHeapSize (heapID);
}
}
// Set out-params.
*totalMemP = totalMemory;
*freeMemP = availMemory;
// Return.
return;
}
Checking all the heaps may be overkill, but it works.
Hope this helps,
Greg
At 12:45 AM 6/15/00 -0400, you wrote:
>Does anyone have any sample code showing how to find the total RAM and
free RAM
>on a device? Apparently what I thought should work isn't the right way. I
>would like the report to be the same as what the info screen in launcher
>reports.
>
>Right now I'm using MemCardInfo(). I assume there are some calculations that
>need to be done to arrive at the correct value, but I don't know what they
are.
>
>If there's a KB article about this, well..
>
>Thanks
>
>--
>Brian Mathis
>Direct Edge
>http://www.directedge.com
>
>--
>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/