Skip to main content

6u11 give my applet Out Of Memory Errors

15 replies [Last post]
demonduck
Offline
Joined: 2008-03-14
Points: 0

FF2; 6u11

PanCyl; v0.3.2 -- New JavaScript Response
Memory: 8,304K Free: 3,845K (46%) ... completed.

IE6
PanCyl; v0.3.2 -- New JavaScript Response
Memory: 390,336K Free: 383,787K (98%) ... completed.

Both give me out of memory errors.

Reverting to 6u10

Addendum:

When I removed 6u11 -- I was reverted to 1.5u10 even though
6u10 was the previous version. 1.5u10 wouldn't allow my
applet to run.

I had to reinstall 6u10 by hand. Now my applet runs in
both FF2 and IE6.

This is soooo depressing...

Addendum 2:

I downloaded the offline installer for 6u11 -- installed
it and got out of memory errors. I restarted my machine
and now it runs. I'm running Windows 2000 maybe that
has something to do with it.

So in summary, doing an update (apparently) requires a
machine restart.

Addendum 3:

More weirdness -- running my applet from my web site
works -- running it locally I get out of memory errors.

It's the same jar on my website and locally. It's the
same HTML page on my website and locally and if I open
the page on my website it runs and if I open the page
locally it doesn't run. This happens in both FF2 and IE6
with 6u11. With 6u10 everything runs both from my website
and locally. I'm exhausted....

Addendum 4:

Reverted to 6u10. Stuff works again -- I hope...

Somebody try (click on a thumbnail):

http://pancyl.com/aerialpan.htm

with 6u10 and 6u11 -- use IE6 or FF2. Let me know
what you see.

Addendum 5:

Tried 6u11 again. Still getting Out of memory errors
when the applet is run locally.

Here's the results of 5 tests -- 3 in FF2 -- 2 in IE6.
Plenty of memory is allocated in IE6 because I use
the java_arguments param to allocate 384 meg on startup.

Still I get Out Of Memory Errors locally even with
a huge amount of memory. Something else is going on.

FF2 -- NET -- NO MEMORY ERROR
Java Plug-in 1.6.0_11
Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator

PanCyl; v0.3.2 -- New JavaScript Response
Memory: 87,904K Free: 16,432K (18%) ... completed.

FF2 -- Local -- MEMORY ERROR

Java Plug-in 1.6.0_11
Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator

PanCyl; v0.3.2 -- New JavaScript Response
Memory: 8,336K Free: 3,872K (46%) ... completed.

FF2 -- Net -- NO MEMORY ERROR

Java Plug-in 1.6.0_11
Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator

PanCyl; v0.3.2 -- New JavaScript Response
Memory: 53,780K Free: 23,639K (43%) ... completed.

********************

IE6 -- Local -- MEMORY ERROR
Java Plug-in 1.6.0_11
Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator

PanCyl; v0.3.2 -- New JavaScript Response
Memory: 390,336K Free: 383,797K (98%) ... completed.

--------

IE6 -- NET -- NO MEMORY ERROR
Java Plug-in 1.6.0_11
Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator

PanCyl; v0.3.2 -- New JavaScript Response
Memory: 390,208K Free: 359,268K (92%) ... completed.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jacobdk
Offline
Joined: 2008-04-21
Points: 0

I'm using 1.6.0_11 with FF3 and IE7. Your applet works just fine here in both, I don't get any errors.

I don't have access to any of the old browsers FF2 or IE6, so I can't speak for those. Have you tried FF3 / IE7? You might also want to try experiment with the new memory allocation parameter for applets in your HTML file. Like this for allocation 128 mb for the applet:

You get back to 1.5.0 because of the new Patch-In-Place functionality introduced in 1.6.0_10, which upgrades your existing JRE installation instead of installing next to it. This is to avoid having the old version lying around in "Add/Remove Programs"/"Programs and Features" when installing an update.

Before patch-in-place in 6u10, if you had originally installed 1.6.0_00 and used Java Update until 1.6.0_07, you would have 8 JRE installations cluttering your Program Files directory and "Add/Remove Programs"/"Programs and Features", where 7 of them would be of no use. Now you only have the latest version from 6u10 and onwards, which I personally think is a big improvement.

Hope this helps,
Jacob

demonduck
Offline
Joined: 2008-03-14
Points: 0

> I'm using 1.6.0_11 with FF3 and IE7. Your applet
> works just fine here in both, I don't get any
> errors.

That's good news. I don't have access to the new browsers so
I'm always grateful for the information about how my applet
runs in FF3 and/or IE7.

