Mono MVC 3 shopping cart Web applications are running under Apache in Mono. In top output below there are 3 applications with pids 31398, 30851, 30854 Processes are sorted by %MEM.

After some time there is lot of mono processes which take all on memory and Linux OOM starts to kill them. After that processes are started again and memory usage continues to increase.

How to fix or diagnose this so that mono does not eat all memory? Using Mono 2.10 with .NET 4

It looks like simply vieweing web pages or google bot access causes this issue.

top - 16:12:25 up 26 days,  4:34,  1 user,  load average: 0.23, 0.17, 0.11
Tasks:  65 total,   1 running,  64 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,  0.3%sy,  0.0%ni, 98.6%id,  0.7%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1048576k total,  1023596k used,    24980k free,        0k buffers
Swap:        0k total,        0k used,        0k free,   582340k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
31398 www-data  20   0  254m 122m 5692 S  0.3 11.9   0:29.38 mono
30851 www-data  20   0  202m  71m 4552 S  0.0  6.9   0:13.70 mono
30854 www-data  20   0  245m  51m 4196 S  0.0  5.0   0:05.74 mono
31413 postgres  20   0  117m  47m  29m S  0.0  4.6   0:16.04 postgres
32235 postgres  20   0  111m  40m  27m S  0.0  3.9   0:00.59 postgres
31803 postgres  20   0  106m  35m  28m S  0.0  3.5   0:01.96 postgres
30342 postgres  20   0 99888  26m  25m D  0.3  2.6   0:02.49 postgres
  882 postgres  20   0  103m  23m  19m S  0.0  2.3   0:00.13 postgres
  973 postgres  20   0  102m  17m  13m S  0.0  1.7   0:00.07 postgres
  942 postgres  20   0  102m  16m  12m S  0.0  1.6   0:00.15 postgres
30867 www-data  20   0 58172  14m 2604 S  0.0  1.4   0:00.71 mono
30849 www-data  20   0 51212  12m 2604 S  0.0  1.2   0:00.66 mono
32234 postgres  20   0 99.4m  11m 9388 S  0.0  1.2   0:00.02 postgres
30847 www-data  20   0 50000  11m 2560 S  0.0  1.2   0:00.63 mono
30863 www-data  20   0 50000  11m 2560 S  0.0  1.1   0:00.64 mono
32568 postgres  20   0 99.6m  10m 8304 S  0.0  1.1   0:00.05 postgres
30439 postgres  20   0 99.3m  10m 8120 S  0.0  1.1   0:00.03 postgres
  616 postgres  20   0 99.5m  10m 7324 S  0.0  1.0   0:00.06 postgres
  971 postgres  20   0 99.4m 9.8m 7196 S  0.0  1.0   0:00.01 postgres
  954 postgres  20   0  101m 9288 6544 S  0.0  0.9   0:00.00 postgres
32225 postgres  20   0 98.7m 8812 6344 S  0.0  0.8   0:00.02 postgres
31410 postgres  20   0 98.7m 8708 6272 S  0.0  0.8   0:00.06 postgres
  946 postgres  20   0 99.2m 8648 5928 S  0.0  0.8   0:00.01 postgres
  785 postgres  20   0 99.3m 7912 5152 S  0.0  0.8   0:00.00 postgres
  972 postgres  20   0 99.2m 7808 5136 S  0.0  0.7   0:00.00 postgres
32297 postgres  20   0 99.2m 7688 5016 S  0.0  0.7   0:00.02 postgres
有帮助吗?

解决方案

There's this little memory leak bug in MonoFastCGI which could be well affecting the Apache ModMono integration as well (as both of them share some code).

If using FastCgi, there is a workaround: use unix domain sockets instead of local ports. So, you could try switching to use this technology (which is implemented by many web servers, not only Apache). In my case I used it with nginx and I was pretty satisfied. More info here.

Also, if I were you I would upgrade to Mono 3.x as well.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top