libctru - How to know when app runs out of memory?

Post Reply
Gearmo3DS
Posts: 3
Joined: Sat Nov 25, 2023 2:37 pm

libctru - How to know when app runs out of memory?

Post by Gearmo3DS » Sat Nov 25, 2023 3:35 pm

Given this snippet:

Code: Select all

    u32 totalMemory, freeMemory;
    freeMemory = osGetMemRegionFree(MEMREGION_APPLICATION);
    totalMemory = osGetMemRegionSize(MEMREGION_APPLICATION);
I noticed that freeMemory always returns zero.

Should I only use `linearSpaceFree();` instead?

WinterMute
Site Admin
Posts: 1859
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: libctru - How to know when app runs out of memory?

Post by WinterMute » Sat Nov 25, 2023 6:05 pm

You know when an app runs out of memory when you can't allocate any more. It isn't possible to know whether or not an allocation will succeed before attempting to allocate nor is it possible to determine how much memory is free in the system.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Gearmo3DS
Posts: 3
Joined: Sat Nov 25, 2023 2:37 pm

Re: libctru - How to know when app runs out of memory?

Post by Gearmo3DS » Sat Nov 25, 2023 11:29 pm

Thank you WinterMute

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests