OutOfMemoryError cannot be caught

There's a bug open on this (ID 4697804) but I thought I'd advertise it more widely because I've only just discovered it (at the worst possible time) and it's taken me completely by surprise; I'm stuck now as to what I'm meant to do.
The issue is that the OutOfMemoryError thrown when the VM cannot allocate space for an object cannot always be caught by the application. In fact, the comments on the bug report suggest that the error is never actually thrown in these circumstances: the VM is corrupt by that stage and unable to continue executing Java code, so it prints a message on the console as if the error had been thrown and then exits, leaving the application with no possibility of recovery.
This is depressingly easy to reproduce. I added this example to the bug report but it's small enough to be worth repeating here:
import java.util.*;
public class Bug4697804 {
    public static void main(String[] args) {
        try {
            create(2, 1024);
        catch (OutOfMemoryError err) {
            System.err.println("OutOfMemoryError - OK");
    private static Object create(int d, int n) {
        List x = new ArrayList(n);
        if (d > 0) {
            for (int i = 0; i < n; ++i) {
                x.add(create(d-1, n));
        return x;
}I'm using J2SE 1.4.0 on Windows 2000, but I don't think this is platform-specific. If you run the example with the default heap settings it's almost certain to work as expected:
java Bug4697804OutOfMemoryError - OKBut if, in anticipation of a larger memory requirement, you increase the maximum heap size and choose a number which is more than your machine can handle, you're in trouble:
java -Xmx512m Bug4697804Exception java.lang.OutOfMemoryError: requested 4112 bytesPicking a safe value for -Xmx is impossible. What matters is the amount of free memory available at the point where the VM tries to expand the heap, and that varies unpredictably depending on what else is running at the time. So when you start Java -- and that's the only opportunity you get to choose the heap size -- there may be lots of memory free, but by the time the VM comes to need that space it may have been consumed entirely by other applications. Even the default settings won't save you if your machine is heavily loaded.
The only strategy I can come up with to beat this bug is to pre-allocate a fixed-size heap by setting -Xms the same as -Xmx. This is a horrible thing to do because you're bound either to set the size too small and so limit the application's capacity even when there's plenty of free memory, or set it too large and waste the space, starving other applications instead. Also, I can't be certain there aren't other circumstances which will provoke the same behaviour.
I've looked at a lot of discussions in these forums about out of memory errors. Many correctly steer people towards the -Xmx option (which may not be such a good idea as it turns out). But in some there's a suggestion that an OutOfMemoryError is bound to indicate a problem with the program, that it's out of control in some sense, and that you can't expect to handle and recover from such an error. I think that's entirely wrong, in general, and I hope it's not a view which informs the way in which the VM treats its storage allocation.
In an end-user application with any degree of complexity, memory usage is ultimately determined by what users choose to do: how many objects they create and how complex they choose to make them. Placing any kind of limit on that is artificial and unnecessary. I'd expect any language runtime to continue allocating memory for as long as the operating system allows and then fail predictably when memory is exhausted. Granted, the operation in progress at the time is bound to be fatally compromised, but rudimentary programming safeguards can protect data that's been computed up to that point. As long as the application can handle the event and continue, there's hope of salvaging something. To exit without warning is unforgivable.
Anyway, since available memory is determined as much by what other applications do as by your own, even careful programming can't protect you from this problem. In low-memory situations, any API you ever call, if it happens to create objects, may terminate the VM. That's not a nice thought, really.

Okay, so what can we do about it?
In the app I'm writing, the user can get a bunch of data from the database, which is displayed in JTables. When a request for data is made, the client spawns a thread to talk to the server and get the data. If this thread runs out of memory, I'd like it to stop, dump everything it has, and report back to the user that the search was too large, please restrict it somehow.
Of course, I can always limit the search to N records, but this is overly restrictive. I have no idea how much RAM the user has on their client box, and some records are much larger than others anyway. As you said, this solution is unscalable and unacceptable.
In the thread's run() method, I catch OutOfMemoryError but it never seems to get here. It just prints "OutOfMemoryError" on the console and it's hosed. The user is left hung with an hourglass pointer forever. Is this console output coming from the crashed VM?
What can I do?
Thanks! --- Eric

Similar Messages

  • Java.lang.OutOfMemoryError: Cannot allocate memory in tsStartJavaThread

    Running Java Application on Web logic managed server fails with following error:
    java.lang.OutOfMemoryError: Cannot allocate memory in tsStartJavaThread (lifecycle.c:1096).
    Java heap 1G reserved, 741076K committed
    Paged memory=26548K/3145712K.
    Your Java heap size might be set too high.
    Try to reduce the Java heap size using -Xmx:<size> (e.g. "-Xmx128m").
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:640)
    at java.util.concurrent.ThreadPoolExecutor.addIfUnderCorePoolSize(ThreadPoolExecutor.java:703)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:652)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92)
    Memory doesn't seem to be an issue, because -Xmx = 1GB is specified in VM args.
    This application needs only 200MB to run (Obtained by running the application in eclipse and
    checking the heap memory usage).
    Not sure whats causing this error? Application runs as single (main) thread
    and towards the end of the program multiple threads(they do JDBC tasks) are
    are spawned. In this particular case, 3 threads were about to be launched, when
    this error occured. Please help in pointing out what the issue is and how this
    can be resolved.
    Here are further details on Jrockit version and VM arguments:
    Following JRockit is used on the Weblogic machine.
    $java -version
    java version "1.6.0_22"
    Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
    Oracle JRockit(R) (build R28.1.1-14-139783-1.6.0_22-20101206-0241-linux-ia32, compiled mode)
    Following are the JVM arguments:
    java -jrockit -Xms512m -Xmx1024m -Xss10240k
    Thanks in advance.

    Noting that you are using a IBM vm and a rather old one at that...
    Threads take java memory. Normally the solution is to increase the maximum java heap. Doing that depends on the memory that the system supports and the maximum that the VM allows and the default that it uses.
    You might want to verify the command line options you are using. You might want to also find out what happens if you use a larger number or smaller one.
    And if all else fails you can use a thread pool rather than trying to create seperate threads.

  • Java.lang.OutOfMemoryError: cannot create any more threads

    Server: AIX
    OS Level: 4.3.3
    JDK 1.1.8
    I have an application that creates a lot of worker Threads. For each widget, a new Thread is created. If there are 431 widgets, the program displays the OutOfMemory error and exits. If I reduce the number of widgets by 9 and only create 422 Threads everything works fine. I print out the TotalMemory() and the FreeMemory() just before it dies and there seems to be plenty of memory left. I have tried setting the following settings "-ms50m" and "-mx400m", but it seemed to make no difference. Any ideas?
    Total Memory: 10211320
    Free Memory: 1461640
    I also ran using the "verbosegc" option. Here is that output:
    <GC: freeing class [B(300291f8)>
    <GC: freeing class java.lang.Compiler(3002a920)>
    <GC: unloaded and freed 2 classes>
    GC: Wed May 26 13:13:08 2004
    <GC(async)(1): freed 635 objects, 24440 bytes in 8 ms, 65% free (684736/1048568)>
    <GC(1): begin: 2630 ms, mark: 7 ms, sweep: 1 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[1]: managing allocation failure. need 1552 bytes, action=1 (21984/1048568)>
    <GC: freeing class java.lang.NoSuchMethodException(30024300)>
    <GC: freeing class java.rmi.UnexpectedException(30027610)>
    <GC: freeing class sun.rmi.registry.RegistryImpl_Stub(30027b68)>
    <GC: freeing class sun.security.provider.SHA(300250a8)>
    <GC: unloaded and freed 4 classes>
    GC: Wed May 26 13:13:14 2004
    <GC(2): freed 6754 objects, 335560 bytes in 25 ms, 34% free (357544/1048568)>
    <GC(2): begin: 8262 ms, mark: 18 ms, sweep: 7 ms, compact: 0 ms>
    <AF[1]: completed in 532 ms>
    <FIN: async finalizer thread waking>
    <AF[2]: managing allocation failure. need 1552 bytes, action=1 (223896/1048568)>
    GC: Wed May 26 13:13:14 2004
    <GC(3): freed 1787 objects, 92008 bytes in 56 ms, 30% free (315880/1048568)>
    <GC(3): begin: 8795 ms, mark: 20 ms, sweep: 5 ms, compact: 31 ms>
    <GC(3): moved 9012 objects, 470088 bytes in 31 ms>
    <AF[2]: completed in 544 ms>
    <AF[3]: managing allocation failure. need 424 bytes, action=1 (13584/1048568)>
    GC: Wed May 26 13:13:15 2004
    <GC(4): freed 3960 objects, 199056 bytes in 27 ms, 20% free (212640/1048568)>
    <GC(4): begin: 9621 ms, mark: 22 ms, sweep: 5 ms, compact: 0 ms>
    <AF[3]: managing allocation failure. need 424 bytes, action=2 (212640/1048568)>
    <AF[3]: managing allocation failure. need 424 bytes, action=3 (212640/1048568)>
    <AF[3]: zeroed 3 of 3 soft refs in 3 ms>
    GC: Wed May 26 13:13:16 2004
    <GC(5): freed 14 objects, 744 bytes in 23 ms, 20% free (213384/1048568)>
    <GC(5): begin: 10082 ms, mark: 20 ms, sweep: 3 ms, compact: 0 ms>
    <AF[3]: managing allocation failure. need 424 bytes, action=3003 (213384/1048568)>
    <AF[3]: zeroed 0 of 0 soft refs in 3 ms>
    <AF[3]: managing allocation failure. need 424 bytes, action=4 (213384/1048568)>
    <AF: expanded heap by 1048576 to 2097144 bytes, 60% free>
    <AF[3]: completed in 1218 ms>
    <AF[4]: managing allocation failure. need 1552 bytes, action=1 (134080/2097144)>
    GC: Wed May 26 13:13:16 2004
    <GC(6): freed 15077 objects, 748816 bytes in 107 ms, 42% free (882896/2097144)>
    <GC(6): begin: 10726 ms, mark: 34 ms, sweep: 14 ms, compact: 59 ms>
    <GC(6): moved 12562 objects, 828712 bytes in 59 ms>
    <AF[4]: completed in 509 ms>
    <AF[5]: managing allocation failure. need 1552 bytes, action=1 (12744/2097144)>
    GC: Wed May 26 13:13:17 2004
    <GC(7): freed 11655 objects, 575824 bytes in 55 ms, 28% free (588568/2097144)>
    <GC(7): begin: 11542 ms, mark: 41 ms, sweep: 14 ms, compact: 0 ms>
    <AF[5]: completed in 604 ms>
    <AF[6]: managing allocation failure. need 3280 bytes, action=1 (558216/2097144)>
    GC: Wed May 26 13:13:18 2004
    <GC(8): freed 420 objects, 22088 bytes in 110 ms, 27% free (580304/2097144)>
    <GC(8): begin: 11966 ms, mark: 41 ms, sweep: 8 ms, compact: 61 ms>
    <GC(8): moved 11582 objects, 723272 bytes in 61 ms>
    <AF[6]: completed in 473 ms>
    <AF[7]: managing allocation failure. need 1552 bytes, action=1 (12304/2097144)>
    GC: Wed May 26 13:13:18 2004
    <GC(9): freed 7364 objects, 374360 bytes in 59 ms, 18% free (386664/2097144)>
    <GC(9): begin: 12741 ms, mark: 48 ms, sweep: 11 ms, compact: 0 ms>
    <AF[7]: managing allocation failure. need 1552 bytes, action=2 (386664/2097144)>
    <AF[7]: managing allocation failure. need 1552 bytes, action=3 (386664/2097144)>
    <AF[7]: zeroed 0 of 0 soft refs in 9 ms>
    <AF[7]: managing allocation failure. need 1552 bytes, action=4 (386664/2097144)>
    <AF: expanded heap by 1048576 to 3145720 bytes, 45% free>
    <AF[7]: completed in 617 ms>
    GC: Wed May 26 13:13:19 2004
    <GC(10): freed 9825 objects, 492936 bytes in 172 ms, 38% free (1199928/3145720)>
    <GC(10): begin: 13426 ms, mark: 56 ms, sweep: 16 ms, compact: 99 ms>
    <GC(10): moved 22853 objects, 1415864 bytes in 99 ms>
    GC: Wed May 26 13:13:20 2004
    <GC(async)(11): freed 26 objects, 2440 bytes in 66 ms, 38% free (1196344/3145720)>
    <GC(11): begin: 14222 ms, mark: 58 ms, sweep: 8 ms, compact: 0 ms>
    <AF[8]: managing allocation failure. need 16400 bytes, action=1 (112112/3145720)>
    <GC: freeing class java.rmi.UnexpectedException(30027610)>
    <GC: freeing class sun.rmi.registry.RegistryImpl_Stub(30027b68)>
    <GC: freeing class sun.security.provider.SHA(30020b30)>
    <GC: unloaded and freed 3 classes>
    GC: Wed May 26 13:13:24 2004
    <GC(12): freed 5185 objects, 1014736 bytes in 71 ms, 35% free (1126848/3145720)>
    <GC(12): begin: 18001 ms, mark: 59 ms, sweep: 12 ms, compact: 0 ms>
    <AF[8]: completed in 830 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:25 2004
    <GC(async)(13): freed 3882 objects, 824912 bytes in 72 ms, 35% free (1114576/3145720)>
    <GC(13): begin: 19693 ms, mark: 60 ms, sweep: 12 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:27 2004
    <GC(async)(14): freed 3455 objects, 739696 bytes in 75 ms, 35% free (1101776/3145720)>
    <GC(14): begin: 21321 ms, mark: 62 ms, sweep: 13 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[9]: managing allocation failure. need 16400 bytes, action=1 (364032/3145720)>
    GC: Wed May 26 13:13:28 2004
    <GC(15): freed 3223 objects, 704488 bytes in 74 ms, 33% free (1068520/3145720)>
    <GC(15): begin: 22665 ms, mark: 61 ms, sweep: 13 ms, compact: 0 ms>
    <AF[9]: completed in 496 ms>
    <FIN: async finalizer thread waking>
    <AF[10]: managing allocation failure. need 16400 bytes, action=1 (270272/3145720)>
    GC: Wed May 26 13:13:30 2004
    <GC(16): freed 6494 objects, 712488 bytes in 81 ms, 31% free (982760/3145720)>
    <GC(16): begin: 23905 ms, mark: 66 ms, sweep: 15 ms, compact: 0 ms>
    <AF[10]: completed in 617 ms>
    <FIN: async finalizer thread waking>
    <AF[11]: managing allocation failure. need 16400 bytes, action=1 (522936/3145720)>
    GC: Wed May 26 13:13:30 2004
    <GC(17): freed 4048 objects, 474384 bytes in 81 ms, 31% free (997320/3145720)>
    <GC(17): begin: 24759 ms, mark: 66 ms, sweep: 15 ms, compact: 0 ms>
    <AF[11]: completed in 645 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:31 2004
    <GC(async)(18): freed 2878 objects, 372312 bytes in 81 ms, 31% free (988168/3145720)>
    <GC(18): begin: 25455 ms, mark: 67 ms, sweep: 14 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[12]: managing allocation failure. need 16400 bytes, action=1 (649312/3145720)>
    GC: Wed May 26 13:13:32 2004
    <GC(19): freed 1540 objects, 323336 bytes in 203 ms, 30% free (972560/3145720)>
    <GC(19): begin: 26489 ms, mark: 68 ms, sweep: 14 ms, compact: 121 ms>
    <GC(19): moved 28510 objects, 1684672 bytes in 121 ms>
    <AF[12]: completed in 735 ms>
    <FIN: async finalizer thread waking>
    <AF[13]: managing allocation failure. need 16400 bytes, action=1 (75360/3145720)>
    GC: Wed May 26 13:13:34 2004
    <GC(20): freed 5621 objects, 854200 bytes in 81 ms, 29% free (929560/3145720)>
    <GC(20): begin: 27906 ms, mark: 66 ms, sweep: 15 ms, compact: 0 ms>
    <AF[13]: completed in 598 ms>
    <FIN: async finalizer thread waking>
    <AF[14]: managing allocation failure. need 16400 bytes, action=1 (185408/3145720)>
    GC: Wed May 26 13:13:35 2004
    <GC(21): freed 3437 objects, 727680 bytes in 80 ms, 29% free (913088/3145720)>
    <GC(21): begin: 29354 ms, mark: 67 ms, sweep: 13 ms, compact: 0 ms>
    <AF[14]: completed in 600 ms>
    <FIN: async finalizer thread waking>
    <AF[15]: managing allocation failure. need 16400 bytes, action=1 (255960/3145720)>
    GC: Wed May 26 13:13:36 2004
    <GC(22): freed 3369 objects, 631744 bytes in 86 ms, 28% free (887704/3145720)>
    <GC(22): begin: 30784 ms, mark: 72 ms, sweep: 14 ms, compact: 0 ms>
    <AF[15]: completed in 798 ms>
    <FIN: async finalizer thread waking>
    <AF[16]: managing allocation failure. need 1552 bytes, action=1 (277648/3145720)>
    GC: Wed May 26 13:13:38 2004
    <GC(23): freed 4319 objects, 571728 bytes in 208 ms, 27% free (849368/3145720)>
    <GC(23): begin: 31820 ms, mark: 69 ms, sweep: 15 ms, compact: 124 ms>
    <GC(23): moved 32020 objects, 1918840 bytes in 124 ms>
    <AF[16]: completed in 716 ms>
    <FIN: async finalizer thread waking>
    <AF[17]: managing allocation failure. need 16400 bytes, action=1 (57816/3145720)>
    GC: Wed May 26 13:13:39 2004
    <GC(24): freed 8529 objects, 635392 bytes in 93 ms, 22% free (693208/3145720)>
    <GC(24): begin: 32859 ms, mark: 74 ms, sweep: 18 ms, compact: 1 ms>
    <AF[17]: managing allocation failure. need 16400 bytes, action=2 (693208/3145720)>
    <FIN: async finalizer thread waking>
    <AF[17]: synchronously running 4 finalizers>
    <AF[17]: synchronous finalization attempt took 1 ms>
    GC: Wed May 26 13:13:39 2004
    <GC(25): freed 11 objects, 2376 bytes in 89 ms, 22% free (694032/3145720)>
    <GC(25): begin: 33407 ms, mark: 75 ms, sweep: 14 ms, compact: 0 ms>
    <AF[17]: managing allocation failure. need 16400 bytes, action=3 (694032/3145720)>
    <AF[17]: zeroed 9 of 9 soft refs in 15 ms>
    GC: Wed May 26 13:13:40 2004
    <GC(26): freed 58 objects, 3472 bytes in 90 ms, 22% free (697504/3145720)>
    <GC(26): begin: 33957 ms, mark: 76 ms, sweep: 14 ms, compact: 0 ms>
    <AF[17]: managing allocation failure. need 16400 bytes, action=3003 (697504/3145720)>
    <AF[17]: zeroed 0 of 0 soft refs in 16 ms>
    <AF[17]: managing allocation failure. need 16400 bytes, action=4 (697504/3145720)>
    <AF: expanded heap by 1048576 to 4194296 bytes, 41% free>
    <AF[17]: completed in 1842 ms>
    <AF[18]: managing allocation failure. need 8208 bytes, action=1 (265952/4194296)>
    GC: Wed May 26 13:13:41 2004
    <GC(27): freed 17813 objects, 1444896 bytes in 238 ms, 40% free (1710840/4194296)>
    <GC(27): begin: 35625 ms, mark: 80 ms, sweep: 26 ms, compact: 132 ms>
    <GC(27): moved 24970 objects, 1390720 bytes in 132 ms>
    <AF[18]: completed in 936 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:43 2004
    <GC(async)(28): freed 3519 objects, 866264 bytes in 96 ms, 40% free (1699032/4194296)>
    <GC(28): begin: 37429 ms, mark: 79 ms, sweep: 17 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:45 2004
    <GC(async)(29): freed 7470 objects, 964488 bytes in 97 ms, 39% free (1646808/4194296)>
    <GC(29): begin: 39287 ms, mark: 79 ms, sweep: 18 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:47 2004
    <GC(async)(30): freed 4130 objects, 807712 bytes in 97 ms, 38% free (1625440/4194296)>
    <GC(30): begin: 40857 ms, mark: 80 ms, sweep: 17 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:48 2004
    <GC(async)(31): freed 6462 objects, 911544 bytes in 103 ms, 37% free (1579288/4194296)>
    <GC(31): begin: 42499 ms, mark: 83 ms, sweep: 19 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[19]: managing allocation failure. need 16400 bytes, action=1 (544024/4194296)>
    GC: Wed May 26 13:13:50 2004
    <GC(32): freed 9174 objects, 963288 bytes in 255 ms, 35% free (1507304/4194296)>
    <GC(32): begin: 43944 ms, mark: 85 ms, sweep: 22 ms, compact: 148 ms>
    <GC(32): moved 31280 objects, 1760488 bytes in 148 ms>
    <AF[19]: completed in 727 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:51 2004
    <GC(async)(33): freed 5334 objects, 916464 bytes in 105 ms, 35% free (1479760/4194296)>
    <GC(33): begin: 45710 ms, mark: 85 ms, sweep: 20 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:13:53 2004
    <GC(async)(34): freed 4727 objects, 843296 bytes in 110 ms, 34% free (1452368/4194296)>
    <GC(34): begin: 47271 ms, mark: 89 ms, sweep: 21 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[20]: managing allocation failure. need 1552 bytes, action=1 (201640/4194296)>
    GC: Wed May 26 13:13:55 2004
    <GC(35): freed 15729 objects, 1102776 bytes in 311 ms, 31% free (1304416/4194296)>
    <GC(35): begin: 48752 ms, mark: 104 ms, sweep: 32 ms, compact: 175 ms>
    <GC(35): moved 35105 objects, 1835792 bytes in 175 ms>
    <AF[20]: completed in 894 ms>
    <FIN: async finalizer thread waking>
    <AF[21]: managing allocation failure. need 16400 bytes, action=1 (78240/4194296)>
    GC: Wed May 26 13:13:56 2004
    <GC(36): freed 12481 objects, 1155656 bytes in 122 ms, 29% free (1233896/4194296)>
    <GC(36): begin: 50490 ms, mark: 96 ms, sweep: 26 ms, compact: 0 ms>
    <AF[21]: completed in 626 ms>
    <FIN: async finalizer thread waking>
    <AF[22]: managing allocation failure. need 16400 bytes, action=1 (352488/4194296)>
    GC: Wed May 26 13:13:58 2004
    <GC(37): freed 4977 objects, 846352 bytes in 122 ms, 28% free (1198840/4194296)>
    <GC(37): begin: 52136 ms, mark: 98 ms, sweep: 24 ms, compact: 0 ms>
    <AF[22]: completed in 788 ms>
    <FIN: async finalizer thread waking>
    <AF[23]: managing allocation failure. need 16400 bytes, action=1 (447480/4194296)>
    GC: Wed May 26 13:13:59 2004
    <GC(38): freed 3784 objects, 727792 bytes in 127 ms, 28% free (1175272/4194296)>
    <GC(38): begin: 53702 ms, mark: 101 ms, sweep: 26 ms, compact: 0 ms>
    <AF[23]: completed in 732 ms>
    <FIN: async finalizer thread waking>
    <AF[24]: managing allocation failure. need 16400 bytes, action=1 (505640/4194296)>
    GC: Wed May 26 13:14:01 2004
    <GC(39): freed 3844 objects, 648688 bytes in 125 ms, 27% free (1154328/4194296)>
    <GC(39): begin: 54998 ms, mark: 98 ms, sweep: 27 ms, compact: 0 ms>
    <AF[24]: completed in 667 ms>
    <FIN: async finalizer thread waking>
    <AF[25]: managing allocation failure. need 16400 bytes, action=1 (561280/4194296)>
    GC: Wed May 26 13:14:02 2004
    <GC(40): freed 4740 objects, 548792 bytes in 302 ms, 26% free (1110072/4194296)>
    <GC(40): begin: 55896 ms, mark: 102 ms, sweep: 26 ms, compact: 174 ms>
    <GC(40): moved 32891 objects, 1661088 bytes in 174 ms>
    <AF[25]: completed in 743 ms>
    <FIN: async finalizer thread waking>
    <AF[26]: managing allocation failure. need 16400 bytes, action=1 (292096/4194296)>
    GC: Wed May 26 13:14:03 2004
    <GC(41): freed 6267 objects, 774336 bytes in 139 ms, 25% free (1066432/4194296)>
    <GC(41): begin: 57515 ms, mark: 113 ms, sweep: 26 ms, compact: 0 ms>
    <AF[26]: completed in 772 ms>
    <FIN: async finalizer thread waking>
    <AF[27]: managing allocation failure. need 16400 bytes, action=1 (315984/4194296)>
    GC: Wed May 26 13:14:05 2004
    <GC(42): freed 4472 objects, 726008 bytes in 129 ms, 24% free (1041992/4194296)>
    <GC(42): begin: 58864 ms, mark: 104 ms, sweep: 25 ms, compact: 0 ms>
    <AF[27]: managing allocation failure. need 16400 bytes, action=2 (1041992/4194296)>
    <AF[27]: synchronously running 18 finalizers>
    <FIN: async finalizer thread waking>
    <AF[27]: synchronous finalization attempt took 3 ms>
    GC: Wed May 26 13:14:05 2004
    <GC(43): freed 46 objects, 6040 bytes in 129 ms, 24% free (1046480/4194296)>
    <GC(43): begin: 59401 ms, mark: 106 ms, sweep: 23 ms, compact: 0 ms>
    <AF[27]: managing allocation failure. need 16400 bytes, action=3 (1046480/4194296)>
    <AF[27]: zeroed 0 of 0 soft refs in 23 ms>
    <AF[27]: managing allocation failure. need 16400 bytes, action=4 (1046480/4194296)>
    <AF: expanded heap by 1048576 to 5242872 bytes, 39% free>
    <AF[27]: completed in 1233 ms>
    <AF[28]: managing allocation failure. need 16400 bytes, action=1 (439288/5242872)>
    GC: Wed May 26 13:14:08 2004
    <GC(44): freed 7949 objects, 1599288 bytes in 289 ms, 38% free (2038576/5242872)>
    <GC(44): begin: 62021 ms, mark: 106 ms, sweep: 27 ms, compact: 156 ms>
    <GC(44): moved 22967 objects, 1133840 bytes in 156 ms>
    <AF[28]: completed in 1044 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:14:10 2004
    <GC(async)(45): freed 4094 objects, 840880 bytes in 133 ms, 38% free (2030528/5242872)>
    <GC(45): begin: 63875 ms, mark: 108 ms, sweep: 25 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[29]: managing allocation failure. need 8208 bytes, action=1 (114768/5242872)>
    GC: Wed May 26 13:14:12 2004
    <GC(46): freed 21586 objects, 1635288 bytes in 154 ms, 33% free (1750056/5242872)>
    <GC(46): begin: 65807 ms, mark: 115 ms, sweep: 39 ms, compact: 0 ms>
    <AF[29]: completed in 691 ms>
    <FIN: async finalizer thread waking>
    <AF[30]: managing allocation failure. need 1552 bytes, action=1 (696192/5242872)>
    GC: Wed May 26 13:14:13 2004
    <GC(47): freed 14485 objects, 957856 bytes in 376 ms, 31% free (1654048/5242872)>
    <GC(47): begin: 66906 ms, mark: 122 ms, sweep: 38 ms, compact: 216 ms>
    <GC(47): moved 34318 objects, 1722880 bytes in 216 ms>
    <AF[30]: completed in 927 ms>
    <FIN: async finalizer thread waking>
    <AF[31]: managing allocation failure. need 16400 bytes, action=1 (459760/5242872)>
    GC: Wed May 26 13:14:14 2004
    <GC(48): freed 13009 objects, 1168784 bytes in 153 ms, 31% free (1628544/5242872)>
    <GC(48): begin: 68716 ms, mark: 119 ms, sweep: 34 ms, compact: 0 ms>
    <AF[31]: completed in 747 ms>
    <FIN: async finalizer thread waking>
    <AF[32]: managing allocation failure. need 16400 bytes, action=1 (538768/5242872)>
    GC: Wed May 26 13:14:17 2004
    <GC(49): freed 8330 objects, 1021448 bytes in 339 ms, 29% free (1560216/5242872)>
    <GC(49): begin: 70875 ms, mark: 122 ms, sweep: 33 ms, compact: 184 ms>
    <GC(49): moved 24324 objects, 1119304 bytes in 184 ms>
    <AF[32]: completed in 1494 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:14:19 2004
    <GC(async)(50): freed 4448 objects, 927416 bytes in 152 ms, 29% free (1545096/5242872)>
    <GC(50): begin: 72825 ms, mark: 122 ms, sweep: 30 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[33]: managing allocation failure. need 16400 bytes, action=1 (158984/5242872)>
    GC: Wed May 26 13:14:21 2004
    <GC(51): freed 10590 objects, 1250112 bytes in 167 ms, 26% free (1409096/5242872)>
    <GC(51): begin: 74814 ms, mark: 130 ms, sweep: 37 ms, compact: 0 ms>
    <AF[33]: completed in 736 ms>
    <FIN: async finalizer thread waking>
    <AF[34]: managing allocation failure. need 1552 bytes, action=1 (402752/5242872)>
    GC: Wed May 26 13:14:22 2004
    <GC(52): freed 13192 objects, 837080 bytes in 415 ms, 23% free (1239832/5242872)>
    <GC(52): begin: 75673 ms, mark: 135 ms, sweep: 41 ms, compact: 238 ms>
    <GC(52): moved 34722 objects, 1631272 bytes in 238 ms>
    <AF[34]: managing allocation failure. need 1552 bytes, action=2 (1239832/5242872)>
    <FIN: async finalizer thread waking>
    <AF[34]: synchronously running 6 finalizers>
    <AF[34]: synchronous finalization attempt took 1 ms>
    GC: Wed May 26 13:14:22 2004
    <GC(53): freed 21 objects, 4984 bytes in 161 ms, 23% free (1241712/5242872)>
    <GC(53): begin: 76457 ms, mark: 130 ms, sweep: 31 ms, compact: 0 ms>
    <AF[34]: managing allocation failure. need 1552 bytes, action=3 (1241712/5242872)>
    <AF[34]: zeroed 0 of 0 soft refs in 34 ms>
    <AF[34]: managing allocation failure. need 1552 bytes, action=4 (1241712/5242872)>
    <AF: expanded heap by 1048576 to 6291448 bytes, 36% free>
    <AF[34]: completed in 1415 ms>
    <AF[35]: managing allocation failure. need 16400 bytes, action=1 (252936/6291448)>
    GC: Wed May 26 13:14:24 2004
    <GC(54): freed 23814 objects, 1717504 bytes in 453 ms, 31% free (1970440/6291448)>
    <GC(54): begin: 78098 ms, mark: 148 ms, sweep: 51 ms, compact: 253 ms>
    <GC(54): moved 34460 objects, 1684384 bytes in 253 ms>
    <AF[35]: completed in 952 ms>
    <FIN: async finalizer thread waking>
    <AF[36]: managing allocation failure. need 16400 bytes, action=1 (143712/6291448)>
    GC: Wed May 26 13:14:26 2004
    <GC(55): freed 26403 objects, 1600136 bytes in 203 ms, 27% free (1743848/6291448)>
    <GC(55): begin: 79739 ms, mark: 148 ms, sweep: 55 ms, compact: 0 ms>
    <AF[36]: completed in 758 ms>
    <FIN: async finalizer thread waking>
    <AF[37]: managing allocation failure. need 61912 bytes, action=1 (1223696/6291448)>
    GC: Wed May 26 13:14:27 2004
    <GC(56): freed 5320 objects, 370504 bytes in 481 ms, 25% free (1594200/6291448)>
    <GC(56): begin: 80478 ms, mark: 153 ms, sweep: 47 ms, compact: 281 ms>
    <GC(56): moved 43171 objects, 1952320 bytes in 281 ms>
    <AF[37]: completed in 883 ms>
    <FIN: async finalizer thread waking>
    <AF[38]: managing allocation failure. need 16400 bytes, action=1 (394680/6291448)>
    GC: Wed May 26 13:14:28 2004
    <GC(57): freed 14083 objects, 964208 bytes in 209 ms, 21% free (1358888/6291448)>
    <GC(57): begin: 81774 ms, mark: 160 ms, sweep: 49 ms, compact: 0 ms>
    <AF[38]: managing allocation failure. need 16400 bytes, action=2 (1358888/6291448)>
    <FIN: async finalizer thread waking>
    <AF[38]: synchronously running 12 finalizers>
    <AF[38]: synchronous finalization attempt took 1 ms>
    GC: Wed May 26 13:14:28 2004
    <GC(58): freed 36 objects, 5168 bytes in 206 ms, 21% free (1360952/6291448)>
    <GC(58): begin: 82355 ms, mark: 160 ms, sweep: 46 ms, compact: 0 ms>
    <AF[38]: managing allocation failure. need 16400 bytes, action=3 (1360952/6291448)>
    <AF[38]: zeroed 0 of 0 soft refs in 50 ms>
    <AF[38]: managing allocation failure. need 16400 bytes, action=4 (1360952/6291448)>
    <AF: expanded heap by 1101824 to 7393272 bytes, 33% free>
    <AF[38]: completed in 1294 ms>
    <AF[39]: managing allocation failure. need 16400 bytes, action=1 (674336/7393272)>
    GC: Wed May 26 13:14:31 2004
    <GC(59): freed 16138 objects, 1510224 bytes in 584 ms, 29% free (2184560/7393272)>
    <GC(59): begin: 84491 ms, mark: 178 ms, sweep: 60 ms, compact: 346 ms>
    <GC(59): moved 55092 objects, 2219584 bytes in 346 ms>
    <AF[39]: completed in 1242 ms>
    <FIN: async finalizer thread waking>
    <AF[40]: managing allocation failure. need 8208 bytes, action=1 (120088/7393272)>
    GC: Wed May 26 13:14:33 2004
    <GC(60): freed 17355 objects, 1880752 bytes in 245 ms, 27% free (2000840/7393272)>
    <GC(60): begin: 86760 ms, mark: 183 ms, sweep: 62 ms, compact: 0 ms>
    <AF[40]: completed in 866 ms>
    <FIN: async finalizer thread waking>
    <AF[41]: managing allocation failure. need 1552 bytes, action=1 (221648/7393272)>
    GC: Wed May 26 13:14:35 2004
    <GC(61): freed 21131 objects, 1627296 bytes in 591 ms, 25% free (1848944/7393272)>
    <GC(61): begin: 88506 ms, mark: 181 ms, sweep: 63 ms, compact: 347 ms>
    <GC(61): moved 57273 objects, 2733408 bytes in 347 ms>
    <AF[41]: completed in 1170 ms>
    <FIN: async finalizer thread waking>
    <AF[42]: managing allocation failure. need 16400 bytes, action=1 (84512/7393272)>
    GC: Wed May 26 13:14:36 2004
    <GC(62): freed 18625 objects, 1461576 bytes in 263 ms, 20% free (1546088/7393272)>
    <GC(62): begin: 90212 ms, mark: 196 ms, sweep: 67 ms, compact: 0 ms>
    <AF[42]: managing allocation failure. need 16400 bytes, action=2 (1546088/7393272)>
    <FIN: async finalizer thread waking>
    <AF[42]: synchronously running 14 finalizers>
    <AF[42]: synchronous finalization attempt took 1 ms>
    GC: Wed May 26 13:14:37 2004
    <GC(63): freed 46 objects, 6728 bytes in 252 ms, 20% free (1549712/7393272)>
    <GC(63): begin: 90853 ms, mark: 197 ms, sweep: 55 ms, compact: 0 ms>
    <AF[42]: managing allocation failure. need 16400 bytes, action=3 (1549712/7393272)>
    <AF[42]: zeroed 0 of 0 soft refs in 61 ms>
    <AF[42]: managing allocation failure. need 16400 bytes, action=4 (1549712/7393272)>
    <AF: expanded heap by 1294336 to 8687608 bytes, 32% free>
    <AF[42]: completed in 1441 ms>
    <AF[43]: managing allocation failure. need 16400 bytes, action=1 (658696/8687608)>
    GC: Wed May 26 13:14:40 2004
    <GC(64): freed 20119 objects, 2108800 bytes in 611 ms, 31% free (2767496/8687608)>
    <GC(64): begin: 93853 ms, mark: 197 ms, sweep: 68 ms, compact: 346 ms>
    <GC(64): moved 46120 objects, 1817512 bytes in 346 ms>
    <AF[43]: completed in 1340 ms>
    <FIN: async finalizer thread waking>
    <AF[44]: managing allocation failure. need 16400 bytes, action=1 (348696/8687608)>
    GC: Wed May 26 13:14:43 2004
    <GC(65): freed 24943 objects, 2286616 bytes in 280 ms, 30% free (2635312/8687608)>
    <GC(65): begin: 97187 ms, mark: 209 ms, sweep: 71 ms, compact: 0 ms>
    <AF[44]: completed in 1027 ms>
    <FIN: async finalizer thread waking>
    <AF[45]: managing allocation failure. need 16400 bytes, action=1 (921208/8687608)>
    GC: Wed May 26 13:14:45 2004
    <GC(66): freed 25648 objects, 1677408 bytes in 628 ms, 29% free (2598616/8687608)>
    <GC(66): begin: 99185 ms, mark: 203 ms, sweep: 72 ms, compact: 353 ms>
    <GC(66): moved 40683 objects, 1679720 bytes in 353 ms>
    <AF[45]: completed in 1269 ms>
    <FIN: async finalizer thread waking>
    <AF[46]: managing allocation failure. need 16400 bytes, action=1 (298648/8687608)>
    GC: Wed May 26 13:14:48 2004
    <GC(67): freed 24497 objects, 2194248 bytes in 280 ms, 28% free (2492896/8687608)>
    <GC(67): begin: 102480 ms, mark: 209 ms, sweep: 71 ms, compact: 0 ms>
    <AF[46]: completed in 1045 ms>
    <FIN: async finalizer thread waking>
    <AF[47]: managing allocation failure. need 16400 bytes, action=1 (926440/8687608)>
    GC: Wed May 26 13:14:51 2004
    <GC(68): freed 16029 objects, 1506568 bytes in 649 ms, 28% free (2433008/8687608)>
    <GC(68): begin: 104589 ms, mark: 212 ms, sweep: 71 ms, compact: 366 ms>
    <GC(68): moved 37208 objects, 1532696 bytes in 366 ms>
    <AF[47]: completed in 1219 ms>
    <FIN: async finalizer thread waking>
    <AF[48]: managing allocation failure. need 16400 bytes, action=1 (173384/8687608)>
    GC: Wed May 26 13:14:52 2004
    <GC(69): freed 51791 objects, 2147296 bytes in 315 ms, 26% free (2320680/8687608)>
    <GC(69): begin: 106490 ms, mark: 225 ms, sweep: 90 ms, compact: 0 ms>
    <AF[48]: completed in 934 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:14:54 2004
    <GC(async)(70): freed 6219 objects, 1029800 bytes in 283 ms, 26% free (2288904/8687608)>
    <GC(70): begin: 108407 ms, mark: 217 ms, sweep: 66 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:14:56 2004
    <GC(async)(71): freed 5729 objects, 880760 bytes in 283 ms, 25% free (2248616/8687608)>
    <GC(71): begin: 110141 ms, mark: 217 ms, sweep: 66 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[49]: managing allocation failure. need 16400 bytes, action=1 (969720/8687608)>
    GC: Wed May 26 13:14:59 2004
    <GC(72): freed 5892 objects, 1249144 bytes in 687 ms, 25% free (2218864/8687608)>
    <GC(72): begin: 112714 ms, mark: 223 ms, sweep: 68 ms, compact: 396 ms>
    <GC(72): moved 39455 objects, 1664056 bytes in 396 ms>
    <AF[49]: completed in 1301 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:01 2004
    <GC(async)(73): freed 8020 objects, 1112008 bytes in 306 ms, 25% free (2175920/8687608)>
    <GC(73): begin: 115094 ms, mark: 232 ms, sweep: 74 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:03 2004
    <GC(async)(74): freed 3458 objects, 784440 bytes in 285 ms, 24% free (2157712/8687608)>
    <GC(74): begin: 116914 ms, mark: 221 ms, sweep: 64 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:05 2004
    <GC(async)(75): freed 4251 objects, 820752 bytes in 288 ms, 24% free (2133176/8687608)>
    <GC(75): begin: 118932 ms, mark: 222 ms, sweep: 66 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:07 2004
    <GC(async)(76): freed 3670 objects, 792432 bytes in 295 ms, 24% free (2111200/8687608)>
    <GC(76): begin: 120808 ms, mark: 228 ms, sweep: 67 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:09 2004
    <GC(async)(77): freed 5047 objects, 853656 bytes in 293 ms, 23% free (2078848/8687608)>
    <GC(77): begin: 122707 ms, mark: 225 ms, sweep: 68 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:11 2004
    <GC(async)(78): freed 2987 objects, 762568 bytes in 295 ms, 23% free (2063392/8687608)>
    <GC(78): begin: 124622 ms, mark: 228 ms, sweep: 67 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:12 2004
    <GC(async)(79): freed 4024 objects, 809992 bytes in 295 ms, 23% free (2040800/8687608)>
    <GC(79): begin: 126488 ms, mark: 226 ms, sweep: 69 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:14 2004
    <GC(async)(80): freed 4276 objects, 820272 bytes in 300 ms, 23% free (2013800/8687608)>
    <GC(80): begin: 128277 ms, mark: 230 ms, sweep: 70 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:16 2004
    <GC(async)(81): freed 2995 objects, 763960 bytes in 299 ms, 22% free (1998048/8687608)>
    <GC(81): begin: 130138 ms, mark: 229 ms, sweep: 70 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    <AF[50]: managing allocation failure. need 16400 bytes, action=1 (1239008/8687608)>
    GC: Wed May 26 13:15:18 2004
    <GC(82): freed 3634 objects, 725728 bytes in 731 ms, 22% free (1964736/8687608)>
    <GC(82): begin: 131754 ms, mark: 234 ms, sweep: 71 ms, compact: 425 ms>
    <GC(82): moved 57964 objects, 2313288 bytes in 425 ms>
    <AF[50]: managing allocation failure. need 16400 bytes, action=2 (1964736/8687608)>
    <FIN: async finalizer thread waking>
    <AF[50]: synchronously running 18 finalizers>
    <AF[50]: synchronous finalization attempt took 0 ms>
    GC: Wed May 26 13:15:19 2004
    <GC(83): freed 43 objects, 7568 bytes in 296 ms, 22% free (1970752/8687608)>
    <GC(83): begin: 132865 ms, mark: 231 ms, sweep: 65 ms, compact: 0 ms>
    <AF[50]: managing allocation failure. need 16400 bytes, action=3 (1970752/8687608)>
    <AF[50]: zeroed 0 of 0 soft refs in 74 ms>
    <AF[50]: managing allocation failure. need 16400 bytes, action=4 (1970752/8687608)>
    <AF: expanded heap by 1523712 to 10211320 bytes, 34% free>
    <AF[50]: completed in 1951 ms>
    GC: Wed May 26 13:15:20 2004
    <GC(async)(84): freed 3361 objects, 465256 bytes in 663 ms, 34% free (3478624/10211320)>
    <GC(84): begin: 133983 ms, mark: 237 ms, sweep: 67 ms, compact: 359 ms>
    <GC(84): moved 10549 objects, 445792 bytes in 359 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:22 2004
    <GC(async)(85): freed 4413 objects, 819304 bytes in 304 ms, 33% free (3453600/10211320)>
    <GC(85): begin: 136216 ms, mark: 235 ms, sweep: 69 ms, compact: 0 ms>
    <FIN: async finalizer thread waking>
    GC: Wed May 26 13:15:24 2004
    <GC(async)

    Noting that you are using a IBM vm and a rather old one at that...
    Threads take java memory. Normally the solution is to increase the maximum java heap. Doing that depends on the memory that the system supports and the maximum that the VM allows and the default that it uses.
    You might want to verify the command line options you are using. You might want to also find out what happens if you use a larger number or smaller one.
    And if all else fails you can use a thread pool rather than trying to create seperate threads.

  • OutOfMemoryError when opening environment using Java API

    I've been getting a strange error recently and I can't seem to figure out why. Whenever my DBXML environment gets opened, I receive a "java.lang.OutOfMemoryError: Cannot allocate memory" error. The machine has over 700 MB of free RAM. Here is the code I use to create/open the environment.
    EnvironmentConfig envConf = new EnvironmentConfig();
    envConf.setAllowCreate(true); // If the environment does not exits, create it.
    envConf.setInitializeCache(true); // Turn on the shared memory region.
    envConf.setInitializeLocking(true); // Turn on the locking subsystem.
    envConf.setInitializeLogging(true); // Turn on the logging subsystem.
    envConf.setTransactional(true); // Turn on the transactional subsystem.
    envConf.setThreaded(true); //Turn on thread-safe
    envConf.setLogRegionSize(500000); //Increase logging region
    envConf.setErrorStream(System.err); //Set error stream
    envConf.setMaxLocks(5000); //Set max # of locks
    envConf.setMaxLockers(5000); //Set max # of lockers
    envConf.setMaxLockObjects(5000); //Set max # of lock objects
    envConf.setMaxMutexes(10);
    //Set the error stream to write to a log file
    String fileName = SystemProps.DATA_HOME + "/dbxml.log";
    File f = new File(fileName);
    FileOutputStream fos = new FileOutputStream(f);
    envConf.setErrorStream(fos);
    return new Environment(envHome, envConf);
    Is there something specific I'm doing here that would require lots of RAM? Could it be related to the size/contents of my DBXML containers?
    Thanks in advance.

    I'm not exactly sure why this worked, but running recovery seems to have fixed my problem.

  • Cannot capture the exception generated by EJB components.

    Hi, All:
    I got a strange problem when developing EJB application under SAP WAS server. I developed an EJB as below:
    public class UserAccountBean implements SessionBean{
         String getUserEmail(String accountID) throws SAPSystemException{
              if(error){
                   throw new SAPSystemException("Specified user not found.");
    Exception I defined as below.
    public class SAPSystemException extends Exception {
    @param message
         public SAPSystemException(String message) {
              super(message);
    In client side I code as below:
    public String getUserMail(String accountID){
         UserAccount bean = home.create();
         try{
              String email = bean.getUserEmail(accountID);
         }catch(SAPSystemException e){
              // do something here;
         }catch(Exception e){
              // do some other thing here;
    It is strange that the SAPSystemException I throw out in the bean cannot be caught by the block catch(SAPSystemException e), it is only captured as general exception and it is said as UndeclaredThrowableException.
    When I deployed EJB components and Web components together, the exception can be captured successfully. But when I deployed them separately, it has problem for exception capture. I think it must be the protocol problem. Before I only use RMI-IIOP but SAP WAS server using RMI-P4. Is anything I can do to solve this problem?
    I packed the remote and home interface for the EJB and common classes like value objects and exceptions in both components. Is there anything I forgot to set for the deployment?
    Thanks in advance.
    Message was edited by: Weimin Guo
    Message was edited by: Weimin Guo

    Thank you very much Gregor. In fact, I already defined this throws exception in the remote object interface.
    public interface UserAccount extends EJBObject {
         public String getUserEmail(String accountID) throws RemoteException, SAPSystemException;
    This is application-specific interface and this mechanism works well in my previous in other application server.
    I checked the SAP document and found if you using RMI-IIOP, you need to get the client package for your deployed EJBs and put in the path accessible by the WEB components. Based on this suggestion, I put the EJB jar file together with WEB application (Sure the EJB application still deployed in other host and JNDI point to that host. I remembered one book mentioned that if you don't want generate the client package from EJB containter, you can do it this way. For me, I just haven't found the way to get the client package with Administrator Tool it said.), It works!!!. I checked the remote object generated by home object, it is different with EJB jar file there or not. But in the document SAP said that only if you use RMI-IIOP you need do this way, for RMI-P4, you don't need that. Anyway, it seems that RMI-P4 use same way as RMI-IIOP(You only don't need narrow the home object after lookup).
    I'll try to find how to get EJB client package from WAS server. For this is my first time to use SAP WAS Server, things a little strange.
    Thank you very much for your great help.
    Cheers.

  • "App_DispatcherUnhandledException" cannot work while migrating from VSTS2010 to VSTS2013

    In the past, our project was developed in VSTS2010 and .NET 4.0, everything works well.
    Right now, while migrating from VSTS2010 to VSTS2013 and from .NET 4.0 to .NET 4.5.1, we found that the exceptions thrown from one UI thread cannot be caught and handled in main thread.
    I mean, once the exception is thrown,  the "App_DispatcherUnhandledException" cannot catch and handle it in Debug.
    During the migration, we don't change any codes and just update the project configuration file.
    Is anyone know how to solve this problem?
    Thanks so much!!

    Hello Zeng Wei,
    It seems we do not have an edition called VSTS2013, it is old version when in
    2005. Can I just understand you are upgrade your project from Visual Studio 2010 to Visual Studio 2013?
    Anyway, for App_DispatcherUnhandledException that cannot be raised, we can check the MSDN article:
    https://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception.aspx?f=255&MSPPError=-2147217396
    If an exception is not handled on either a background user interface (UI) thread (a thread with its own
    Dispatcher) or a background worker thread (a thread without a
    Dispatcher), the exception is not forwarded to the main UI thread. Consequently,
    DispatcherUnhandledException is not raised. In these circumstances, you will need to write code to do the following:
    Handle exceptions on the background thread.
    Dispatch those exceptions to the main UI thread.
    Rethrow them on the main UI thread without handling them to allow DispatcherUnhandledException to be raised.
    Another thing is that please make sure you have this code:e.Handled =
    true
    best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • OutOfMemoryError with Vectors

    Hello,
    I am trying to read a lot of data using a database built-in function : search.
    The resultset is put into a vector using the following code :
    public Vector search (......)
    Vector v=new Vector();
    LDAPSearchResults res=ld.search(.......);
    while ( res.hasMoreElements())
    v.addElement((LDAPEntry) results.next());
    return v;
    When calling the method for 30000 registers : Vector v=search(.......)
    I get a OutOfMemorError.
    I have tried to capture the OutOfMemoryError in the search Method
    public Vector search (...)
    try
    } catch (OutOfMemoryError e)
    System.out.println("No memory!!!");
    but it does not work. I still get : java.lang:OutOfMemoryError.
    I am calling those functions from the WEB.
    THanks for helping.

    Hi,
    from my experience catching out OutOfMemoryErrors works in JSP as expected.
    Following Code runs fine on TomCat 3.21: After the Vector eats up all memory there appears the OutOfMemoryError which is caught by the exception handler.
    Could be a problem with you Servlet/JSP container - what are you running? - or the LDAP-Server (?) you are using.
    Whether or not you application can do any sensefull in an out-of-memory-situation is the other side of the coin. ;-)
    Regards
    Martin Schl�ter
    <code>
    <%@page contentType="text/plain"%>
    Plain text JSP
    <%
    String str = " Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt";
    str += str + str;
    str += str + str;
    str += str + str;
    str += str + str;
    Vector vec = new Vector();
    for(int i = 0; i < Integer.MAX_VALUE; i++)
    try
    vec.addElement(str);
    catch(OutOfMemoryError ex)
    out.println("Ex: " + ex.getClass().getName());
    break;
    if(i % 100000 == 0)
    out.println(i);
    out.flush();
    %>
    </code>

  • How to catch SAP application errors in BPM.

    Hi,
    I have a IDOC to Soap Sync Scenario where I send the message to a Webservice. I have used a BPM since we need to catch the resposne of this message and map it to a RFC. For ex if I get a success resposne I need to map success if not than I need to catch the error and map it to the RFC. Now here in some cases like if the target system (webservice) is down than XI raises a sap application error:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Inbound Message
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Category>XIAdapterFramework</SAP:Category>
      <SAP:Code area="MESSAGE">GENERAL</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: Connection refused (errno:239)</SAP:AdditionalText>
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack />
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Normally XI stops the process in these cases and does not proceed to the next step but I need to catch this message and map the content in the AdditionalText to the target RFC. Can anyone let me know how to catch this SAP Application Error in BPM and map it to the RFC.
    Thanks,
    Bhargav

    Hi Gaurav,
    As I have mentioned I need to catch the application error in the BPM. If you see the discussion that is mentioned after the blog you have mentioned it is stated that the fault messages or the application error cannot be caught in BPM.
    In the blog that you stated we can catch the fault message and map it to a message structure but only to that extent after that it would stop the BPM process at that step but would not proceed further as shown in the screenshot given in the blog it would fail as "application error restart not possible".
    I need to proceed further and capture this error to an RFC Structure and call a proxy.
    Here after the error it does not proceed to the next step.
    Thanks,
    Bhargav

  • Java threads on machines with hundreds of cores

    I don't know if this is the right forum, but I try anyway.
    My problem is with java on machines with many cores.
    I have some large shared memory machines with 500 cores.
    When a user run java programs on these machines java starts 300+ threads which to me seems way too much for the application as the same application runs faster on systems with less cores and memory and without creating 300+ threads.
    I have found information about how to limit memory usage, but I have not been able to find any information about how to limit the number of threads java creates nor what criteria java uses to determine how many threads should be created.
    In this context threads are the tasks reported under /proc/<PID of java binary>/task on a Linux system.
    Thanks
    John

    Hi,
    Thanks for the reply.
    We did some more testing and found that java on startup looks in /sys/devices/system/cpu/, which holds information about the 512 CPU's on the system.
    We then tried to lower number of allowed processes using ulimit -u 20 and got this error when running the program:
    # A fatal error has been detected by the Java Runtime Environment:
    # java.lang.OutOfMemoryError: Cannot create GC thread. Out of system resources.
    # Internal Error (gcTaskThread.cpp:38), pid=303212, tid=140353923254032
    # Error: Cannot create GC thread. Out of system resources.
    # JRE version: 6.0_21-b06
    # Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0-b16 mixed mode linux-amd64 )
    # An error report file with more information is saved as:
    # /net/panfsdb0/panfsvol1/simon/projects/cge/test/hs_err_pid303212.log
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    Aborted
    Now a Google search for gcTaskThread revealed that it is the Garbage Collector that creates the many threads. Google also told us that the number of GC threads can be controlled by the JVM option -XX:ParallelGCThreads=<number_of_GC_threads> . Specifying 8 GC threads the program now runs with 18 threads. Specifying 4 GC threads the program runs with 14 threads.
    So it seems like the JVM by default creates as many Garbage Collectors threads as there are CPU's in the system.
    This is a very bad practice as on such systems where programs are run within cpusets with just a small subset of the system wide CPU's.
    Instead of searching /sys/devices/system/cpu/ for number of system wide CPU's JVM should read /dev/cpuset/<cpuset id>/cpus to see how many CPU's are actually available for the job.
    Thanks
    John
    Edited by: 886656 on Sep 22, 2011 2:13 AM

  • How to catch CONVT_NO_NUMBER runtime error in ABAP Proxy

    Hi all,
           In our abap proxy program, sometimes the CONVT_NO_NUMBER will happen and cause the program dump and then stuck the whole queue. I noticed that this error cannot be caught by CX_ROOT exception class. So, how can I catch this runtime error and avoid the dump of our program?
    Thanks,
    YiNing

    Hi,
    While Executing the proxy,first give \h TC and then execute the proxy then it will automatically got to debugging mode.
    I think ur data is worng,if it is wrong then only u will get this type of errors.
    Regards,
    Phani

  • Catch CONVT_NO_NUMBER runtime error in OO ABAP Program

    Hi all,
           In our abap proxy program, sometimes the CONVT_NO_NUMBER will happen and cause the program dump. I noticed that this error cannot be caught by CX_ROOT exception class.
           Some told me I can use the CATCH SYSTEM-EXCEPTIONS sentence to catch this runtime error, but it is a old-way syntax and cannot be used with the "try" and "catch".
           So, how can I catch this runtime error and avoid the dump of our program?
    Thanks,
    YiNing

    Hi,
    You are not checking for conversion.
    You are checking ofr logical expression.
    Try below code, it works
    DATA error_ref TYPE REF TO cx_sy_conversion_no_number.
    DATA err_text TYPE string.
    DATA a TYPE i.
    TRY.
        MOVE 'A' TO a.
      CATCH cx_sy_conversion_no_number INTO error_ref.
        err_text = error_ref->get_text( ).
        WRITE err_text.
    ENDTRY.
    Regards,
    Atish

  • F110 ABAP Run time Error

    Hi Friends,
    My user has run F110 payment program
    payment proposal and payment run also created. open vendor invoices also cleared with cleared doucments. But Run Time ABAP Error  occured. the job was cancelled.
    the bank payments are  not happend. below description is the Error analysis.
    Runtime Errors         CONVT_NO_NUMBER
    Date and Time          17.02.2009 09:27:31
    Short text
         Unable to interpret "CSE " as a number.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "SAPLFPAYM_NO" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
         Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
         keep them for a long time.
    Error analysis
         An exception occurred that is explained in detail below.
         This exception cannot be caught in the context of the current statement.
    The reason for the exception is:
    The program attempted to interpret the value "CSE " as a number, but
    since the value contravenes the rules for correct number formats,
    this was not possible.
    How to correct the error
        Whole numbers are represented in ABAP as a sequence of numbers, poss
         with an algebraic sign.
        The following are the possibilities for the representation of floati
        point numbers:
          [algebraic sign][mantissa]E[algebraic sign][exponent]
          [algebraic sign][whole number part].[fraction part]
        For example, -12E+34, +12E-34, 12E34, 12.34
        If the error occurred in your own ABAP program or in an SAP
        program you modified, try to remove the error.
        If the error occures in a non-modified SAP program, you may be able
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the followi
        keywords:
        "CONVT_NO_NUMBER" " "
        "SAPLFPAYM_NO" or "LFPAYM_NOU01"
        "FI_PAYMEDIUM_DMEE_PAYMULNO_05"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
    please give me some inputs, should I suggest to user to reset the clear invoices  and run again the
    F110.
    Points will be awarded.

    hi
    ru using any kind of BAPi here
    check following
    /message/3794598#3794598 [original link is broken]
    Re: Sdccn Runtime error CONVT_NO_NUMBER
    plz do the analysis in ST22 with ur ABAper
    regards
    KI

  • IOS 5 Safari JavaScript execution exceeded timeout

    I am working on a mobile web app that is primarily self-contained and communicated with the server only when necessary. Currently, the libraries being used are:
    - jQuery 1.6.4
    - jQuery UI 1.8.3
    - Modified/patched version of jQTouch
    Up until the release of iOS 5 we were also using touchscroll.js but it is no longer needed since Safari now supports position: fixed and native scrolling.
    Since the release of iOS 5, seemingly at random, this exception is raised:
        JavaScript: Error undefined JavaScript execution exceeded timeout
    Once it is raised, no JS code that runs for more than a *very* short period of time (say 1ms) will be executed by Safari. Refreshing the page, going to a new page, or going to a new domain has no effect. Any and all JS code, even something as simple as
        for(var i = 0; i < 30; i++) ;
    will not be executed by the browser without the exception being raised. The only way around this is to force kill Safari and restart it. I suppose it is also possible to wrap any remotely "heavy duty" code in the application in a window.setTimeout(..., 1) or take advantage of Web Workers for everything but UI updates but that doesn't seem like a very good solution as the application is fairly large and it would require a substantial rewrite.
    Has anyone encountered this issue before? How would you go about debugging something like this as it isn't any single piece of code that seems to put Safari into this broken state and it can happen seemingly at random?
    I tried to figure out what the timeout of the JS engine is in mobile Safari by doing the following:
        var start, end;
        start = new Date();
        try {
           while(true);
        } catch (ex) {
          alert('test');
        end = new Date();
        console.log(Number(end) - Number(start) + 'ms');
    Unfortunately it seems this timeout exception isn't a JS exception so it cannot be caught in a try/catch block; however, it appears the max timeout period is in the realm of several seconds. None of the code in our app locks the browser/JS engine for that long (as it would provide a terrible UX) and most if not all of it probably has a sub 300ms execution time (including anything that's "heavy duty").

    illvminatvs wrote:
    Sometimes even simple DOM queries in jQuery like $('.foo') would trigger this behavior.
    There is nothing simple about jQuery. I'm pretty confident I could create a page where such a selector would bring any desktop browser to its knees.
    Moreover, this issue did not exist in iOS 4 and only manifested itself in iOS 5 and IIRC only occured on iPad 2 devices and not the original iPad.
    I highly doubt that.
    So call it what you will. I'll call it a bug.
    What I'll do is put on my overalls, grab my cane, and tell you how it was in my day.
    Back in my day, every operating system had bugs. Every application running on them had bugs. You know what we did? Blame the vendor? Yep. Filed a bug report? Sure. Sit on our hands? Never! You know what we did? We "worked around it". There was no internet where someone would post just the lines of code we needed. There were no example apps. There was no open source. Somehow, we still got it working.
    Just suppose, for the sake of argument, that you are absolutely correct. This is a bug the Apple introduced in iOS 5 and it breaks your app. Will Apple release a fix for it next month? Unlikely. Next quarter? Maybe, maybe not. 2015? My oldest Apple bug report is dated "04-Apr-2008 06:39 PM".
    It is an imperfect, competitive world. If you don't want to work around the bugs, all that does is give that opportunity to someone else.

  • Runtime Errors    BCD_FIELD_OVERFLOW Exception CX_SY_CONVERSION_OVERFLOW

    Dear All,
    I am getting below error in PRD system. We are using ecc6, oracle 10g and windows 2003. The error coming  after we have restarted  the server. Please suggest how to solve the issues.
    SM21 log
    09:30:21 DIA  000 000 DDIC                               AB  0 Run-time error "BCD_FIELD_OVERFLOW" occurred
    09:30:21 DIA  000 000 DDIC                               AB  1 > Short dump "100913 093034 nodeA " generated
    ST22
    Runtime Errors         BCD_FIELD_OVERFLOW
    Exception              CX_SY_CONVERSION_OVERFLOW
    Date and Time          13.09.2010 00:30:19
    Short text
         A calculation field is defined too small.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "CL_SWNC_RECORD================CP" had to be
          terminated because it has
         come across a statement that unfortunately cannot be executed.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_CONVERSION_OVERFLOW', was not
         caught in
        procedure "DO_TRANSFORMATIONS" "(METHOD)", nor was it propagated by a RAISING
         clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        A value generated during processing is too large for the
        field "ME->MAIN_RECORD_STR+1020(7)" of the program
         "CL_SWNC_RECORD================CP".
    Regards,
    Kumar

    Dear Friends,
    We even got same dump "BCD_FIELD_OVERFLOW" just after system restart. But error was slightly different. Please find below error details and solution:
    Error Details:
    The current ABAP program "CL_SWNC_RECORD================CP" had to be terminated because it has come across a statement that unfortunately cannot be executed.
    Error Analysis:
    An exception occurred that is explained in detail below. This exception cannot be caught in the context of the current statement.
    The reason for the exception is: A value generated during processing is too large for the field " " of the program "CL_SWNC_RECORD================CP".
    "BCD_FIELD_OVERFLOW" " "
    "CL_SWNC_RECORD================CP" or "CL_SWNC_RECORD================CM002"
    "CALCULATE_PROCESSING_TIME"
    SOLUTION:
    An OSS Note:
    Note 1103295 - BCD_FIELD_OVERFLOW in CALCULATE_PROCESSING_TIME (It solves the problem)

  • Im new to java and hope somebody can help me with my question

    Hi!
    Im quite new to java and I just have some simple questions..
    can someone please tell what kinds of error are considered as language violation for java? where can I find more info about these errors?
    can someone give me a simple example on a kind of error that cannot be caught in both compilation and runtime? I hope someone can help me out. Thanks in advance!!

    knightz211 wrote:
    Im just asking about errors that might go against the language definition but cant be detected.. If it "goes against the language defintion," it will be detected by the compiler. That's half of the compiler's job is to tell you what you've done that violates the language spec.
    because it confuses me when they say that such errors might occur so I just want to know what might these errors be.. sorry for that..Who's "they"? What exactly* did "they" say about "such errors"? It sounds to me like you're just confused, and you think there's something mysterious and inexplicable going on but you don't know what and don't even know what you're asking.
    I would suggest not worrying about hypothetical problems that you can't even put into words and focussing on learning Java. Along the way, if you encounter real, specific, actual problems, ask about them, and you'll probably get answers about the problems themselves and the language or theory behind them.

Maybe you are looking for

  • Block Payment Terms

    Dear All, We have created some additional payment terms. During the document posting, by mistakenly the users were selected different payment terms which is not relevant. Instead of deleting those unused/irrelevant payment terms, we would like to mak

  • How to set date value in hidden item

    I have a form which has an date item, P1_MTIME , if I use data picker and an procedure (After header)to define its default , as begin :P1_MTIME := to_char(sysdate,'DD-MON-RR HH24:MI'); end; Everything works fine, but when I change P1_MTIME to hidden,

  • Why is the "missing favicon" icon gone on new tabs?

    When I open a new tab, or I am on a page with no favicon, the little dotted line square that used to be present is now gone. Is this intentional? And if it is, can I bring it back, preferably with the classic theme restorer?

  • Breaking Dawn – the newest of the Twilight series and In Time

    I have really enjoyed all of the Twilight movies (I'm a sucker for a good love story) and was able to watch the newest of the series – Breaking Dawn (released on 2/11/12) last weekend, as well as the new Justin Timberlake film (released on 1/31/12) –

  • I broke my iPod touch screen. What do I do?

    My iPod touch 5th generation screen is cracked! I need to get it repaired for a reasonable price. What do I do?