(This is a cross post from
http://www-128.ibm.com/developerworks/forums/dw_forum.jsp?forum=266&cat=9, but I'm too desperate to behave like a real man - if I find a solution I promise to post to both forums).
I see a real big problem with WebSphere Application Server, Release 4.0.7.
When I try to allocate a byte array I often run into OutofMemoryErrors though Runtime.getRuntime().freeMemory() reports enough free memory.
E.g. running with -Xmx128M and -Xms128M and allocation a byte array of 16M fails!
Here's the scriptlet of a
test JSP page that allocates 2MB chunks and that fails:
And here is what it prints:
freeMem is 99874640
freeMem i= 0 99874640
freeMem i= 1 97874032
freeMem i= 2 118295984
... (3 to 11 left out) ...
freeMem i= 12 98277064
freeMem i= 13 96277048
freeMem i= 14 94277032
freeMem i= 15 92354160
Error: : java.lang.OutOfMemoryError
The VM reports to have ~88 MB free and it can't allocate another 1.9MB!
(The JSP is of course not useful at all, but first I found this error in a
servlet that uses a ByteArrayOutputStream).
Both the JSP page and the servlet run fine on weblogic. The servlet is part of a large enterprise application that runs on WAS 4 (and that can't be changed).
When running a standalone test on the JBM VM the results are much more sensible. The OutofMemoryException will be thrown when the freeMemory is very low. Thus the test fails only in the servlet container.
Here is the exact data:
WebSphere AEs 4.0.7 ptf70339.05 running with process name STORCH/Default Server and process id 2252
Host Operating System is Windows 2000, version 5.0
Java version = J2RE 1.3.1 IBM Windows 32 build cn131w-20030711a ORB130 (JIT enabled: jitc), Java Compiler = jitc, Java VM name = Classic VM
Can anyone help me?
Thanks,
Stefan