Re: Garbage collector: Out of memory (when running AWT/SWING code on arm-linux)

Andrew Haley <[email protected]>
Newsgroups gmane.comp.gcc.java.devel
Message-ID <[email protected]>
Andrew Haley wrote:
> ffileppo wrote:
>>> Hi guys,
>>>
>>> I'm getting the following error:
>>>
>>> GC Warning: Out of Memory! Returning NIL!
>>>
>>> when I try to run any AWT/SWING code compiled with arm-linux-gcj on my embedded box (PXA270 - 128MB Ram). (Other code just runs fine)
>>>
>>> For example this code:
>>>
>>> import javax.swing.*;
>>>
>>> public class SimpleFrame {
>>>   public static void main(String args[]) {
>>>     System.out.println("Check 1");
>>>     JFrame f = new JFrame("Simple Frame");
>>>     System.out.println("Check 2");
>>>     f.setSize(200,100);
>>>     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>>>     f.setVisible(true);
>>>   }
>>> }
>>>
>>> gives out of memory error after printing "Check 1".
>>> Trying with some other code I can see that the first AWT/SWING call causes this error.
>>>
>>> Any idea to fix / debug this problem?
> 
> I think I've found it.  The unwinder is infinitely looping 'til it runs out
> of memory.

And here it is:

(gdb) x state->frames[23].start_ip
0x40c13ac0 <_Jv_JNI_FindClass>: 0xe1a0c00d
(gdb) x state->frames[24].start_ip
0x40017f78 <__udivdi3>: 0xe92d4ff0
(gdb) x state->frames[22].start_ip
0x40c4c918 <java.lang.Class.initializeClass()void>:  0xe92d41f0
(gdb) x state->frames[23].start_ip
0x40c13ac0 <_Jv_JNI_FindClass>: 0xe1a0c00d
(gdb) x state->frames[20].start_ip
0x40c1653c <_Jv_Linker.verify_class(java.lang.Class)>: 0xe52de004
(gdb) x state->frames[21].start_ip
0x40c17ce8 <_Jv_Linker.wait_for_state(java.lang.Class, int)>:      0xe92d47f0
(gdb) x state->frames[22].start_ip
0x40c4c918 <java.lang.Class.initializeClass()void>:  0xe92d41f0
(gdb) x state->frames[23].start_ip
0x40c13ac0 <_Jv_JNI_FindClass>: 0xe1a0c00d
(gdb) x state->frames[24].start_ip
0x40017f78 <__udivdi3>: 0xe92d4ff0
(gdb) x state->frames[25].start_ip
0x4176b834 <GC_generic_push_regs>:      0xe59f3010

So here's the badness: the frame above _Jv_JNI_FindClass is wrong.  Here it's
found to be __udivdi3 but in reality it should be
Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit.  I wonder if
libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
has bad unwinder data.  It's also possible that _Jv_JNI_FindClass has bad
unwinder data.

Anyway, the kludge I suggested should work.

Andrew.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.