> I don't have access to any of the old browsers FF2 or
> IE6, so I can't speak for those. Have you tried FF3 /
> IE7? You might also want to try experiment with the
> new memory allocation parameter for applets in your
> HTML file. Like this for allocation 128 mb for the
> applet:
>
>

Yes, I've used that and if you look at the source for the popup window
you get when you click on a thumbnail you will see that param
in the applet tag. The java_arguments param works great in
browsers that plugin2 supports like IE6. Doesn't work in FF2, but
I was getting out of memory errors in both IE6 -- which is supported
by plugin2 -- and FF2. And I only got out of memory errors when
the applet was run locally -- not over the net. I hope it will just go
away. I'm going to try 6u11 again today.

> You get back to 1.5.0 because of the new
> Patch-In-Place functionality introduced in 1.6.0_10,
> which upgrades your existing JRE installation instead
> of installing next to it. This is to avoid having the
> old version lying around in "Add/Remove
> Programs"/"Programs and Features" when installing an
> update.
>
> Before patch-in-place in 6u10, if you had originally
> installed 1.6.0_00 and used Java Update until
> 1.6.0_07, you would have 8 JRE installations
> cluttering your Program Files directory and
> "Add/Remove Programs"/"Programs and Features", where
> 7 of them would be of no use. Now you only have the
> latest version from 6u10 and onwards, which I
> personally think is a big improvement.

Yes, patch in place is a much better idea. That's a good thing.
I was not aware of this until you told me about it. No complaints
about patch in place.

> Hope this helps,
> Jacob

Yes it does, thanks Jacob...

DD

tackline
Offline
Joined: 2003-06-19
Points: 0

> That's good news. I don't have access to the new
> browsers so
> I'm always grateful for the information about how my
> applet
> runs in FF3 and/or IE7.

"Note: Firefox 2.0.0.x will be maintained with security and stability updates until mid-December, 2008. All users are encouraged to upgrade to Firefox 3."

https://developer.mozilla.org/devnews/index.php/2008/07/01/firefox-20015...

Best get on that.

Tom

demonduck
Offline
Joined: 2008-03-14
Points: 0

The problem is that 6u11 fails with an Out of Memory Error when I try to run an applet
locally.

It's not a firewall problem.I turned my firewall off and I still get Out of Memory Errors.
It happens in IE6 which is supported by plugin2 even when I have the java_arguments set
to allocate 384meg of memory.

6u10 doesn't fail with Out of Memory Errors when I run applets locally in FF2.

It's not the browsers. It's not my firewall. I don't run anti-virus of any kind.

So I guess it's 6u11 that is screwed up -- yet another screwup from our favorite dev team.

Is it possible that the Java Quick Starter is screwing up?
Is it not allocating enough memory at start up time?
Is there a way to turn it off and still run Java in
a browser?

trembovetski
Offline
Joined: 2003-12-31
Points: 0

> Is it possible that the Java Quick Starter is screwing up?

Java Quick Starter has nothing to do with this - it's a separate process, all it does is keeps some files in the OS file cache.

What's the stack trace when it runs out of memory?

Could you post a -verbose:gc log?

Dmitri

demonduck
Offline
Joined: 2008-03-14
Points: 0

How do I get the log? Do I type 'v' in the console window or do I set JVM params
in the control panel?

demonduck
Offline
Joined: 2008-03-14
Points: 0

Here's what I get with -verbose:gc in the JVM params

[GC 895K->352K(5056K), 0.0193195 secs]
[GC 1248K->715K(5056K), 0.0220109 secs]
[GC 1611K->760K(5056K), 0.0126307 secs]
[GC 1174K->778K(5056K), 0.0089254 secs]
[GC 1674K->1468K(5056K), 0.0143546 secs]
[GC 2364K->2003K(5056K), 0.0086693 secs]
[GC 2893K->2103K(5056K), 0.0070341 secs]
[GC 4403K->4151K(5184K), 0.0057767 secs]
[Full GC 4151K->4151K(5184K), 0.1844324 secs]
[GC 6211K->6177K(7880K), 0.0023604 secs]
[Full GC 6177K->6177K(7880K), 0.1710399 secs]
[GC 10330K->10258K(11260K), 0.0029372 secs]
[Full GC 10258K->10258K(11260K), 0.1772720 secs]
[GC 11283K->11276K(18444K), 0.0096102 secs]
[GC 12295K->12295K(18444K), 0.0094970 secs]
[GC 13682K->13621K(18444K), 0.0135961 secs]
[Full GC 13676K->13160K(18444K), 0.2906238 secs]
[Full GC 13160K->13160K(23664K), 0.1733469 secs]
[Full GC 13165K->13160K(23664K), 0.1797374 secs]
2008-12-04 12:23:16
Full thread dump Java HotSpot(TM) Client VM (11.0-b16 mixed mode, sharing):

