how do you determine how much ram is left?

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

Moderators: cheriff, TyRaNiD

Post Reply
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

how do you determine how much ram is left?

Post by Kojima »

I think there's a memory leak in the new build of raptor animation system, cos although it works fine and the zombie i'm looking at animates, if i leave it running for about 30 seconds it just hangs.
And there's very left logic in the demo, just displays a mesh.

So, any function like sceGetRam() sceGetRamTotal() etc?

I did a search of the includes but couldn't find nothing obvious.

Also, anything to determine how much vid mem there is left?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Re: how do you determine how much ram is left?

Post by Raphael »

Kojima wrote:I think there's a memory leak in the new build of raptor animation system, cos although it works fine and the zombie i'm looking at animates, if i leave it running for about 30 seconds it just hangs.
And there's very left logic in the demo, just displays a mesh.

So, any function like sceGetRam() sceGetRamTotal() etc?

I did a search of the includes but couldn't find nothing obvious.

Also, anything to determine how much vid mem there is left?
To find memory leaks, I recommend using a debug memory manager, like the one from Paul Nettle of fluidstudios.com. It's a C++ version though, so if you have C code, you could try my ANSI-C version of it from here: http://www.fx-world.org/wordpress/?p=15

It's pretty easy to use, just #include "mmgr.h" in all files which do memory allocation before your project includes (but after all <...> includes) and then call the memreport dump function once at the end of your program (not needed in the C++ version, as this is handled through the static deallocation of a class).

You'll get a perfect listing of all allocations which weren't freed correctly and where in your code they happend (if any).

Regarding the VRAM stuff, there's not much to do unless you handle all your VRAM usage through an external mem manager (like my valloc library which provides you with a vmemavail() function that returns the free VRAM). This however only works if you allocate all your VRAM with the provided valloc function.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

ok thanks i'll give that a go. I still would like to know how much memory my app is using though, and how much is left, is it possible on a psp?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Kojima wrote:ok thanks i'll give that a go. I still would like to know how much memory my app is using though, and how much is left, is it possible on a psp?
There was a thread about that some time ago with a solution to that, you should be able to find it if you use the search. It was something about a value in the heap header struct.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

That looks like an awesome tool Raphael, thanks for the link. I tried to compile mmgr.cpp (with a makefile used for a c++ app) but it fails around new_handler. The docs say to replace std::set_new_handler with set_new_handler, but that doesn't help because new_handler is still not found. Where is new_handler usually located on the PSP, or is there a workaround? (I'm using Nettle's original code)

@Kojima, this has been asked a few times, I coded a crude one myself, and there is another one here: http://forums.ps2dev.org/viewtopic.php?p=33937
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Try to #include <new.h>, I'm not sure if that helps though, haven't tried C++ on PSP yet.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Thanks, for anyone else using that version, change the line:
#include <new>
to
#include <new.h>
Then comment out #include "stdafx" and add -fexceptions to the makefile.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Got it all working, was just a couple of rouge matrices being created every frame.

Thanks.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

That example appears to be broken (I searched for it).
http://forums.ps2dev.org/viewtopic.php? ... ccce7aa9cd
I gave it a shot to be sure, but it doesn't compile for me.
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Seems fine for me in both C and C++. Maybe you should try the other method in my link above. His is a larger function, but may work better for you, Art.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Yep, I got it now :)
So if there is more RAM consumed than my program expects, it must
have been launched from a shell, which is what I wanted to determine
at run time.
Cheers, Art.
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

Art wrote:Yep, I got it now :)
So if there is more RAM consumed than my program expects, it must
have been launched from a shell, which is what I wanted to determine
at run time.
Cheers, Art.
Or it could be running on a firmware version you didn't expect.

Or perhaps from one of these custom firmwares.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Or it could be running on a firmware version you didn't expect.
No, I'm already checking for that... unless the user replaced their index.dat file.

I'm allowing a small amount of memory for custom firmwares..
I imagine none of them would consume much of any resource.
Post Reply