[erlang-questions] Memory issue: big swap usage

Erik Søe Sørensen eriksoe@REDACTED
Mon Jul 16 10:33:56 CEST 2012


Either the problem is in Erlang code, or it's a leak at a lower level. The
erlang:memory() numbers seem to indicate the latter.
If it's a low-level issue, then a leak detector like libumem(?) or Valgrind
might be of some use.
It may be an idea to check if the number of ports is stable, and whether it
helps matters if you do the work in a short-lived process. Other than that,
I guess the issue may be hard to tackle from within Erlang itself.
 Den 16/07/2012 10.02 skrev "龙第九子" <physacco@REDACTED>:

> Hi all,
>
> Recently I wrote a service-monitoring program in Erlang. It uses httpc
> (the HTTP client shipped with Erlang/OTP) to fetch web server
> statistics data, does some calculations, and then sends results to
> another service. It works fine, however, the memory usage is very
> strange. While VmRSS stays at a reasonable level, but VmSize and
> VmData keep increasing (about 40m per day). Please look at the
> following data:
>
> System memory usage:
>
>     $ free -m
>                  total       used       free     shared    buffers
> cached
>     Mem:          2012       1486        525          0        216
>  713
>     -/+ buffers/cache:        557       1455
>     Swap:         2047          5       2041
>
>
> `top` shows that the beam.smp process consumes 51m physical memory :)
> and 857m swap memory :(
>
>       PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP
> COMMAND
>     27100 root      20   0  909m  51m 2288 S    2  2.6 149:54.65 857m
> beam.smp
>
>
> Current VM status of the process:
>
>     $ cat /proc/27100/status|grep Vm
>     VmPeak:      932260 kB
>     VmSize:      931616 kB
>     VmLck:           0 kB
>     VmHWM:       54624 kB
>     VmRSS:       52968 kB
>     VmData:      907556 kB
>     VmStk:          88 kB
>     VmExe:        1860 kB
>     VmLib:        2412 kB
>     VmPTE:         208 kB
>
>
> And Erlang reported memory usage (seems good):
>
>     15> erlang:memory().
>     [{total,46487136},
>      {processes,1283144},
>      {processes_used,1251480},
>      {system,45203992},
>      {atom,509577},
>      {atom_used,497728},
>      {binary,169912},
>      {code,4395539},
>      {ets,323224}]
>
>
> I use Erlang R14B03 (erts-5.8.4) compiled with GCC 4.4.5 on Debian 6
> Linux 2.6.32-5-amd64. I'm not sure if there is a memory-leaking bug.
> The problem is too hard for me and I have no choice but to restart the
> process. Could someone be kind enough to help me out? Please.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120716/83dcd318/attachment.htm>


More information about the erlang-questions mailing list