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 

newlib malloc updated to prevent memory fragment

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



Joined: 23 Nov 2006
Posts: 22

PostPosted: Fri Jul 10, 2009 1:51 pm    Post subject: newlib malloc updated to prevent memory fragment Reply with quote

Hi, folks. Recently I found out if we update newlib-psp malloc version to the latest malloc-2.8.4, the memory fragment after a mass of allocating-and-freeing memory operations will significantly reduce.

I ported it to newlib-psp-1.17.0. If anyone who suffered from the memory fragment should test this patch.

Note:
1. Already use a spinlock to guarantee thread-safety, no need to define __malloc_lock.
2. Can be slightly slower than original. Or you can define INSECURE to 1 to skip the sanity check for speed.

Install:

wget ftp://sources.redhat.com/pub/newlib/newlib-1.17.0.tar.gz
tar -zxvf newlib-1.17.0.tar.gz
cd newlib-1.17.0
patch -p1 < ../newlib-1.17.0-psp-malloc-2.8.4.patch
./configure --prefix=$PSPDEV --target=psp && make && make install

patch download: http://ifile.it/kt2pqi9
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Sat Jul 11, 2009 1:04 pm    Post subject: Reply with quote

link is down
Back to top
View user's profile Send private message MSN Messenger
Wally



Joined: 26 Sep 2005
Posts: 672

PostPosted: Sat Jul 11, 2009 9:24 pm    Post subject: Reply with quote

coolkehon wrote:
link is down


No its not, quite a complicated site.
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Sat Jul 11, 2009 10:01 pm    Post subject: Reply with quote

Wally wrote:
coolkehon wrote:
link is down


No its not, quite a complicated site.


what?
what are you trying to do?
Back to top
View user's profile Send private message MSN Messenger
Wally



Joined: 26 Sep 2005
Posts: 672

PostPosted: Sun Jul 12, 2009 6:59 am    Post subject: Reply with quote

I've rehosted the script at

www.spiffup.org/newlib-1.17.0-psp-malloc-2.8.4.rar

Enjoy!
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Sun Jul 12, 2009 12:25 pm    Post subject: Reply with quote

thanks
Back to top
View user's profile Send private message MSN Messenger
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Tue Jul 14, 2009 3:11 am    Post subject: Reply with quote

Has the toolchain been updated to include this new patch, should i update my svn view and rebuild the SDK? I guess what I mean is.... has it been checked in yet as this would prove to be very handy update for my development.
Back to top
View user's profile Send private message Visit poster's website
hrimfaxi



Joined: 23 Nov 2006
Posts: 22

PostPosted: Wed Jul 15, 2009 2:44 pm    Post subject: Reply with quote

SamuraiX wrote:
Has the toolchain been updated to include this new patch, should i update my svn view and rebuild the SDK? I guess what I mean is.... has it been checked in yet as this would prove to be very handy update for my development.


No, you needn't.
Back to top
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Wed Aug 19, 2009 5:40 am    Post subject: Reply with quote

I've gotten around to compiling this version of newlib using the following instructions above.

The Good News:
I went from 6246484 Bytes of fragmented memory to 4759612 Bytes. Thats about 23.8% Savings!

The Bad News:
I still have quite a bit of fragmented memory...


If anyone has any suggestions on how to lower fragmented memory or suggest another type of malloc where fragmented memory is even lower then please let me know.
Back to top
View user's profile Send private message Visit poster's website
fungos



Joined: 31 Oct 2007
Posts: 41
Location: cwb br

PostPosted: Thu Aug 20, 2009 11:11 am    Post subject: Reply with quote

@SamuraiX try to use pools, it will reduce a lot your fragmentation if you have a lot of tiny allocations (ie. strings and structs/classes).
Another thing is to reduce your allocations, we are used to alloc much more than we really need.
My games have _almost_ none alloc/new (resource loading ONLY) and I have almost no fragmentation as all my resources are loaded at beginning of a game state and automatically unloaded when switching to another state. These basic things saved me from so much trouble.
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