Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mysql Memory Usage
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
SuperMe
n00b
n00b


Joined: 30 May 2005
Posts: 25
Location: London, UK

PostPosted: Sun Jan 28, 2007 1:17 am    Post subject: mysql Memory Usage Reply with quote

I have a local Gentoo server which I use as a playground. I am developing a new website and so am having a look at apache2 and gallery2 using a mysql database. The mysql demon seems to be using a lot more memory than anything else running on my system. This isn't a problem as I have 2GB however I am curious why it's using so much considering it's doing so little. Any ideas?

Code:
top - 02:06:32 up  7:45,  2 users,  load average: 0.00, 0.00, 0.00
Tasks:  64 total,   2 running,  61 sleeping,   1 stopped,   0 zombie
Cpu(s):  0.0% us,  0.0% sy,  0.0% ni, 100.0% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:   2025900k total,  1309148k used,   716752k free,   281108k buffers
Swap:  8016416k total,        0k used,  8016416k free,   468252k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 4854 mysql     18   0  144m  28m 3924 S    0  1.5   0:00.06 mysqld
 9222 postgres  16   0 41896 6820 6192 S    0  0.3   0:00.08 postmaster
 5012 root      15   0 66060 5428 2528 S    0  0.3   0:00.01 apache2
 5077 monotone  19   0 19480 5212 3996 S    0  0.3   0:00.05 mtn
 5081 nick      18   0 66060 3840  928 S    0  0.2   0:00.00 apache2
 5082 nick      18   0 66060 3840  928 S    0  0.2   0:00.00 apache2
 5083 nick      21   0 66060 3840  928 S    0  0.2   0:00.00 apache2
 5084 nick      20   0 66060 3840  928 S    0  0.2   0:00.00 apache2
 5085 nick      20   0 66060 3840  928 S    0  0.2   0:00.00 apache2
 5497 root      16   0 21232 2300 1792 S    0  0.1   0:00.04 sshd
 8767 root      16   0 21228 2296 1792 S    0  0.1   0:00.04 sshd
 5154 root      20   0 27484 2216 1320 S    0  0.1   0:00.00 smbd
 8770 nick      16   0 10464 1832 1348 S    0  0.1   0:00.01 bash
 5500 nick      16   0 10468 1828 1340 S    0  0.1   0:00.00 bash
 9229 postgres  15   0 23868 1652  508 S    0  0.1   0:00.00 postmaster
 5499 nick      15   0 21384 1504  968 S    0  0.1   0:02.14 sshd
 8769 nick      16   0 21380 1488  968 R    0  0.1   0:00.13 sshd
 9227 postgres  16   0 41896 1332  672 S    0  0.1   0:00.00 postmaster
 9682 nick      16   0 10536 1268  940 R    0  0.1   0:00.00 top
 4944 root      16   0 18672 1184  752 S    0  0.1   0:00.00 sshd
 5164 root      15   0 10976 1164  800 S    0  0.1   0:00.52 nmbd
 5158 root      20   0 27484 1136  240 S    0  0.1   0:00.00 smbd
 9228 postgres  16   0 24372 1108  476 S    0  0.1   0:00.00 postmaster
 8775 nick      16   0  5048  808  636 T    0  0.0   0:00.00 pg
 5233 root      16   0  9012  720  572 S    0  0.0   0:00.00 cron
 5321 root      17   0  3672  684  572 S    0  0.0   0:00.00 agetty
 5323 root      17   0  3672  684  572 S    0  0.0   0:00.00 agetty
 5318 root      16   0  3672  680  572 S    0  0.0   0:00.00 agetty
 5320 root      16   0  3672  680  572 S    0  0.0   0:00.00 agetty
 5317 root      17   0  3668  676  572 S    0  0.0   0:00.00 agetty
 5319 root      17   0  3668  676  572 S    0  0.0   0:00.00 agetty
 1121 root      21  -4  7056  624  340 S    0  0.0   0:00.28 udevd
 4296 root      15   0  4936  620  392 S    0  0.0   0:00.00 syslog-ng
    1 root      16   0  2604  568  484 S    0  0.0   0:00.47 init
Back to top
View user's profile Send private message
drescherjm
Advocate
Advocate


Joined: 05 Jun 2004
Posts: 2790
Location: Pittsburgh, PA, USA

PostPosted: Sun Jan 28, 2007 5:08 am    Post subject: Reply with quote

If I read this correctly mysql is using 144MB which is small in my opinion.

Now if you are talking about the system memory usage this is actually a very good feature of linux. As linux will use almost all of your unused memory for disk cache. When an application requests some the disk cache will shrink.
_________________
John

My gentoo overlay
Instructons for overlay
Back to top
View user's profile Send private message
SuperMe
n00b
n00b


Joined: 30 May 2005
Posts: 25
Location: London, UK

PostPosted: Mon Jan 29, 2007 10:31 am    Post subject: Reply with quote

Thanks. To me 144MB seemed a lot considering it's not doing anything. I just wanted to check if this was normal or if I had some sort of problem.
Back to top
View user's profile Send private message
lluthor
n00b
n00b


Joined: 28 Jan 2007
Posts: 4

PostPosted: Mon Jan 29, 2007 10:55 am    Post subject: Re: mysql Memory Usage Reply with quote

SuperMe wrote:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4854 mysql 18 0 144m 28m 3924 S 0 1.5 0:00.06 mysqld
[/code]


You are reading it incorrectly.

mysql is using 144MB of virtual memory (i.e. address space), this is likely due mmap()ing some data files. This is good, since the kernel can freely allocate and deallocate this as needed, even for dirty pages, since they can be written straight to disk whenever, and clean pages can simply be dropped and page-faulted back in when needed.

Out of this 144MB, mysql is actually only using 28M of dirty memory (memory that cannot simply be dropped by the kernel), and even this can be paged if needed.

The rest of the 144MB, mysql is using ~4MB of clean memory (this is likely the binaries and libraries of mysql) and this can be dropped and faulted as well, and the libraries (and the read-only portions of the binaries) are also shareable like glibc so they consume a constant amount no matter how many processes use them.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum