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 

free'ing memory

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



Joined: 20 Jun 2005
Posts: 82

PostPosted: Sat Sep 10, 2005 5:34 am    Post subject: Reply with quote

ok yea..that was a bad example.. well im not sure why what is happening to me is happening then.. i load up say maybe 40-50 pictures..different sized pictures..and free them all eventually.. and in the same program i load up a mp3 file, and play it.. it crashes..if i try a small mp3 file, it works fine..

now if i take the code that plays the mp3 file into a separate program..the big mp3 file will load and play fine.. so that leaves me to beleive the images i load and free..are not clearing memory completly..or is there some way i can .. like defrag the memory..heh.. so the mp3 has room to be loaded into?
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Sat Sep 10, 2005 5:43 am    Post subject: Reply with quote

I don't know how to defrag the memory, but this is a PSPSDK related question, I've splitted your posting to this forum.
Back to top
View user's profile Send private message
jpadams



Joined: 02 Jul 2005
Posts: 23
Location: Los Angeles

PostPosted: Sat Sep 10, 2005 6:31 am    Post subject: Reply with quote

are your malloc's aligned ?
thats the easiest way to cause a crash
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Mon Sep 12, 2005 12:55 pm    Post subject: Reply with quote

Call malloc/free as few times as possible. If you are loading up a bunch of bitmaps, load up enough memory to hold your framebuffer ( 480x272x4bytes ) and write to that buffer whenever you load up an image. When you load the image, call malloc to grab enough memory to hold the file and then free it imediately afterwards, or better yet make a dedicated file-read buffer that is only created once.

This will cut down on the amount of memory fragmentation. Remember, you've only got about 20MB of real RAM to work with once your executable is loaded up. This is NOT a lot!
Back to top
View user's profile Send private message AIM Address MSN Messenger
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Mon Sep 12, 2005 10:37 pm    Post subject: Reply with quote

It's a lot more than PS1!! And we fitted a lot in that. As long as we have the reasonable expectation that if we free everything we malloc there is no fragmentation that is OK. And as long as the C++ object allocations aren't mental then there is some chance of reliable software.

Jim
PS. It's a lot more ram than N64 and DC.
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
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