i've detected a mamory leak in libfat (perhaps this comes from underlayers).
Here is my code to demonstrate that:
Code: Select all
#include <ogcsys.h>
#include <iostream>
#include <fat.h>
#include <wiiuse/wpad.h>
#include <sdcard/wiisd_io.h>
#include <cstdlib>
#include <unistd.h>
using namespace std;
static void *xfb;
static GXRModeObj *vmode;
void Pause()
{
while (1)
{
// Call WPAD_ScanPads each loop, this reads the latest controller states
WPAD_ScanPads();
// WPAD_ButtonsDown tells us which buttons were pressed in this loop
// this is a "one shot" state which will not fire again until the button has been released
u32 pressed = WPAD_ButtonsDown(0);
// We return to the main programme
if ( pressed & (WPAD_BUTTON_A | WPAD_BUTTON_HOME) )
break;
// Wait for the next frame
VIDEO_WaitVSync();
}
}
int main(int argc, char **argv)
{
VIDEO_Init();
vmode = VIDEO_GetPreferredMode(NULL);
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
VIDEO_Configure(vmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(false);
VIDEO_Flush();
VIDEO_WaitVSync();
if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
int x = 20, y = 20, w, h;
w = vmode->fbWidth - (x * 2);
h = vmode->xfbHeight - (y + 20);
// Initialize the console
CON_InitEx(vmode, x, y, w, h);
VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK);
u64 pune=0;
__io_wiisd.startup();
while(1)
{
fatMountSimple("sd", &__io_wiisd);
fatUnmount("sd");
void* blablabla = malloc(256);
if(!blablabla)break;
free(blablabla);
cout << ".";
pune++;
}
__io_wiisd.shutdown();
cout << endl << "there is no memory left after " << pune << " sd card inits";
WPAD_Init();
Pause();
STM_RebootSystem();
}