forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how do you determine how much ram is left?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Fri Aug 04, 2006 1:32 am    Post subject: how do you determine how much ram is left? Reply with quote

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?
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Fri Aug 04, 2006 2:14 am    Post subject: Re: how do you determine how much ram is left? Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Fri Aug 04, 2006 2:59 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Fri Aug 04, 2006 3:05 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Fri Aug 04, 2006 3:06 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Fri Aug 04, 2006 4:17 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Fri Aug 04, 2006 6:01 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Fri Aug 04, 2006 6:14 am    Post subject: Reply with quote

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

Thanks.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Sat Aug 05, 2006 1:05 am    Post subject: Reply with quote

That example appears to be broken (I searched for it).
http://forums.ps2dev.org/viewtopic.php?t=4567&highlight=ram+left&sid=e4622f63f425752b3af7f0ccce7aa9cd
I gave it a shot to be sure, but it doesn't compile for me.
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Sat Aug 05, 2006 1:58 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Sat Aug 05, 2006 2:25 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Sat Aug 05, 2006 7:07 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Sat Aug 05, 2006 7:45 am    Post subject: Reply with quote

Quote:
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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group