LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-10-2004, 09:45 AM   #1
SocialEngineer
Member
 
Registered: May 2003
Distribution: Slackware
Posts: 236

Rep: Reputation: 31
Cleaning up what I am pretty sure is a memory leak..


Ok, I'm running Slackware 10 w/ kernel 2.6.7. After running for 1 day, 1h, and 9 minutes, my memory useage hits ~50% with BadWM and no windows open. It's done the same with Fluxbox and KDE (although Fluxbox took up more ram, and KDE took up CONSIDERABLY more ram). I have 256mb of ram.

I don't want to have to reboot to free up my memory - what's going on here? I did a ps -eo pid,user,%mem and checked memory usage, but it's all below 1% except for a couple root processes. I don't have enough processes to add up to 50%.

Any ideas?
 
Old 11-10-2004, 10:24 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
This is not likely to be a memory leak.

Look at the breakdown of the memory usage using something like
Code:
cat /proc/meminfo
What you have here is probably a large amount of memory being used for hardware caching; if you have any free pages in physical RAM then all block device (disk) reads will be automatically cached (to speed up future reads), causing your memory usage to increase.

This situation isn't a memory leak as such; the cache pages are the first to be reclaimed when an application needs more memory, so you aren't likely to run out of memory because of this.

More information, including how to configure this behaviour, here: http://kerneltrap.org/node/view/3000

If you do have a memory leak in any of your daemons, note that most (read: all well-behaved) daemons re-exec themselves, usually once every few hours, which reclaims their heap, including any memory that they have leaked and puts it back in the free store (i.e. this will free all memory leaks). To find the culpret, run
Code:
top
and sort by memory usage. Write it down (or take a screenshot). Wait a day or so, and compare the memory usage now. The process leaking memory will have grown considerably.
 
Old 11-10-2004, 11:15 AM   #3
SocialEngineer
Member
 
Registered: May 2003
Distribution: Slackware
Posts: 236

Original Poster
Rep: Reputation: 31
Great, thanks. Your right, it's not a memory leak, it's cached schtuff. That's pretty frickin' cool
 
Old 11-15-2004, 09:36 PM   #4
pradeepmenon777
Member
 
Registered: Jan 2004
Location: India
Distribution: Android 9.0.6
Posts: 123

Rep: Reputation: 16
yaa that is right. even i had the same problem. i checked it out to be cached content. But what i am surprised is at the memory used by firefox is nearly 92MB and that by an mp3 player is 52MB. Is there any method to lower the RAM usage in these situations. If ever I wish to clean up my RAM, please help me out with suitable commands,
 
Old 11-16-2004, 10:41 AM   #5
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
There are no commands to clear out cache memory. However, if more memory is needed, then memory pages used for caching are simply discarded.

The only configuration you've got is /proc/sys/vm/swappiness; if this is set to a high number (nearer to 100) then your system will actually swap program pages to disk in order to increase cache size.

Far more than you ever wanted to know about swappiness here: http://kerneltrap.org/node/view/3000
 
Old 11-21-2004, 11:38 PM   #6
jillande
Member
 
Registered: Oct 2003
Location: fargoh eh.
Distribution: slackware
Posts: 94

Rep: Reputation: 15
a related problem (i think?)

with my desktop machine (no problems in slack 8 or 9, just upgraded to 10 last week) i'm experiencing horrible problems with memory. within a matter of an hour or two, i'm consuming huge quantities of memory and i can't even untar a file at the same time as ANYTHING else ... i can't even issue commands to top or type a single letter in another xterm window. the only way to clear things out seems to be to restart (something that pains me to have to do).

kernel 2.4.26
bash-2.05b$ cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 1588932608 1119584256 469348352 0 137162752 640421888
Swap: 1011699712 0 1011699712
MemTotal: 1551692 kB
MemFree: 458348 kB
MemShared: 0 kB
Buffers: 133948 kB
Cached: 625412 kB
SwapCached: 0 kB
Active: 361296 kB
Inactive: 586640 kB
HighTotal: 655296 kB
HighFree: 2044 kB
LowTotal: 896396 kB
LowFree: 456304 kB
SwapTotal: 987988 kB
SwapFree: 987988 kB

this is after being up for two hours, running x, open office and mozilla, shutting everything down, logging out, and checking out the memory situation. running slackware 9.1 and 8.1 i never had this sort of problem even after being up for 2 months.

i don't have the /proc/sys/vm/swappiness but it seems like it might be a 2.6.x option? are there any alternatives or suggestions on how to free up memory so that i can actually accomplish something? if i have to upgrade to 2.6 i guess i have to, but i'd prefer not to. please let me know what other information to provide. i've never dealt with such an issue before. even my work machine with only 128 mb of ram running redhat and gnome performs better than this machine is right now. heh. thanks!
 
Old 11-22-2004, 11:33 AM   #7
jillande
Member
 
Registered: Oct 2003
Location: fargoh eh.
Distribution: slackware
Posts: 94

