| View previous topic :: View next topic |
| Author |
Message |
hrimfaxi
Joined: 23 Nov 2006 Posts: 22
|
Posted: Fri Jul 10, 2009 1:51 pm Post subject: newlib malloc updated to prevent memory fragment |
|
|
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 |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Sat Jul 11, 2009 1:04 pm Post subject: |
|
|
| link is down |
|
| Back to top |
|
 |
Wally

Joined: 26 Sep 2005 Posts: 672
|
Posted: Sat Jul 11, 2009 9:24 pm Post subject: |
|
|
| coolkehon wrote: | | link is down |
No its not, quite a complicated site. |
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Sat Jul 11, 2009 10:01 pm Post subject: |
|
|
| Wally wrote: | | coolkehon wrote: | | link is down |
No its not, quite a complicated site. |
what?
what are you trying to do? |
|
| Back to top |
|
 |
Wally

Joined: 26 Sep 2005 Posts: 672
|
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Sun Jul 12, 2009 12:25 pm Post subject: |
|
|
| thanks |
|
| Back to top |
|
 |
SamuraiX
Joined: 31 Jan 2006 Posts: 76 Location: USA
|
Posted: Tue Jul 14, 2009 3:11 am Post subject: |
|
|
| 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 |
|
 |
hrimfaxi
Joined: 23 Nov 2006 Posts: 22
|
Posted: Wed Jul 15, 2009 2:44 pm Post subject: |
|
|
| 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 |
|
 |
SamuraiX
Joined: 31 Jan 2006 Posts: 76 Location: USA
|
Posted: Wed Aug 19, 2009 5:40 am Post subject: |
|
|
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 |
|
 |
fungos
Joined: 31 Oct 2007 Posts: 41 Location: cwb br
|
Posted: Thu Aug 20, 2009 11:11 am Post subject: |
|
|
@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 |
|
 |
|