Memory (Ram) Fragmentation


Pleng

Very Active Member
Joined
Dec 28, 2006
Messages
3,030
On Windows XP (not sure if it occurs on Win7 or not) there was an issue or RAM becoming fragmented, much in the same way Hard Disks would be, where programs running would occupy adjacent blocks of RAM and basically the more programs, especially small ones I presume, you had running, the smaller the highest amount of contiguous memory was available for starting apps. So even if you had several hundered megabytes free, the smallest contiguous block available might only be 2 or 3 meg and therefore apps could give 'out of memory' errors when trying to start.

Does this also happen on Linux based systems and, more specifically the Pandora? This could be an issue with such an always on system.

(edit: I'm getting seriously p*ssed off with the forum software decapitalizing my words! That's three posts in 3 days that were supposed to have strings of capitals in them, which have all been converted to lower case!)
 

Letalis Sonus

Advanced Member
Joined
Mar 5, 2009
Messages
1,490
Check out this LWN article.

In short: It is generally less of an issue on Linux but in a few situations it may still have a negative influence on performance. Starting with kernel 2.6.35 there are some defragmentation functions which are automatically being activated if the allocation of a higher-order page fails. There's a device node to trigger it manually as well.
 

Tor

Member
Joined
Oct 3, 2008
Messages
709
I will argue that "RAM fragmentation" is as close to a non-issue as anything could be. Normally the only time i would matter at all is when you need physically contiguous memory for non-CPU activities like DMA (and only if your DMA controller can't remap memory itself, and many can). For your user-level application it's all the same to you if the physical memory is fragmented or not, the only issue would probably be some theoretical pressure on the TLBs and even that may not be an issue. Depending on the CPU there could also be an issue with the efficiency of its cache memory depending on how the cache is implemented. But RAM fragmentation is just about the last thing I would bother worrying about.
 

WizardStan

Mega GP Mania
Joined
May 24, 2008
Messages
16,733
My BeagleBoard had some issues with memory fragmentation. The wifi stick I got for it allocates some contiguous memory when it connects to a network which, unfortunately, it has to do once or twice a week. After about 2 weeks of this, it would lose connection and try to reconnect and fail at the point where it tries to get memory. Because the driver was poorly written, this causes it to crash and do weird things that ultimately brought down the entire USB host, requiring a full restart. It wasn't out of memory, it just didn't have the full amount of contiguous memory that it was trying to get. If it requested normal memory it would have no problem, but for some reason it really really needed it to be physical contiguous memory. I'm assuming poorly written driver. If not for this one driver, I'd have never noticed there was a "problem". Assuming there's no similar drivers in the Pandora (or it does better with its memory management then my BeagleBoard's kernel) then you'll never notice whether memory is contiguous or fragmented.
Anywho, I added a few megs of swap space, current uptime is 71 days, so problem solved. If it really really becomes an issue, do something similar with the Pandora for a quick and dirty fix.
 
Top