Rep: Reputation: 15
alright. i logged out of everything, logged in as root (so i wouldn't even have my user processes running), and ran top, output to file and here (in all its ugliness) is what was running.

as you might be able to notice or might not be able to since it's messy, is that there is 1233784k/1551692k usage (roughly 79.5%) even though there is essenially nothing running other than system processes.

Code:
?[H?[J?[0;10mtop - 11:23:17 up 20:15,  1 user,  load average: 0.06, 0.19, 0.32?[0;10m?[39;49m?[K
Tasks:?[0;10m?[39;49m?[0;10m  29 ?[0;10m?[39;49mtotal,?[0;10m?[39;49m?[0;10m   1 ?[0;10m?[39;49mrunning,?[0;10m?[39;49m?[0;10m  28 ?[0;10m?[39;49msleeping,?[0;10m?[39;49m?[0;10m   0 ?[0;10m?[39;49mstopped,?[0;10m?[39;49m?[0;10m   0 ?[0;10m?[39;49mzombie?[0;10m?[39;49m?[K
Cpu(s):?[0;10m?[39;49m?[0;10m   3.7% ?[0;10m?[39;49muser,?[0;10m?[39;49m?[0;10m   1.9% ?[0;10m?[39;49msystem,?[0;10m?[39;49m?[0;10m   0.0% ?[0;10m?[39;49mnice,?[0;10m?[39;49m?[0;10m  94.5% ?[0;10m?[39;49midle?[0;10m?[39;49m?[K
Mem: ?[0;10m?[39;49m?[0;10m  1551692k ?[0;10m?[39;49mtotal,?[0;10m?[39;49m?[0;10m  1233784k ?[0;10m?[39;49mused,?[0;10m?[39;49m?[0;10m   317908k ?[0;10m?[39;49mfree,?[0;10m?[39;49m?[0;10m   145300k ?[0;10m?[39;49mbuffers?[0;10m?[39;49m?[K
Swap:?[0;10m?[39;49m?[0;10m   987988k ?[0;10m?[39;49mtotal,?[0;10m?[39;49m?[0;10m        0k ?[0;10m?[39;49mused,?[0;10m?[39;49m?[0;10m   987988k ?[0;10m?[39;49mfree,?[0;10m?[39;49m?[0;10m   929512k ?[0;10m?[39;49mcached?[0;10m?[39;49m?[K
?[6;1H
?[7m  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            ?[0;10m?[39;49m?[K
?[0;10m    1 root       9   0   240  240  212 S  0.0  0.0   0:05.79 init               ?[0;10m?[39;49m?[K
?[0;10m    2 root      10   0     0    0    0 S  0.0  0.0   0:00.61 keventd            ?[0;10m?[39;49m?[K
?[0;10m    3 root      19  19     0    0    0 S  0.0  0.0   0:01.29 ksoftirqd_CPU0     ?[0;10m?[39;49m?[K
?[0;10m    4 root       9   0     0    0    0 S  0.0  0.0   0:00.00 kswapd             ?[0;10m?[39;49m?[K
?[0;10m    5 root       9   0     0    0    0 S  0.0  0.0   0:00.00 bdflush            ?[0;10m?[39;49m?[K
?[0;10m    6 root       9   0     0    0    0 S  0.0  0.0   0:02.26 kupdated           ?[0;10m?[39;49m?[K
?[0;10m    7 root      16   0     0    0    0 S  0.0  0.0   2:07.87 kjournald          ?[0;10m?[39;49m?[K
?[0;10m   38 root      15   0     0    0    0 S  0.0  0.0   0:32.73 kjournald          ?[0;10m?[39;49m?[K
?[0;10m   39 root       9   0     0    0    0 S  0.0  0.0   0:29.53 kjournald          ?[0;10m?[39;49m?[K
?[0;10m   40 root       9   0     0    0    0 S  0.0  0.0   0:00.23 kjournald          ?[0;10m?[39;49m?[K
?[0;10m   62 root       9   0   592  592  512 S  0.0  0.0   0:00.61 syslogd            ?[0;10m?[39;49m?[K
?[0;10m   65 root       9   0   448  448  392 S  0.0  0.0   0:00.01 klogd              ?[0;10m?[39;49m?[K
?[0;10m  182 root       9   0     0    0    0 S  0.0  0.0   0:00.02 khubd              ?[0;10m?[39;49m?[K
?[0;10m  806 root       9   0     0    0    0 S  0.0  0.0   0:00.00 usb-storage-0      ?[0;10m?[39;49m?[K
?[0;10m  807 root       9   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_1          ?[0;10m?[39;49m?[K
?[0;10m  970 root       9   0   568  568  500 S  0.0  0.0   0:00.00 inetd              ?[0;10m?[39;49m?[K
?[0;10m  973 root       9   0  1408 1408 1192 S  0.0  0.1   0:00.56 sshd               ?[0;10m?[39;49m?[K
?[0;10m  981 lp         9   0  1248 1248 1028 S  0.0  0.1   0:00.01 lpd                ?[0;10m?[39;49m?[K?[6;1H?[K?[H?[0;10mtop - 11:23:20 up 20:15,  1 user,  load average: 0.06, 0.19, 0.32?[0;10m?[39;49m?[K
Tasks:?[0;10m?[39;49m?[0;10m  29 ?[0;10m?[39;49mtotal,?[0;10m?[39;49m?[0;10m   1
i tried to copy a 1mb file from one folder to another on the same partition and that process took approx 30 seconds, during which i could not complete other tasks including switch vt's and type commands.

ideas? help?
 
Old 11-27-2004, 12:01 PM   #8
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
Jillande: it looks like you have a bone-fide memory leak here. If you don't have the swappiness file then you don't have the kernel patch for hardware caching as described above.

I'd start investigating this by running top, then press F and sort by %MEM.Look at the process that's eating most of your memory; you are likely to need to shutdown and/or upgrade this in order to make your system usable.

Also, check to see if you have any tmpfs partitions mounted, eg. on /tmp/ as some processes might be using that as a free storage space and hence eating your RAM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory leak?! nyk Programming 10 01-24-2005 07:08 PM
Possible Memory Leak liquidcool Linux - General 3 10-07-2004 08:38 AM
memory leak mdk Mandriva 1 09-17-2004 10:54 AM
Memory Leak when using memory debugging C program on SuSE SLES8 babalina Linux - Distributions 0 10-06-2003 09:39 AM
Memory Leak? eLinux Linux - General 2 09-20-2003 09:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration