Slim extra memory Question

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Slim extra memory Question

Post by Art »

Hi,
If you set the extra memory flag in the make file to use the slim RAM,
will the program fail to load on a PSP1000 straight away even if the extra RAM was not used?

If not, when will the program fail to load on a PSP1000... when a 40Mb array is defined, or when you go to use it?
If not actually, then potentially.
Salvy
Posts: 5
Joined: Tue Jun 30, 2009 6:26 am

Post by Salvy »

You could take a look at Daedalusx64 source.
J.F did a great job enabling Slim extra RAM and such without breaking any phat functionality.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

It will work fine on both. The only thing that changes is the amount of memory you can allocate dynamically. Mallocs will simple fail after there is no more free memory.

Since malloc uses the heap defined at compile time, you should use a negative value such as PSP_HEAP_SIZE_KB(-1024) instead of a hardcoded value. So you'll have 23MiB on Phat and 55MiB on the Slim with 1MiB for stacks etc in either case.

Or you could not use that heap at all and create one to use at runtime with the sce* functions after detecting Phat or Slim. Since extra memory isn't hardful, just use the PSP_HEAP_SIZE_KB method and allocate extra in your code depending on the model.

If you declare the 40MiB array at compile time then it will obviously fail on the Phat since 40MiB is statically allocated. The program will not work at all. If you have a pointer to the array, then only the 40MiB malloc will fail but you can handle the error.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Thanks for that.. helpful since I still don't plan on getting one.
If not actually, then potentially.
Post Reply