Ram fragmentation?

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

Moderators: cheriff, TyRaNiD

Post Reply
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Ram fragmentation?

Post by willow :--) »

Hi, I'm in a situation very similar to that one: http://forums.ps2dev.org/viewtopic.php? ... gmentation

I am loading/freeing lots of objects of various sizes (from a few dozen bytes to several MB), quite a lot.
After a while, the PSP crashes, apparently when trying to load a huge image (I need to calculate exactly, but the texture probably takes more than 1MB in Ram).

The most obvious culprit is a memory leak somewhere in my code, but is it theoretically possible that, with loading/freeing lots of various objects, I reached a state where my RAM is fragmented and unable to allocate space for a huge block of data ?
User avatar
Coldbird
Posts: 97
Joined: Thu Feb 08, 2007 7:22 am

Post by Coldbird »

Doesnt have to be a leak... maybe you just load too much shit at once...
Keep in mind that depending on how many modules and stuff is loaded you can easily max out the 24MB of useable RAM...
Been gone for some time. Now I'm back. Someone mind getting me up-2-date?
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

Coldbird wrote:Doesnt have to be a leak... maybe you just load too much shit at once...
Keep in mind that depending on how many modules and stuff is loaded you can easily max out the 24MB of useable RAM...
No, the game works fine for a while, it fails at a state where the quantity of Ram needed is supposed to be "stabilized"
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well then, the obvious thing to do here is to put an extra check at the allocation function(s) and goto a special debugger routine when allocation fails just to see what's going on.
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

J.F. wrote:Well then, the obvious thing to do here is to put an extra check at the allocation function(s) and goto a special debugger routine when allocation fails just to see what's going on.
Yes. I was thinking of using one of the tricks I saw here numerous time (calling malloc with a growing number of bytes to determine the maximum size block).
I just wanted to make sure that "Ram fragmentation" is something that actually happens, or if it's just something I made up. (I don't know how the malloc algorithms work precisely)
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Yes, RAM will fragment. But it shouldn't cause a crash unless you're ignoring malloc() errors or something similar.
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

jimparis wrote:Yes, RAM will fragment. But it shouldn't cause a crash unless you're ignoring malloc() errors or something similar.
true. Unfortunately a lib is doing the mallocs (and ignoring the errors) for me :)
Post Reply