Page 1 of 1

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

Posted: Sat Nov 25, 2023 3:35 pm
by Gearmo3DS
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?

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

Posted: Sat Nov 25, 2023 6:05 pm
by WinterMute
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.

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

Posted: Sat Nov 25, 2023 11:29 pm
by Gearmo3DS
Thank you WinterMute