"thread applet-pangnomic.PanGnomicApplet.class" prio=4 tid=0x06930400 nid=0x304
in Object.wait() [0x077bf000..0x077bfc94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2119fab8> (a sun.plugin.AppletViewer)
at java.lang.Object.wait(Object.java:485)
at sun.applet.AppletPanel.getNextEvent(Unknown Source)
- locked <0x2119fab8> (a sun.plugin.AppletViewer)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"AWT-EventQueue-2" prio=4 tid=0x0692e400 nid=0x354 in Object.wait() [0x075bf000.
.0x075bfd94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2119fd58> (a java.awt.EventQueue)
at java.lang.Object.wait(Object.java:485)
at java.awt.EventQueue.getNextEvent(Unknown Source)
- locked <0x2119fd58> (a java.awt.EventQueue)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

"TimerQueue" daemon prio=6 tid=0x06905c00 nid=0x498 in Object.wait() [0x073bf000
..0x073bfb14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x210f0298> (a javax.swing.TimerQueue)
at javax.swing.TimerQueue.run(Unknown Source)
- locked <0x210f0298> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Unknown Source)

"ConsoleWriterThread" daemon prio=6 tid=0x06909800 nid=0x1ec in Object.wait() [0
x072bf000..0x072bfb94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x210672f8> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at com.sun.deploy.util.ConsoleTraceListener$ConsoleWriterThread.run(Unkn
own Source)
- locked <0x210672f8> (a java.lang.Object)

"AWT-EventQueue-0" prio=6 tid=0x068ce000 nid=0x140 in Object.wait() [0x06ebf000.
.0x06ebfd14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2107e0b0> (a java.awt.EventQueue)
at java.lang.Object.wait(Object.java:485)
at java.awt.EventQueue.getNextEvent(Unknown Source)
- locked <0x2107e0b0> (a java.awt.EventQueue)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

"AWT-EventQueue-1" prio=6 tid=0x068c3c00 nid=0x588 runnable [0x06dbf000..0x06dbf
d94]
java.lang.Thread.State: RUNNABLE
at com.sun.deploy.util.ConsoleHelper.dumpAllStacksImpl(Native Method)
at com.sun.deploy.util.ConsoleHelper.dumpAllStacks(Unknown Source)
at sun.plugin.util.PluginConsoleController.dumpAllStacks(Unknown Source)

at com.sun.deploy.util.ConsoleWindow$2.actionPerformed(Unknown Source)
at javax.swing.JComponent$ActionStandin.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.KeyboardManager.fireBinding(Unknown Source)
at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source)
at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Sou
rce)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Sour
ce)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Sour
ce)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

