Re: Memory bug in 1.3.84

Chris Hoover (upstate1@cris.com)
Sun, 07 Apr 1996 20:38:26 -0400


At 06:52 PM 4/7/96 -0400, you wrote:
>> There appears to be a memory bug in 1.3.84. The kernel does not appear to
>> be releasing all of the allocated memory that a program takes.
>
>> started linux
>> 4960 k used
>> 18076 k free
>
>> started X (nohup startx &)
>> 11388 k used
>> 11648 k free
>
>> exited X
>> 13114 k used
>> 9892 k free
>
>> The memory values were from top. Tested on a Pentium 100 w/ 24 megs
>> of ram and 17 megs swap. (Never used swap).
>>
>> It appears that when the kernel returns to a previous state i.e. closing
>> down a program. That the reported available memory should be reported the
>> same as the original reporting. However, this is not happening. The most
>> blatent example being the exiting of X-Windows. The kernel with nothing but
>> top definately does not use 13+ megs.
>
>This is what should happen. MS-DOS would free memory after a program
>exits, but Linux does not. What if you should run the same program
>again? It makes no sense to load the program from disk when it was
>just in memory being run.
>
>Ever notice that there is no smartdrv.exe for Linux? As the system
>runs, free memory is used for disk cache. After the system has
>been running for a long time, there should be very little free
>memory - free memory is a waste.
>
>No need to worry. If a program needs memory, the size of the disk
>cache can be reduced. Also note that programs run out of the disk
>cache instead of being copied from the disk cache to free memory
>as DOS would do. If needed, program code can be discarded because
>it can be reloaded from the executable later. If memory is really
>short, Linux will swap data and stack to disk. As a last resort
>Linux kills programs (you have to do something dumb, like run
>X in 8 MB while you compile a kernel and run emacs).
>
>Well, it is fast right?
>
>You might complain that 'free' should be called 'waste'.
>There really can't be a 'cache' catagory because cache
>is used to run programs. That leads to "What is cache?".
>
>

However, if I exit X and immediately reload it, using the same setup files,
the free memory will decrease. I have had the used memory become just about
all of the avaliable memory doing this. If the memory is stored in cache
after exiting for a possible reentry into a program, then when you reenter
that program immedialty upon exiting it, the free memory should not decrease
beyond the point that it was when you had the program running the first time.

Also, when you exit a program, how long should the memory be maintained in
the "cache"??? If you exit a program and and leave the system (say over
night) the cache does not decrease. Yet it seems logical that if a user has
not reused the program in say 30 min or 1 hr. that the memory should be
reassigned to the free memory catagory and the cache forgotten.

Therefore, this leads me to believe that there is still a bug in the memory
management area of linux. If I exit the program, free memory should be
increased on the display to near the original amount, even if it is held in
cache (since this is still "unallocated" memory at the momment i.e. it is
not being used by a program). All that the cache needs to carry is just a
hook to where the old memory is at. Then, if the user reenters the program,
the partial load is still their via the tag. However, if the user runs
other programs this memory appear to be available for use (the way it should
be). The user should never see the free memory go to 0 or any where near
that if there is unused memory in the cache. However, this appears to be
precisley what linux will do. While there may be megs of unused memory in
the cache, linux will let the free memory reading of the system to drop down
to 500k or lower. This gives an incorrect reading and can cause the use of
the disk cache. This should not be since there is still free cache memory
and the disk cache is so much slower than having linux start eating into the
cache memory.

BTW, to most people, the term "cache" is interpreted to mean the memory that
is used as a "buffer" to hold the most demanded pages of memory (i.e. disk
cache, L2 cache, etc). However, linux appears to be redefining it with a
definition that is contrary to the usual one.

Chris