title: OOM-killer with Java application on Linux
body: <p>I have a problem with my Java application on a Linux system (version 2.6.39.2) with 500MB RAM. Every hour my application takes 1-2MB resident memory more. The application starts with 40MB of resident memory used. After 15 days, OOM-killer kills my application (see attached log).</p>
  
  <p>More information:</p>
  
  <ul>
  <li>I haven’t set any memory limit (no Xms, Xmx, …) for my application.</li>
  <li>I have made a heap dump when 396MB of resident memory where used but for Memory Analysis tool, I only use 7.8MB of memory and there were no special memory leaks.</li>
  </ul>
  
  <p>What can I do to found the source of the problem or how to ensure that my application will not be killed?</p>
  
  <p>Thanks in advance for your help.
  Best regards.</p>
  
  <p><strong>EDIT:</strong>
  It is a standalone embedded application without server. The problem occurs on the deployed application on a machine (difficult to install analysis tools) but not on my development PC.</p>
  
  <hr>
  
  <pre><code>Jun  7 06:15:41 HMI user.warn kernel: java invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
  Jun  7 06:15:42 HMI user.warn kernel: Pid: 650, comm: java Not tainted 2.6.39.2 #7
  Jun  7 06:15:42 HMI user.warn kernel: Call Trace:
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c144c264&gt;] ? printk+0xf/0x11
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1074eb8&gt;] dump_header.clone.8+0x58/0x150
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c11dd008&gt;] ? ___ratelimit+0x78/0xf0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1075121&gt;] oom_kill_process.clone.11+0x41/0x220
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c10376e8&gt;] ? has_capability_noaudit+0x18/0x30
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1074fd5&gt;] ? oom_badness+0x25/0x130
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c10755ef&gt;] out_of_memory+0x1bf/0x2a0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1078b4a&gt;] __alloc_pages_nodemask+0x5aa/0x5c0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c107a1cb&gt;] __do_page_cache_readahead+0xdb/0x200
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1072b00&gt;] ? wait_on_page_bit+0x90/0xa0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c107a539&gt;] ra_submit+0x19/0x20
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1074762&gt;] filemap_fault+0x3d2/0x3e0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1086de9&gt;] __do_fault+0x39/0x3a0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1074390&gt;] ? __lock_page_or_retry+0x50/0x50
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1089540&gt;] handle_pte_fault+0x70/0x5b0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1089b0f&gt;] handle_mm_fault+0x8f/0x100
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c101ff00&gt;] do_page_fault+0x100/0x3d0
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1053e0a&gt;] ? sys_futex+0x5a/0x100
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c101fe00&gt;] ? vmalloc_sync_all+0x110/0x110
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c144ed1a&gt;] error_code+0x5a/0x60
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c1440000&gt;] ? vsc_sata_init_one+0x1f6/0x278
  Jun  7 06:15:42 HMI user.warn kernel:  [&lt;c101fe00&gt;] ? vmalloc_sync_all+0x110/0x110
  Jun  7 06:15:42 HMI user.warn kernel: Mem-Info:
  Jun  7 06:15:42 HMI user.warn kernel: DMA per-cpu:
  Jun  7 06:15:42 HMI user.warn kernel: CPU    0: hi:    0, btch:   1 usd:   0
  Jun  7 06:15:42 HMI user.warn kernel: Normal per-cpu:
  Jun  7 06:15:42 HMI user.warn kernel: CPU    0: hi:  186, btch:  31 usd:  52
  Jun  7 06:15:42 HMI user.warn kernel: active_anon:111882 inactive_anon:51 isolated_anon:0
  Jun  7 06:15:42 HMI user.warn kernel:  active_file:70 inactive_file:853 isolated_file:0
  Jun  7 06:15:42 HMI user.warn kernel:  unevictable:0 dirty:0 writeback:0 unstable:0
  Jun  7 06:15:42 HMI user.warn kernel:  free:1183 slab_reclaimable:307 slab_unreclaimable:1016
  Jun  7 06:15:42 HMI user.warn kernel:  mapped:149 shmem:122 pagetables:302 bounce:0
  Jun  7 06:15:42 HMI user.warn kernel: DMA free:2028kB min:88kB low:108kB high:132kB active_anon:13696kB inactive_anon:0kB active_file:0kB inactive_file:72kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15800kB mlocked:0kB dirty:0kB writeback:0kB ma
  Jun  7 06:15:42 HMI user.warn kernel: lowmem_reserve[]: 0 483 483 483
  Jun  7 06:15:42 HMI user.warn kernel: Normal free:2704kB min:2768kB low:3460kB high:4152kB active_anon:433832kB inactive_anon:204kB active_file:280kB inactive_file:3340kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:495488kB mlocked:0kB dirty:0kB w
  Jun  7 06:15:42 HMI user.warn kernel: lowmem_reserve[]: 0 0 0 0
  Jun  7 06:15:42 HMI user.warn kernel: DMA: 393*4kB 7*8kB 3*16kB 1*32kB 1*64kB 2*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 2028kB
  Jun  7 06:15:42 HMI user.warn kernel: Normal: 676*4kB 0*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 2704kB
  Jun  7 06:15:42 HMI user.warn kernel: 1057 total pagecache pages
  Jun  7 06:15:42 HMI user.warn kernel: 0 pages in swap cache
  Jun  7 06:15:42 HMI user.warn kernel: Swap cache stats: add 0, delete 0, find 0/0
  Jun  7 06:15:42 HMI user.warn kernel: Free swap  = 0kB
  Jun  7 06:15:42 HMI user.warn kernel: Total swap = 0kB
  Jun  7 06:15:42 HMI user.warn kernel: 128928 pages RAM
  Jun  7 06:15:42 HMI user.warn kernel: 0 pages HighMem
  Jun  7 06:15:42 HMI user.warn kernel: 2847 pages reserved
  Jun  7 06:15:42 HMI user.warn kernel: 476 pages shared
  Jun  7 06:15:42 HMI user.warn kernel: 124258 pages non-shared
  Jun  7 06:15:42 HMI user.info kernel: [ pid ]   uid  tgid total_vm      rss cpu oom_adj oom_score_adj name
  Jun  7 06:15:42 HMI user.info kernel: [   78]     0    78      535       77   0     -17         -1000 udevd
  Jun  7 06:15:42 HMI user.info kernel: [  314]     0   314      422       17   0       0             0 zeroconf
  Jun  7 06:15:42 HMI user.info kernel: [  320]     1   320      420       17   0       0             0 portmap
  Jun  7 06:15:42 HMI user.info kernel: [  349]     0   349      618       22   0       0             0 rc
  Jun  7 06:15:42 HMI user.info kernel: [  358]    42   358      585       38   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  362]    44   362     3139      184   0       0             0 hald
  Jun  7 06:15:42 HMI user.info kernel: [  363]     0   363      805       45   0       0             0 hald-runner
  Jun  7 06:15:42 HMI user.info kernel: [  374]     0   374      821       32   0       0             0 hald-addon-inpu
  Jun  7 06:15:42 HMI user.info kernel: [  386]    44   386      767       35   0       0             0 hald-addon-acpi
  Jun  7 06:15:42 HMI user.info kernel: [  401]     0   401      531       23   0       0             0 dropbear
  Jun  7 06:15:42 HMI user.info kernel: [  406]     0   406      425       22   0       0             0 acpid
  Jun  7 06:15:42 HMI user.info kernel: [  411]     0   411      617       16   0       0             0 syslogd
  Jun  7 06:15:42 HMI user.info kernel: [  413]     0   413      617       18   0       0             0 klogd
  Jun  7 06:15:42 HMI user.info kernel: [  422]    46   422      666       48   0       0             0 avahi-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  423]    46   423      666       42   0       0             0 avahi-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  431]     0   431      886       18   0       0             0 pure-ftpd
  Jun  7 06:15:42 HMI user.info kernel: [  442]     0   442      618       16   0       0             0 S97x11Dm
  Jun  7 06:15:42 HMI user.info kernel: [  443]     0   443      741       26   0       0             0 xinit
  Jun  7 06:15:42 HMI user.info kernel: [  445]     0   445     7850     4035   0       0             0 X
  Jun  7 06:15:42 HMI user.info kernel: [  452]     0   452      617       15   0       0             0 sh
  Jun  7 06:15:42 HMI user.info kernel: [  453]     0   453     2008      226   0       0             0 matchbox-window
  Jun  7 06:15:42 HMI user.info kernel: [  454]     0   454     2001      725   0       0             0 matchbox-deskto
  Jun  7 06:15:42 HMI user.info kernel: [  455]     0   455     1479      183   0       0             0 matchbox-panel
  Jun  7 06:15:42 HMI user.info kernel: [  472]     0   472      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  474]     0   474   154396   104395   0       0             0 java
  Jun  7 06:15:42 HMI user.info kernel: [  479]     0   479      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  484]     0   484      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  489]     0   489      585       36   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  496]     0   496      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  504]     0   504      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  509]     0   509      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  514]     0   514      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  519]     0   519      585       36   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  524]     0   524      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  529]     0   529      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  535]     0   535      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  540]     0   540      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  546]     0   546      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  552]     0   552      585       36   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  557]     0   557      585       36   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  562]     0   562      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  567]     0   567      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  572]     0   572      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  577]     0   577      585       36   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  582]     0   582      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  587]     0   587      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  592]     0   592      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  597]     0   597      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  602]     0   602      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  610]     0   610      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  616]     0   616      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  621]     0   621      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  626]     0   626      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  631]     0   631      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  636]     0   636      585       35   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  641]     0   641      585       34   0       0             0 dbus-daemon
  Jun  7 06:15:42 HMI user.info kernel: [  642]     0   642     1407      155   0       0             0 mb-applet-menu-
  Jun  7 06:15:42 HMI user.info kernel: [  649]     0   649     1397      139   0       0             0 mb-applet-clock
  Jun  7 06:15:42 HMI user.info kernel: [  837]     0   837      530       77   0     -17         -1000 udevd
  Jun  7 06:15:42 HMI user.info kernel: [  838]     0   838      532       78   0     -17         -1000 udevd
  Jun  7 06:15:42 HMI user.err kernel: Out of memory: Kill process 474 (java) score 798 or sacrifice child
  Jun  7 06:15:42 HMI user.err kernel: Killed process 474 (java) total-vm:617584kB, anon-rss:417580kB, file-rss:0kB
  </code></pre>
  
  <hr>