"CacheCleanUpThread" daemon prio=6 tid=0x05937000 nid=0x4b8 in Object.wait() [0x
067bf000..0x067bfb14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2109d0d0> (a com.sun.deploy.cache.CleanupThread)
at java.lang.Object.wait(Object.java:485)
at com.sun.deploy.cache.CleanupThread.run(Unknown Source)
- locked <0x2109d0d0> (a com.sun.deploy.cache.CleanupThread)

"CacheMemoryCleanUpThread" daemon prio=6 tid=0x05935c00 nid=0x560 in Object.wait
() [0x066bf000..0x066bfb94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2109d1c8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x2109d1c8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at com.sun.deploy.cache.MemoryCache$LoadedResourceCleanupThread.run(Unkn
own Source)

"traceMsgQueueThread" daemon prio=6 tid=0x05932800 nid=0x408 in Object.wait() [0
x065af000..0x065afc14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2109ef00> (a java.util.ArrayList)
at java.lang.Object.wait(Object.java:485)
at com.sun.deploy.util.Trace$TraceMsgQueueChecker.run(Unknown Source)
- locked <0x2109ef00> (a java.util.ArrayList)
at java.lang.Thread.run(Unknown Source)

"AWT-Windows" daemon prio=6 tid=0x05930800 nid=0x3fc runnable [0x0643f000..0x064
3fc94]
java.lang.Thread.State: RUNNABLE
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"AWT-Shutdown" prio=6 tid=0x0592f400 nid=0x3a0 in Object.wait() [0x0633f000..0x0
633fd14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2109d328> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at sun.awt.AWTAutoShutdown.run(Unknown Source)
- locked <0x2109d328> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

"Java2D Disposer" daemon prio=10 tid=0x0592d000 nid=0x264 in Object.wait() [0x06
23f000..0x0623fd94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2109d3b8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x2109d3b8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"Low Memory Detector" daemon prio=6 tid=0x05874800 nid=0x320 runnable [0x0000000
0..0x00000000]
java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x0586e400 nid=0x540 waiting on condition [
0x00000000..0x05f3f740]
java.lang.Thread.State: RUNNABLE

"Attach Listener" daemon prio=10 tid=0x0586cc00 nid=0x1bc runnable [0x00000000..
0x00000000]
java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x0586b800 nid=0x4f4 runnable [0x00000000
..0x00000000]
java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x05866800 nid=0x574 in Object.wait() [0x05c3f000.
.0x05c3fc94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2109d5e8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x2109d5e8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" daemon prio=10 tid=0x05861c00 nid=0x400 in Object.wait() [0x
05b3f000..0x05b3fd14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x2109ceb8> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
- locked <0x2109ceb8> (a java.lang.ref.Reference$Lock)

"main" prio=6 tid=0x03699400 nid=0x594 runnable [0x00000000..0x0012cb38]
java.lang.Thread.State: RUNNABLE

"VM Thread" prio=10 tid=0x05860400 nid=0x544 runnable

"VM Periodic Task Thread" prio=10 tid=0x05888400 nid=0x524 waiting on condition

trembovetski
Offline
Joined: 2003-12-31
Points: 0

Hm. the heap seems to be OK.

You could try running your applet as an application (or in an applet viewer) with
the following flag: -XX:+HeapDumpOnOutOfMemoryError .

Once OOME occurs it dumps the heap, then you could load it into VisualVM and use heap walker to find what's filling the heap.

Thanks,
Dmitri

demonduck
Offline
Joined: 2008-03-14
Points: 0

I don't have the JDK 1.6 installed. I develop with 1.5.0.16 in Eclipse. So I can't run
it in the 1.6.0.11 applet viewer and the 1.5 applet viewer doesn't have any
problems with my applet.

Also, I've never put a main() in my applet because I never intended to run it
as an application.

Could the fact that my applet is compiled to 1.5 be part of the problem?

The reason I use 1.5 is that many Macs have that as a standard JVM and
they can't run 1.6 applets -- at least that's what I've been told by some Mac users.
Maybe I'm wrong about that.

I'm making a test app/applet with 1.6 to see if I can
emulate the OOME. If I can emulate the OOME, then I can
do what you asked.

trembovetski
Offline
Joined: 2003-12-31
Points: 0

Not sure what you would need a 1.6 jdk for. You can download VisualVM separately from https://visualvm.dev.java.net/ , it should be able to run on a JRE.

Also, you can install 1.6 jdk and continue to use JDK1.5 for your development. I'm sure Eclipse will allow you to specify which Java platform to use.

> Also, I've never put a main() in my applet because I never intended to run it as an application.

You could run it in appletviewer, it doesn't have to be an application.

> Could the fact that my applet is compiled to 1.5 be part of the problem?

I doubt it but worth a try.

From the list of the bugs fixed in 6u11 I don't see what could have caused the regression -
http://java.sun.com/javase/6/webnotes/6u11.html

Dmitri

demonduck
Offline
Joined: 2008-03-14
Points: 0

I downloaded VisualVM. Started it and it says that I'm running on an "unsupported
Java version 1.5" which is the most recent JDK I have installed.

I have the 1.6u11 JRE but I guess VisualVM needs the JDK. I'll install that later and
get things put together. I have a test application/applet mostly working.

I seem to remember seeing this error before. I can't remember
the circumstances and it seems like it was over a year
ago maybe two. I remember that a revision release was made
sooner than usual.

Message was edited by: demonduck

rogyeu
Offline
Joined: 2006-07-30
Points: 0

demonduck,

i wrote an Applet that instantiates a large number of int array to force the OOM error when VM is running with the default settings. I created an html page to passed -Xmx arguments to increase the heap size. I tried to log the html page locally on IE 6 + XP & IE 7 + Vista on 6u11, but I cannot reproduce the issue.

OOM error can be thrown even when the arguments are passed because there really isn't enough memory. You can check the VM arguments of a plugin that are passed to the VM by pressing "s" and look at the "javaplugin.vm.option" value in Java Console.

-- RY

demonduck
Offline
Joined: 2008-03-14
Points: 0

I'm working on an applet that will do the same. Make a large array at startup time.

The problem I'm seeing could be particular to the way my applet starts threads
and allocates large arrays for large images. It also could be a problem with
Windows 2000. I run Windows 2000.

Addendum:

I made a very simple applet that allocates a 30 Meg int
array in the first couple of lines of init().

It generates an OOME after allocating a 30meg int array.
I've found that if I put the allocation in a try/catch
block and catch the OOME, the applet can recover and
continue. But I question the need to throw an OOME
for a 30meg int array. I don't know why this is happening.
But maybe it's because I have an old machine running
Windows 2000. But I do a lot of image processing using
a whole lot more memory than 30 meg and no problems.

Here's the URL of the applet:

http://pancyl.com/AppletMemoryError.htm

Here's the URL of the jar and the source:

http://pancyl.com/jars/AppletMemoryError.jar

http://pancyl.com/AppletMemoryError.java

Addendum 2:

I just tried 6u10 and am getting the same OOME for
30 meg int array in init(). It must be some sort of
timing issue the reason I haven't seen this before in
my applet. Maybe the reason I'm seeing this error now
in my pancyl panorama applet:

http://pancyl.com/

is because I trap OOME and popup a MemoryHelp page:

http://pancyl.com/memoryhelp.htm

and then I stop my applet thinking that if I have an OOME
then it's an unrecoverable error and I should stop. But
if I'm getting OOME's that can be recovered from, I should
probably continue.

So my question is: should I be getting OOME's if they
are recoverable and the applet can continue if I just
trap them in a try/catch block????? Are the OOME's I'm
seeing peculiar to my Win2K machine or do they happen to
XP and Vista machines? And should I trap and continue
because some machine might not be able to continue.

I think that OOME's should only be thrown when there really
is a problem with low memory. An OOME because I allocate
a 30meg int array with a 96meg default memory limit
doesn't seem right to me.

trembovetski
Offline
Joined: 2003-12-31
Points: 0

If your allocation rate is higher than GC can collect the garbage, you will get OOME, so timing is important.

I would suggest to profile your app and see if you are generating too much garbage and see if it can be reduced.

If it can't be, you could try to catch the OOME and run Runtime.gc()/Runtime.runFinalization() and try to allocate the data again.

Dmitri

demonduck
Offline
Joined: 2008-03-14
Points: 0

Dmitri,

Did you look at the code for the test applet I posted? There's really nothing going on there.
The allocation for the 30 meg array is just about the first thing it does. And it gets
an OOME with 96meg of memory as the default heap size.
And if I put the allocation in a try/catch block, the applet can recover from the OOME.

We had a discussion about OOME about a year ago. OOME's are supposed to be
non-recoverable. Now it turns out that OOME's are recoverable and really are not
Errors but Exceptions????

For example here is what the common knowledge about Errors is:

http://www.java-forums.org/new-java/871-difference-between-error-excepti...

In general error is which nobody can control or guess when it occurs.Exception can be guessed and can be handled.
In Java Exception and Error are sub class of Throwable.It is differentiated based on the program control.Error such as OutOfMemory Error which no programmer can guess and can handle it.It depends on dynamically based on architectire,OS and server configuration.Where as Exception programmer can handle it and can avoid application's misbehavior.For example if your code is looking for a file which is not available then IOException is thrown.Such instances programmer can guess and can handle it.

http://www.developer.com/java/article.php/1455891

What is the difference between an Error and an Exception? Paraphrasing David Flanagan and his excellent series of books entitled Java in a Nutshell, an Error indicates that a non-recoverable error has occurred that should not be caught. Errors usually cause the Java virtual machine to display a message and exit.

Sun says the same thing in a slightly different way:

"An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions."

For example, one of the subclasses of Error is named VirtualMachineError. This error is "Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating. "

http://forums.sun.com/thread.jspa?threadID=609732

The functional diiference, in terms of the compiler, is that you don't have to declare errors in throws clauses on methods, or catch them.

Conceptually, an Error means something has gone wrong with your program, which should usually give up and crash, whereas an exception is for an unusual situation that you, as a programmer, anticipated as a possibilty. So, for example, a divide-by-zero is an Error, but attempting to read a file and finding it doesn't exist is an Exception.

But now we have a JRE/plugin that throws Errors that can be recovered from.

How can we write deliverable apps/applets if we get random, supposedly non-recoverable
errors that indicate that the JVM is hosed and the program should exit when, in this
case, the OOME is a timing error between the garbage collector and the execution
of the app/applet?

Are we now supposed to put allocations in a loop like we used to do in the old UNIX/C
days. Where you try for a large Object or primitive array 10 times and garbage
collect each time it fails and *MAYBE* our app/applet will survive and run?

This is kind of nuts you know. I think this is a far more
serious problem than just my applet failing sometimes.

I think you guys should take a close look at this problem
and do something to fix it.