Last active
January 11, 2020 21:27
-
-
Save uyjulian/df5e5c44a8304ba17536609f0358ac0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
#include <switch.h> | |
#include <malloc.h> | |
int main(int argc, char **argv) | |
{ | |
consoleInit(NULL); | |
size_t mem_available; | |
size_t mem_used; | |
struct mallinfo mi = mallinfo(); | |
svcGetInfo(&mem_available, InfoType_TotalMemorySize, CUR_PROCESS_HANDLE, 0); | |
svcGetInfo(&mem_used, InfoType_UsedMemorySize, CUR_PROCESS_HANDLE, 0); | |
size_t heap_available = mi.uordblks; | |
size_t heap_used = mi.fordblks; | |
bool has_heap_override = envHasHeapOverride(); | |
printf("Memory available: 0x%lx\n", mem_available); | |
printf("Memory used: 0x%lx\n", mem_used); | |
printf("Heap available: 0x%lx\n", heap_available); | |
printf("Heap free: 0x%lx\n", heap_used); | |
printf("Has heap override: 0x%x\n", has_heap_override); | |
while (appletMainLoop()) | |
{ | |
hidScanInput(); | |
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); | |
if (kDown & KEY_PLUS) | |
{ | |
break; | |
} | |
consoleUpdate(NULL); | |
} | |
consoleExit(NULL); | |
return 0; | |
} | |
/* | |
For each run, be sure you exit to qlaunch. | |
If you exit the testing program to hbmenu and open it right back up, you will get the same results. | |
Test results: | |
as app override: | |
Memory available: 0xc7500000 | |
Memory used: 0xc7140000 | |
Heap available: 0x190134f0 | |
Heap free: 0x19010188 | |
Has heap override: 0x1 | |
as app override (2): | |
Memory available: 0xc7500000 | |
Memory used: 0xc7140000 | |
Heap available: 0x50e134f0 | |
Heap free: 0x50e10188 | |
Has heap override: 0x1 | |
as app override (3): | |
Memory available: 0xc7500000 | |
Memory used: 0xc7140000 | |
Heap available: 0x2d6134f0 | |
Heap free: 0x2d610188 | |
Has heap override: 0x1 | |
as applet override: | |
Memory available: 0x181dd000 | |
Memory used: 0xf940000 | |
Heap available: 0x2f4134f0 | |
Heap free: 0x2f410188 | |
Has heap override: 0x1 | |
as applet override (2): | |
Memory available: 0x181dd000 | |
Memory used: 0xf940000 | |
Heap available: 0x64c134f0 | |
Heap free: 0x64c10188 | |
Has heap override: 0x1 | |
as applet override (3): | |
Memory available: 0x181dd000 | |
Memory used: 0xf940000 | |
Heap available: 0x484134f0 | |
Heap free: 0x48410188 | |
Has heap override: 0x1 | |
as hbmenu.nsp forwarder: | |
Memory available: 0xc7500000 | |
Memory used: 0xc7163000 | |
Heap available: 0x2a215f00 | |
Heap free: 0x2a212208 | |
Has heap override: 0x1 | |
as hbmenu.nsp forwarder (2): | |
Memory available: 0xc7500000 | |
Memory used: 0xc7163000 | |
Heap available: 0x61e15f00 | |
Heap free: 0x61e12208 | |
Has heap override: 0x1 | |
as hbmenu.nsp forwarder (3): | |
Memory available: 0xc7500000 | |
Memory used: 0xc7163000 | |
Heap available: 0x4f815f00 | |
Heap free: 0x4f812208 | |
Has heap override: 0x1 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment