We've received a report about a bug regarding SUN's JVM that causes the JVM iteself to crash with a message regarding an OutOfMemoryError even if there is plenty of space in the heap. Obviously if the JVM crashes cause the heap is full you're not in this case and you should increase your heap size and/or decrease the usage of the heap made by your adapter.

The message could be like this one:

java.lang.OutOfMemoryError: requested <bytes> bytes for <reason>. Out of swap space?

(where <int> and <reason> can vary)

We've never experienced the issue directly.

Note that the problem is not related to Lightstreamer. You can find a lot of threads on the internet reporting this problem for different applications like tomcat, coldfusion and several custom programs, on different operating systems (Win2000, WinXP, different Linux distros) and different VMs (1.4, 1.5 and 6).

After a short investigation we provide here some info and resources to help you investigate and solve the problem in the case this happens to you. Unfortunately it seems that there is not a fixed way to go through.

Below are some bug reports regarding similar issues:
  1. http://bugs.sun.com/bugdatabase/view...bug_id=4916142
  2. http://bugs.sun.com/bugdatabase/view...bug_id=4697804
Those are various articles that could help
  1. from http://java.sun.com/developer/techni...SE/monitoring/
    ...Native memory error. The Java Native Interface (JNI) code or the native library of an application and the JVM implementation allocate memory from the native heap. An OutOfMemoryError will be thrown when an allocation in the native heap fails. For example, the following error message indicates insufficient swap space, which could be caused by a configuration issue in the operating system or by another process in the system that is consuming much of the memory:
    java.lang.OutOfMemoryError: request <size> bytes for <reason>. Out of swap space?
  2. from http://www.velocityreviews.com/forum...it-linux-.html
    ...#You could possibly try to use vmstat and such tools to track the system
    memory to see which process is using what memory. By doing this, you at
    least, are able to verify where the memory problem is.

    #This has to do with the max memory a particular process can occupy. I
    believe the *default* value most vendors us in workstation editions of
    Linux is 2GB of ram per process (minus some overhead). You can
    reconfigure your kernel manually to allow more memory, or, if you are
    not comfortable doing that, purchase an enterprise edition support
  3. from http://www.talkingtree.com/blog/inde...-Plain-English
    ...this would also help explain why JVM crashes leaving behind HotSpot crash logs happen after hours or days of uptime... The demand on the application has risen to the level where HotSpot begins to do its thing, finally exacerbating any HotSpot flaws or weaknesses...
  4. from http://forum.java.sun.com/thread.jsp...art=0&tstart=0
    ...If you look, he has plenty of heap. The problem is that the hotspot compiler is asking the OS for more memory outside the heap and for some reason the WIndows OS is refusing to grant it more memory. There are several things that use memory outside of the heap. Native (JNI) methods can directly allocate memory from the OS. NIO uses memory directly, hotspot compiler, and there are others...
    ...Generally speaking, there are usually two reasons on why you'll get an OOME when you have apparently plenty of heap space left:
    1) You suffer from memory fragmentation. So, while
    there is apparently enough heap left, there is no
    enough contiguous space to allocate what is
    2) Space is needed outside the JVM (Caffeine's
    point). Specially true if you're using JNI...
  5. from http://java.sun.com/javase/6/webnote...-VM/TSG-VM.pdf
    ...The detail message request <size> bytes for <reason>. Out of swap space? appears to be an OutOfMemoryError.However, theHotSpotVMcode reports this apparent exception when an allocation from the native heap failed and the native heap might be close to exhaustion. The message indicates the size (in bytes) of the request that failed and the reason for the memory request...If this type of OutOfMemoryError is thrown, you might need to use troubleshooting utilities on the operating system to diagnose the issue further...