OSDynLoad_GetLoaderHeapStatistics

Syntax

#include <cafe/os/OSDynLoad.h>

typedef struct _OSDynLoad_LoaderHeapStatistics
{
    /* current total amount in bytes of allocations in code heap */
    unsigned int mCodeHeap_MemBytesUsed;
    /* current number of allocations in code heap */
    unsigned int mCodeHeap_UsedNumAllocations;   
    /* current total amount of free memory in code heap */
    unsigned int mCodeHeap_MemBytesFree;         
    /* largest allocation available in code heap */
    unsigned int mCodeHeap_MemLargestFreeBlock;	 
    /* current total amount in bytes of allocations in data heap */
    unsigned int mDataHeap_MemBytesUsed;	 
    /* current number of allocations in data heap */
    unsigned int mDataHeap_UsedNumAllocations;   
} OSDynLoad_LoaderHeapStatistics;

int OSDynLoad_GetLoaderHeapStatistics(
              OSDynLoad_LoaderHeapStatistics *apRetLoaderHeapStatistics);

Parameters

apRetLoaderHeapStatistics Pointer to the structure that the loader will use to return heap statistics.

Return Values

Returns an OSDYNLOAD_ERR_xxx error code (see OSDynLoad.h).

Description

Returns statistics on the heaps used by the loader at the time the function is called.

The loader uses 2 heaps to load the RPX and RPLs. In general, one heap is for data and the other is for code. The data heap uses the default heap unless the game developer changes that with OSDynLoad_SetAllocator. Because it can be changed, it is difficult for OSDynLoad_GetLoaderHeapStatistics to return useful information about how much space is free in the data heap. There are, however, alternatives to getting free space statistics for the data heap. For example, if you use OSDynLoad_SetAllocator to use an OS expanded heap, you can use MEMGetAllocatableSizeForExpHeap to return the largest available allocation size or MEMGetTotalFreeSizeForExpHeap to return the total free space.

OSDynLoad_GetLoaderHeapStatistics returns in the OSDynLoad_LoaderHeapStatistics structure's mDataHeap_MemBytesUsed field the current total size in bytes of allocations that the loader has made in the data heap and the mDataHeap_UsedNumAllocations field is for the current number of allocations that the loader used in the data heap.

The loader manages its own heap for code. The mCodeHeap_MemBytesUsed and mCodeHeap_UsedNumAllocations behave similarly to mDataHeap_MemBytesUsed and mDataHeap_UsedNumAllocations. mCodeHeap_MemBytesFree is the current total size in bytes of free space in the code heap. mCodeHeap_MemLargestFreeBlock is the largest size allocation currently available in the code heap.

We anticipate at least the following uses for OSDynLoad_GetLoaderHeapStatistics:

Do Not Call From

None.

See Also

OSDynLoad_Acquire
OSDynLoad_IsModuleLoaded
OSDynLoad_Release
OSDynLoad_SetAllocator

Revision History

2013/11/01 Added OSDynLoad_IsModuleLoaded.
2013/05/08 Automated cleanup pass.
2012/06/14 Initial version.


CONFIDENTIAL