How to use extra memory in had 2.5?

Discussion in '3DS - Homebrew Development and Emulators' started by elhobbs, Oct 31, 2015.

  1. elhobbs
    OP

    elhobbs GBAtemp Advanced Fan

    Member
    807
    296
    Jul 28, 2008
    United States
    does anyone know how to use the extra memory in hax 2.5?
     
  2. smealum

    smealum growing up sucks.

    Member
    635
    2,031
    May 1, 2006
    United States
    SF
    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.
     
    Noise964, Garcia98, Selim873 and 5 others like this.
  3. elhobbs
    OP

    elhobbs GBAtemp Advanced Fan

    Member
    807
    296
    Jul 28, 2008
    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.
     
  4. smealum

    smealum growing up sucks.

    Member
    635
    2,031
    May 1, 2006
    United States
    SF
    are you sure you updated your payload to 2.5 ? if you're running 2.5 you should automatically get a 90MB heap.
     
  5. elhobbs
    OP

    elhobbs GBAtemp Advanced Fan

    Member
    807
    296
    Jul 28, 2008
    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?
     
  6. smealum

    smealum growing up sucks.

    Member
    635
    2,031
    May 1, 2006
    United States
    SF
    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 )
     
  7. elhobbs
    OP

    elhobbs GBAtemp Advanced Fan

    Member
    807
    296
    Jul 28, 2008
    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?
     
  8. smealum

    smealum growing up sucks.

    Member
    635
    2,031
    May 1, 2006
    United States
    SF
    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.