[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory size and allocation



Dennis Payne wrote:

>>This sounds strange to me... i'd prefer to fill the ram till there is space
>>available and remove unused data when i run out of space, this should
>>improve the game performance avoiding all the load/unload work...
>>Is this policy SO bad?
>>
> 
> Yes it is.  Before you run out of memory you will begin swapping (assuming
> there is virutal memory) in which case it is no worse than dumping the
> data and reloading if needed.  Not only that but the kernel will
> decrease the file cache space which may make new data slower to
> read.  This may also affect network packets where they start being
> dropped to conserve space.  And with memory overcommit you are totally
> screwed.  You need to keep track of what you need and what you don't.
> 

Even worse, the kernel will always keep a not so small disk cache in 
memory and start paging even before you hit any hard limit. It's not as 
bad as it sounds, though, because this mostly affects memory areas which 
were not accessed lately and even results in some overall speedups. This 
  behaviour is not limited to Linux. Other OSes (esp. Windows) have very 
similar policies for memory management.

But what this actually means is that caching data to a file might not be 
a good idea. Instead, cache data in memory only (although this always 
includes the risk of getting the data paged out to disk) or free it 
entirely and reload it from disk when needed (given the fact you got 
fast loading code).

Some current high-end engines (like the one in Return to Castle 
Wolfenstein) seem to perform caching in-memory only. When reading the 
system requirements on the box you will see something like "about 300MB 
of swap space", which suggests that they push their memory caching 
policy very far.

Bye,
Gregor

-- 
*****************************************************
* Gregor Mueckl                 GregorMueckl@gmx.de *
*                                                   *
* The ChallengeOS project:                          *
* http://challengeos.sourceforge.net                *
*****************************************************
* Math problems?                                    *
* Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].       *
*****************************************************