Homebrew How to use extra memory in had 2.5?

smealum

growing up sucks.
Member
Joined
May 1, 2006
Messages
635
Trophies
2
Age
31
Location
SF
Website
www.smealum.net
XP
2,515
Country
United States
so on n3ds by default you're already getting a ~90MB regular heap (don't remember the exact value, but it's 124MB - code/data - linear heap - 1MB iirc).
the additional 64MB (and 12MB on o3ds) is there but has to be implemented in ctrulib, and that hasn't been done yet due to lack of time.

if you're interested in using that additional memory before it's properly implemented in ctrulib i can give you a quick rundown.
 

elhobbs

Well-Known Member
OP
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,032
Country
United States
so on n3ds by default you're already getting a ~90MB regular heap (don't remember the exact value, but it's 124MB - code/data - linear heap - 1MB iirc).
the additional 64MB (and 12MB on o3ds) is there but has to be implemented in ctrulib, and that hasn't been done yet due to lack of time.

if you're interested in using that additional memory before it's properly implemented in ctrulib i can give you a quick rundown.
A run down would be appreciated. I must be doing something wrong as I am only seeing 32 and 24 on my n3ds. I was thinking it might be as simple as adjusting the sizes with a custom __system_allocateHeaps but that is just a guess.
 

smealum

growing up sucks.
Member
Joined
May 1, 2006
Messages
635
Trophies
2
Age
31
Location
SF
Website
www.smealum.net
XP
2,515
Country
United States
A run down would be appreciated. I must be doing something wrong as I am only seeing 32 and 24 on my n3ds. I was thinking it might be as simple as adjusting the sizes with a custom __system_allocateHeaps but that is just a guess.
are you sure you updated your payload to 2.5 ? if you're running 2.5 you should automatically get a 90MB heap.
 

elhobbs

Well-Known Member
OP
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,032
Country
United States
are you sure you updated your payload to 2.5 ? if you're running 2.5 you should automatically get a 90MB heap.
I updated ninjhax but was launching themehax. Me being a dumbass. Does the additional memory increase the linear address range or just the heap?
 

smealum

growing up sucks.
Member
Joined
May 1, 2006
Messages
635
Trophies
2
Age
31
Location
SF
Website
www.smealum.net
XP
2,515
Country
United States
I updated ninjhax but was launching themehax. Me being a dumbass. Does the additional memory increase the linear address range or just the heap?
what 2.5 does is set __heap_size to the max it can be given the default linear heap size. by default, this will be used for the regular heap : https://github.com/smealum/ctrulib/blob/master/libctru/source/system/allocateHeaps.c

given this, what you do know is that __linear_heap_size + __heap_size is the maximum amount of memory you should commit. as you can see __system_allocateHeaps is weak, so you can override it in your code to change the way memory is split between the two heaps. just make sure to adjust __libctru_exit as well (cf https://github.com/smealum/ctrulib/blob/master/libctru/source/system/ctru_exit.c )
 

elhobbs

Well-Known Member
OP
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,032
Country
United States
what 2.5 does is set __heap_size to the max it can be given the default linear heap size. by default, this will be used for the regular heap : https://github.com/smealum/ctrulib/blob/master/libctru/source/system/allocateHeaps.c

given this, what you do know is that __linear_heap_size + __heap_size is the maximum amount of memory you should commit. as you can see __system_allocateHeaps is weak, so you can override it in your code to change the way memory is split between the two heaps. just make sure to adjust __libctru_exit as well (cf https://github.com/smealum/ctrulib/blob/master/libctru/source/system/ctru_exit.c )
thanks for this. Is there a limit to how much can be used for linear? Just curious - why two memory regions in the first place?
 

smealum

growing up sucks.
Member
Joined
May 1, 2006
Messages
635
Trophies
2
Age
31
Location
SF
Website
www.smealum.net
XP
2,515
Country
United States
thanks for this. Is there a limit to how much can be used for linear? Just curious - why two memory regions in the first place?
afaik you can make the linear buffer as large as you want. the only thing is that there are limitations on the linear buffer that aren't on the regular buffer. for one thing, since the linear buffer is, you know, linear, you'll have limitations on how big single blocks of it can be depending on how fragmented the physical space is. not much of a problem for apps in general, but much more for applets. secondly, there are limitations within the kernel on how linear memory can be used. for example, iirc you can't create shared memory blocks of linear data.

i'm sure there are other reasons but those are the ones that come to mind right now.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: https://youtube.com/shorts/WOppJ92RgGU?si=KE79L6A_3jESsGQM