0

I'm running an Java app on Ubuntu 12.04.3 x64 VPS using Oracle Java. After few minutes the process gets killed by the OS: "killed" appears in the console.

Before the crash, excessive memory usage can be seen using TOP (few gigabytes of virtual memory). In order to inspect the leak I have installed the Java VisualVM and connected to it remotely through jstatd. No signs of leak can be seen:

  • Heap size: 10 MB
  • PermGen space size: 20 MB
  • Threads: 5
  • Classes loaded: 815

After few tries, the hs_err_pid7071.log and hs_err_pid7057.log appeared in the apps directory (linked).

There are some native libraries used by the app.

I run jcmd 8749 VM.native_memory detail and got this result. VM was using about 2 GB of memory at the time.

Removing this line makes the leak disappear:

Kryo kryo = new Kryo();
return kryo.copy(gameWorld);

Documentation of this method

atok
  • 5,880
  • 3
  • 33
  • 62
  • It looks like you have non-heap memory leak. Make a heap dump just before it crashes and look for non-java resources such as images or file handles. – Piotr Praszmo Jan 11 '14 at 13:17
  • log says that no swap space is available. Run `free -mt` and check why is that and whether is it a system problem or your application is consuming all of it. – ssedano Jan 11 '14 at 13:30
  • Swap total:0 - that's how the VPS was configured. But the app should not be using as much memory in the first place. – atok Jan 11 '14 at 13:44
  • I don't understand what you have posted. First you say it's can't be reproduced, then you say removing that line made it disappear. If it can't be reproduced, how do you know removing that line made it disappear? – Robin Green Jan 11 '14 at 14:25
  • It's easy to reproduce: it crashes every time. I'm sorry. English is not my first language. Please, feel free to fix any part of my question that suggests the error is not reproducible. – atok Jan 11 '14 at 15:49
  • Narrow it down further. Figure out which objects in 'gameWorld' are causing the problem. Presumably the ones with non-heap memory allocations. – P.T. Jan 11 '14 at 16:52
  • Thank you P.T.! I found it: one of the fields in this object was a reference to Box2D World that lives on the native heap. I wrongly assumed it's not copied because the field was marked as 'transient'. :D – atok Jan 11 '14 at 17:13

1 Answers1

0

I see this line in your hs* files:

Memory: 4k page, physical 502752k(372080k free), swap 0k(0k free)

Is it true, that your machine has only around 370M of free memory? And you try to start JVM process with "jvm_args: -Xms1g" ? Where from this 1G could come?

Nikem
  • 5,716
  • 3
  • 32
  • 59