Cannot allocate memory (Errno::ENOMEM)

T

Tom Shealy

Hello,

I'm using a ruby to setup an ec2 instance as part of a bootscript. The
ruby script runs out of memory and exits with an error. I believe this
may be related to the fact that the ruby script makes a lot of system
calls (using the backtick `). I don't need to hang on the the output of
the system call after checking it, and I'm wondering if I should be
doing something to release resources after the forked process finishes.
Any advice is greatly appreciated.

Thanks,

Tom


Bootscript Exit:

/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/kernel/agnostics.rb:7:in
``': Cannot allocate memory - elb-describe-lbs db-beta (Errno::ENOMEM)
from
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/kernel/agnostics.rb:7:in
``'
from /usr/local/Scripts/bootscripts/test.rb:527:in `boot'
from /usr/local/Scripts/bootscripts/test.rb:520:in `each'
from /usr/local/Scripts/bootscripts/test.rb:520:in `boot'
from
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/test_util-1.0.0/lib/test_util.rb:995:in
`test_boot'
from /etc/init.d/ec2-run-user-data:15


pmap information taken while script is running (see large memory use in
[anon] function):

root@localhost:~# pmap 3813
3813: /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby
/etc/init.d/ec2-run-user-data
08048000 752K r-x-- /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby
08104000 4K r---- /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby
08105000 4K rw--- /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby
08106000 64K rw--- [ anon ]
082eb000 1078028K rw--- [ anon ]
b711f000 64K r-x-- /lib/tls/i686/nosegneg/libresolv-2.10.1.so
b712f000 4K r---- /lib/tls/i686/nosegneg/libresolv-2.10.1.so
b7130000 4K rw--- /lib/tls/i686/nosegneg/libresolv-2.10.1.so
b7131000 8K rw--- [ anon ]
b7133000 20K r-x-- /lib/tls/i686/nosegneg/libnss_dns-2.10.1.so
b7138000 4K r---- /lib/tls/i686/nosegneg/libnss_dns-2.10.1.so
b7139000 4K rw--- /lib/tls/i686/nosegneg/libnss_dns-2.10.1.so
b7141000 4K rw--- [ anon ]
b714a000 8K rw--- [ anon ]
b714d000 4K rw--- [ anon ]
b7152000 104K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot_scan.so
b716c000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot_scan.so
b716d000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/hpricot_scan.so
b716e000 80K r-x-- /lib/libz.so.1.2.3.3
b7182000 4K r---- /lib/libz.so.1.2.3.3
b7183000 4K rw--- /lib/libz.so.1.2.3.3
b7184000 1204K r-x-- /lib/i686/cmov/libcrypto.so.0.9.8
b72b1000 32K r---- /lib/i686/cmov/libcrypto.so.0.9.8
b72b9000 52K rw--- /lib/i686/cmov/libcrypto.so.0.9.8
b72c6000 16K rw--- [ anon ]
b72ca000 260K r-x-- /lib/i686/cmov/libssl.so.0.9.8
b730b000 4K ----- /lib/i686/cmov/libssl.so.0.9.8
b730c000 4K r---- /lib/i686/cmov/libssl.so.0.9.8
b730d000 12K rw--- /lib/i686/cmov/libssl.so.0.9.8
b7310000 12K rw--- [ anon ]
b7313000 8K r-x-- /lib/libnss_mdns4_minimal.so.2
b7315000 4K r---- /lib/libnss_mdns4_minimal.so.2
b7316000 4K rw--- /lib/libnss_mdns4_minimal.so.2
b7317000 12K rw--- [ anon ]
b731a000 4K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest/sha1.so
b731b000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest/sha1.so
b731c000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest/sha1.so
b731d000 4K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest/md5.so
b731e000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest/md5.so
b731f000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest/md5.so
b7320000 4K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/fcntl.so
b7321000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/fcntl.so
b7322000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/fcntl.so
b7323000 12K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest.so
b7326000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest.so
b7327000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/digest.so
b7328000 256K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/openssl.so
b7368000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/openssl.so
b7369000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/openssl.so
b736a000 4K rw--- [ anon ]
b736b000 40K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/socket.so
b7375000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/socket.so
b7376000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/socket.so
b7377000 8K r-x-- /usr/lib/gconv/UTF-16.so
b7379000 4K r---- /usr/lib/gconv/UTF-16.so
b737a000 4K rw--- /usr/lib/gconv/UTF-16.so
b737b000 4K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/fast_xs.so
b737c000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/fast_xs.so
b737d000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/fast_xs.so
b737e000 16K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/strscan.so
b7382000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/strscan.so
b7383000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/strscan.so
b7384000 228K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/nkf.so
b73bd000 8K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/nkf.so
b73bf000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/nkf.so
b73c0000 4K rw--- [ anon ]
b73c1000 40K r-x-- /lib/tls/i686/nosegneg/libnss_files-2.10.1.so
b73cb000 4K r---- /lib/tls/i686/nosegneg/libnss_files-2.10.1.so
b73cc000 4K rw--- /lib/tls/i686/nosegneg/libnss_files-2.10.1.so
b73cd000 36K r-x-- /lib/tls/i686/nosegneg/libnss_nis-2.10.1.so
b73d6000 4K r---- /lib/tls/i686/nosegneg/libnss_nis-2.10.1.so
b73d7000 4K rw--- /lib/tls/i686/nosegneg/libnss_nis-2.10.1.so
b73d8000 76K r-x-- /lib/tls/i686/nosegneg/libnsl-2.10.1.so
b73eb000 4K r---- /lib/tls/i686/nosegneg/libnsl-2.10.1.so
b73ec000 4K rw--- /lib/tls/i686/nosegneg/libnsl-2.10.1.so
b73ed000 8K rw--- [ anon ]
b73ef000 28K r--s- /usr/lib/gconv/gconv-modules.cache
b73f6000 12K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/i686-linux/iconv.so
b73f9000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/i686-linux/iconv.so
b73fa000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/i686-linux/iconv.so
b73fb000 40K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/bigdecimal.so
b7405000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/bigdecimal.so
b7406000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/bigdecimal.so
b7407000 104K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/syck.so
b7421000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/syck.so
b7422000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/syck.so
b7423000 8K rw--- [ anon ]
b7425000 84K r-x-- /lib/tls/i686/nosegneg/libpthread-2.10.1.so
b743a000 4K r---- /lib/tls/i686/nosegneg/libpthread-2.10.1.so
b743b000 4K rw--- /lib/tls/i686/nosegneg/libpthread-2.10.1.so
b743c000 8K rw--- [ anon ]
b743e000 112K r-x-- /lib/libgcc_s.so.1
b745a000 4K r---- /lib/libgcc_s.so.1
b745b000 4K rw--- /lib/libgcc_s.so.1
b745c000 4K rw--- [ anon ]
b745d000 920K r-x-- /usr/lib/libstdc++.so.6.0.13
b7543000 16K r---- /usr/lib/libstdc++.so.6.0.13
b7547000 4K rw--- /usr/lib/libstdc++.so.6.0.13
b7548000 28K rw--- [ anon ]
b754f000 1288K r-x-- /lib/tls/i686/nosegneg/libc-2.10.1.so
b7691000 8K r---- /lib/tls/i686/nosegneg/libc-2.10.1.so
b7693000 4K rw--- /lib/tls/i686/nosegneg/libc-2.10.1.so
b7694000 12K rw--- [ anon ]
b7697000 144K r-x-- /lib/tls/i686/nosegneg/libm-2.10.1.so
b76bb000 4K r---- /lib/tls/i686/nosegneg/libm-2.10.1.so
b76bc000 4K rw--- /lib/tls/i686/nosegneg/libm-2.10.1.so
b76bd000 36K r-x-- /lib/tls/i686/nosegneg/libcrypt-2.10.1.so
b76c6000 4K r---- /lib/tls/i686/nosegneg/libcrypt-2.10.1.so
b76c7000 4K rw--- /lib/tls/i686/nosegneg/libcrypt-2.10.1.so
b76c8000 156K rw--- [ anon ]
b76ef000 8K r-x-- /lib/tls/i686/nosegneg/libdl-2.10.1.so
b76f1000 4K r---- /lib/tls/i686/nosegneg/libdl-2.10.1.so
b76f2000 4K rw--- /lib/tls/i686/nosegneg/libdl-2.10.1.so
b76f3000 4K rw--- [ anon ]
b76f4000 28K r-x-- /lib/tls/i686/nosegneg/librt-2.10.1.so
b76fb000 4K r---- /lib/tls/i686/nosegneg/librt-2.10.1.so
b76fc000 4K rw--- /lib/tls/i686/nosegneg/librt-2.10.1.so
b76fd000 4K rw--- [ anon ]
b76fe000 24K r-x-- /lib/tls/i686/nosegneg/libnss_compat-2.10.1.so
b7704000 4K r---- /lib/tls/i686/nosegneg/libnss_compat-2.10.1.so
b7705000 4K rw--- /lib/tls/i686/nosegneg/libnss_compat-2.10.1.so
b7706000 16K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/stringio.so
b770a000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/stringio.so
b770b000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/stringio.so
b770c000 8K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/etc.so
b770e000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/etc.so
b770f000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/etc.so
b7710000 12K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/thread.so
b7713000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/thread.so
b7714000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/1.8/i686-linux/thread.so
b7715000 104K r-x--
/opt/ruby-enterprise-1.8.7-2010.01/lib/libtcmalloc_minimal.so.0.0.0
b772f000 4K r----
/opt/ruby-enterprise-1.8.7-2010.01/lib/libtcmalloc_minimal.so.0.0.0
b7730000 4K rw---
/opt/ruby-enterprise-1.8.7-2010.01/lib/libtcmalloc_minimal.so.0.0.0
b7731000 108K rw--- [ anon ]
b774c000 4K r-x-- [ anon ]
b774d000 108K r-x-- /lib/ld-2.10.1.so
b7768000 4K r---- /lib/ld-2.10.1.so
b7769000 4K rw--- /lib/ld-2.10.1.so
bf455000 7152K rw--- [ stack ]
total 1092368K
 
R

Robert Klemme

I'm using a ruby to setup an ec2 instance as part of a bootscript. The
ruby script runs out of memory and exits with an error. I believe this
may be related to the fact that the ruby script makes a lot of system
calls (using the backtick `). I don't need to hang on the the output of
the system call after checking it,

Note, your Ruby script may run out of memory while *running* the command
already if that command yields too much output.
and I'm wondering if I should be
doing something to release resources after the forked process finishes.
Any advice is greatly appreciated.

Since we don't see the code this is difficult to do. If your sub
processes yield so much output you should probably consider not using
backticks. If you need to look at the output you could use IO#popen or
have the process write to a file. If you do not need the output, you
can redirect to null device or use system and let the program write to
the terminal. It all depends.

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top