LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Memory management (https://www.linuxquestions.org/questions/linux-hardware-18/memory-management-69078/)

Mojojo 06-30-2003 01:18 PM

Memory management
 
Does anyone know a good way to free up some of your memory in linux. Most of the time i'm using 90% of my physical memory and 0% swap space. I've disabled programs I dont need plus i added 256mb of ram the other day and it just ate it up.

david_ross 06-30-2003 01:33 PM

Try running "top" and pressing "M" to sort by memory usage. it sounds like you may be running a program with a memory leak if it ate up all the new 256.

LogicG8 07-07-2003 11:11 AM

How much of the memory used is cache?
I have a 1GB of RAM and Linux still uses 90%
even though only about 128MB is actual programs
the rest is cache. Linux will store as much as it
can in memory to speed things up. HD access
takes forever compared to memory. So no matter
how much memory you have Linux will try to use
almost all of it. It's a really nice system and it speeds
up things alot. OTOH it is a good policy to not
run anything you don't need. You can take a look
at ps aux to give you an idea about what programs
are running. Then you can remove anything you
don't use from your init scripts.

AluriaDavid 08-26-2003 10:27 AM

Memory Leak?
 
I think I may be having some sort of memory leak.
I'm running RH8 with all the current updates from up2date.
1gb in memory dual amd 2gig processors.
The system for the most part sits idol.
If I count all the memory allocated to programs I get somewhere in the 200-300 range. Yet I'm at 95% used.
Programs and Services:
Gnome, wget (daily backup from main server), apache, iptables, php with optimizer, mysql, pretty much everything from a full install.
Anyhow, is there a way to test for memory leaks or perform some sort of flush/refresh?

Thanks.

----------------------
I'm no expert, but i know not to type rm -rf /

fancypiper 08-26-2003 10:29 AM

# Memory and swap information
cat /proc/meminfo
free
An article: Tips for Optimizing Linux Memory

AluriaDavid 08-26-2003 11:22 AM

Alright, so I thnk this shows that cache is eating me up.
This is not a healthy process for because when memory is full it slows performance. Here are the two commands..
[root@vacant init.d]# cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 1055326208 1028231168 27095040 0 62836736 860737536
Swap: 2146787328 123543552 2023243776
MemTotal: 1030592 kB
MemFree: 26460 kB
MemShared: 0 kB
Buffers: 61364 kB
Cached: 803124 kB
SwapCached: 37440 kB
Active: 764212 kB
ActiveAnon: 66208 kB
ActiveCache: 698004 kB
Inact_dirty: 1612 kB
Inact_laundry: 147316 kB
Inact_clean: 17052 kB
Inact_target: 186036 kB
HighTotal: 130992 kB
HighFree: 7652 kB
LowTotal: 899600 kB
LowFree: 18808 kB
SwapTotal: 2096472 kB
SwapFree: 1975824 kB
[root@vacant init.d]# free
total used free shared buffers cached
Mem: 1030592 1007092 23500 0 61368 803140
-/+ buffers/cache: 142584 888008
Swap: 2096472 120648 1975824

fancypiper 08-26-2003 11:39 AM

Have you read the article I linked???

AluriaDavid 08-26-2003 11:55 AM

Yes, it is helpful understand the two commands you gave me. Obviously, what i see is that cache is growing so large that it leaves the system unstable to handle any new processes.

Is there a way to limit cache and buffer from eating all available system memory?

fancypiper 08-26-2003 01:03 PM

Are you having lots of disk activity?

From the article:
Quote:

When extra physical memory is not in use, the kernel attempts to put it to work as a disk buffer cache. The disk buffer stores recently accessed disk data in memory; if the same data is needed again it can be quickly retrieved from the cache, improving performance. The buffer grows and shrinks dynamically to use the memory available, although priority is given to using the memory for paging. Thus, all the memory you have is put to good use.
My box loafing:
Code:

fancy@uilleann $ cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  526135296 223584256 302551040        0 40853504 94973952
Swap: 518152192        0 518152192
MemTotal:      513804 kB
MemFree:        295460 kB
MemShared:          0 kB
Buffers:        39896 kB
Cached:          92748 kB
SwapCached:          0 kB
Active:        183732 kB
Inact_dirty:      8936 kB
Inact_clean:      3872 kB
Inact_target:    39308 kB
HighTotal:          0 kB
HighFree:            0 kB
LowTotal:      513804 kB
LowFree:        295460 kB
SwapTotal:      506008 kB
SwapFree:      506008 kB
Committed_AS:  182316 kB
fancy@uilleann $ free
            total      used      free    shared    buffers    cached
Mem:        513804    218752    295052          0      40176      92824

Working hard compiling stuff, surfing, playing music, etc.
Code:

fancy@uilleann $ cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  526135296 336281600 189853696        0 74522624 144273408
Swap: 518152192        0 518152192
MemTotal:      513804 kB
MemFree:        185404 kB
MemShared:          0 kB
Buffers:        72776 kB
Cached:        140892 kB
SwapCached:          0 kB
Active:        279236 kB
Inact_dirty:    13248 kB
Inact_clean:      2336 kB
Inact_target:    58964 kB
HighTotal:          0 kB
HighFree:            0 kB
LowTotal:      513804 kB
LowFree:        185404 kB
SwapTotal:      506008 kB
SwapFree:      506008 kB
Committed_AS:  205768 kB
fancy@uilleann $ free
            total      used      free    shared    buffers    cached
Mem:        513804    350700    163104          0      78460    155576
-/+ buffers/cache:    116664    397140
Swap:      506008          0    506008


AluriaDavid 08-26-2003 01:11 PM

That would be great, but instead of leaving 295MB free for immediate use. It only leaves 23MB free. This makes bring up Mozilla or using X in general slow in response. The system has even completely frozen on me a couple of times.

fancypiper 08-26-2003 01:21 PM

What did top (memory sorted hit shift m) show for your processes?
Code:

  2:20pm  up 27 min,  4 users,  load average: 1.68, 1.14, 0.55
88 processes: 81 sleeping, 5 running, 2 zombie, 0 stopped
CPU states: 43.0% user, 12.3% system,  0.0% nice, 44.6% idle
Mem:  513804K av,  372812K used,  140992K free,      0K shrd,  99480K buff
Swap:  506008K av,      0K used,  506008K free                  153668K cached

  PID USER    PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM  TIME COMMAND
 1704 fancy    15  0 30464  29M 16084 S    0.1  5.9  0:40 galeon-bin
 1709 fancy    15  0 30464  29M 16084 S    0.0  5.9  0:00 galeon-bin
 1710 fancy    15  0 30464  29M 16084 S    0.0  5.9  0:00 galeon-bin
 1711 fancy    15  0 30464  29M 16084 S    0.0  5.9  0:00 galeon-bin
 1713 fancy    15  0 30464  29M 16084 S    0.0  5.9  0:00 galeon-bin
10171 fancy    15  0 30464  29M 16084 S    0.0  5.9  0:00 galeon-bin
 1615 root      15  0 70664  20M  3596 S    0.7  4.0  0:29 X
 1651 fancy    15  0 15256  14M  8948 S    0.0  2.9  0:11 evolution-mail
 1685 fancy    15  0 15256  14M  8948 S    0.0  2.9  0:00 evolution-mail
 1686 fancy    15  0 15256  14M  8948 S    0.0  2.9  0:00 evolution-mail
 1687 fancy    21  0 15256  14M  8948 S    0.0  2.9  0:01 evolution-mail
 1688 fancy    16  0 15256  14M  8948 S    0.0  2.9  0:00 evolution-mail
 1689 fancy    15  0 15256  14M  8948 S    0.0  2.9  0:00 evolution-mail
 1698 fancy    15  0 15256  14M  8948 S    0.0  2.9  0:00 evolution-mail
 1703 fancy    15  0 15256  14M  8948 S    0.0  2.9  0:00 evolution-mail
 1720 fancy    15  0 13868  13M  8708 R    0.0  2.6  0:02 realplay_
 1723 fancy    15  0 13868  13M  8708 S    0.0  2.6  0:00 realplay_
 1724 fancy    15  0 13868  13M  8708 S    0.0  2.6  0:00 realplay_
 1725 fancy    15  0 13868  13M  8708 S    0.0  2.6  0:00 realplay_
 1728 fancy    15  0 13868  13M  8708 R    0.0  2.6  0:00 realplay_
 1636 fancy    15  0  9948 9948  6652 S    0.0  1.9  0:14 evolution
 1987 root      15  0  9504 9504  1904 R    6.3  1.8  0:20 python2.2
 1622 fancy    15  0  7296 7296  5096 S    0.3  1.4  0:01 gkrellm
 1664 fancy    15  0  6356 6352  5200 S    0.0  1.2  0:00 evolution-calen
 1660 fancy    15  0  6312 6308  5188 S    0.0  1.2  0:00 evolution-addre
 1643 fancy    15  0  6116 6112  4952 S    0.0  1.1  0:00 wombat
 1924 fancy    15  0  6084 6080  4584 S    0.0  1.1  0:00 gedit
 1669 fancy    15  0  5504 5500  4484 S    0.0  1.0  0:00 evolution-alarm
 1671 fancy    15  0  5324 5324  4356 S    0.0  1.0  0:00 evolution-execu
 1894 fancy    15  0  5092 5092  3348 S    0.3  0.9  0:03 gnome-terminal
 1721 fancy    16  0  5076 5076  5036 S    0.0  0.9  0:00 realplay_
 1722 fancy    16  0  5076 5076  5036 S    0.0  0.9  0:00 realplay_
 1840 fancy    15  0  4188 4188  3348 R    2.3  0.8  0:01 gnome-terminal
 1267 xfs      15  0  4104 4104  988 S    0.0  0.7  0:00 xfs
 1647 fancy    15  0  3924 3924  3056 S    0.0  0.7  0:00 bonobo-moniker-
 1621 fancy    15  0  2664 2664  2044 S    0.0  0.5  0:01 fluxbox
 1639 fancy    15  0  2524 2524  1324 S    0.0  0.4  0:00 oafd
 1653 fancy    15  0  2036 2036  1292 S    0.0  0.3  0:00 gconfd-1
 1178 root      15  0  1816 1816  1300 S    0.0  0.3  0:00 sendmail
 1623 fancy    15  0  1812 1812  1384 S    0.0  0.3  0:00 xscreensaver
 1601 fancy    15  0  1624 1624  1272 S    0.0  0.3  0:00 fetchmail


AluriaDavid 08-31-2003 10:29 AM

Top memory was fine, it was simply cache/buffer had taken up all the space. It matters not that computer since I was 'let go' from there the other day.
But I know on other systems I've worked with having the same trouble.
What I think I see perhaps is with the Hard Drive cached, when I run certain programs that demands a lot of memory at once. It either has to swap my active program in Swap-space, or it has to determine what is in its cache to keep and what to discard for space.
I wonder if in theory you don't want to have unused memory. but in practice to much cache/buffer can actually cause system lag.


All times are GMT -5. The time now is 04:35 AM.